这是我创建 PaymentMethod API 的代码。我从以下位置找到了这段代码 https://docs.stripe.com/api/ payment_methods/create 但它给出了错误。需要一个解决方案来克服这个问题。
import com.stripe.Stripe;
import com.stripe.exception.StripeException;
import com.stripe.model.PaymentMethod;
import com.stripe.param.PaymentMethodCreateParams;
public class Main {
public static void main(String[] args) throws StripeException {
System.out.println("Hello world!");
Stripe.apiKey = "sk_t";
PaymentMethodCreateParams params =
PaymentMethodCreateParams.builder()
.setType(PaymentMethodCreateParams.Type.CARD)
.setCard(
PaymentMethodCreateParams.CardDetails.builder()
.setNumber("pm_card_visa")
.setExpMonth(8L)
.setExpYear(2026L)
.setCvc("314")
.build()
)
.build();
PaymentMethod paymentMethod = PaymentMethod.create(params);
System.out.println("done!");
}
}
运行此代码后我发现以下错误。请帮忙解释为什么会出现此错误。 我正在使用这个条纹版本:25.0.0
错误: **将信用卡号直接发送到 Stripe API 通常是不安全的。我们建议您使用映射到您正在使用的测试卡的测试令牌,请参阅https://stripe.com/docs/testing。启用原始卡数据 API **
Exception in thread "main" com.stripe.exception.CardException:
Sending credit card numbers directly to the Stripe API is generally unsafe. We suggest you use test tokens that map to the test card you are using, see https://stripe.com/docs/testing. To enable raw card data APIs in test mode, see https://support.stripe.com/questions/enabling-access-to-raw-card-data-apis.; request-id: req_UzVH4M3J5n22oP
at com.stripe.net.LiveStripeResponseGetter.handleApiError(LiveStripeResponseGetter.java:255)
at com.stripe.net.LiveStripeResponseGetter.handleError(LiveStripeResponseGetter.java:198)
at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:102)
at com.stripe.model.PaymentMethod.create(PaymentMethod.java:405)
at com.stripe.model.PaymentMethod.create(PaymentMethod.java:379)
at com.sam.Main.main(Main.java:32)
进程已完成,退出代码为 1