我正在尝试创建一张信用卡,因此我需要调用 paymentMethodNone()
。根据文档我可以
Use PaymentMethod.create() to create a payment method for an existing customer:
// It's not clear what A_PAYMENT_METHOD_TOKEN has to be
Result<PaymentMethodNonce> result = bt.paymentMethodNonce()
.create("A_PAYMENT_METHOD_TOKEN");
String nonceFromTheClient = result.getTarget().getNonce();
Customer customer = customerResult.getTarget();
PaymentMethodRequest paymentMethodRequest = new PaymentMethodRequest()
.customerId(customer.getId())
.paymentMethodNonce(nonceFromTheClient);
Result<? extends PaymentMethod> paymentMethodResult = bt.paymentMethod()
.create(paymentMethodRequest);
PaymentMethod paymentMethod = paymentMethodResult.getTarget();
但是,文档中没有关于有效 token 的信息。都不是here也不here - 还是我只是瞎了眼?
完全披露:我在 Braintree 工作。如果您还有任何疑问,请随时联系support .
您不需要 payment_method_token
来创建 PaymentMethod
。
要创建信用卡,您需要创建一个 PaymentMethod .首先,从传入请求中检索 payment_method_nonce
。接下来,使用 PaymentMethodRequest
创建 PaymentMethod
。
//payment_method_nonce will be a post parameter in the request
//set nonceFromTheClient to equal payment_method_nonce
PaymentMethodRequest paymentMethodRequest = new PaymentMethodRequest()
.customerId(customer.getId())
.paymentMethodNonce(nonceFromTheClient);
Result<? extends PaymentMethod> result = gateway.paymentMethod().create(request);
我是一名优秀的程序员,十分优秀!