什么是有效的付款方式令牌?

时间:2016-08-01 19:32:39

标签: paypal braintree

我正在尝试创建信用卡,因此我需要致电paymentMethodNone()。根据文件,我可以

  

使用PaymentMethod.create()为现有客户创建付款方式:

// 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();

但是,没有关于文档中有效令牌的说法。既不是here也不是here - 或者我只是盲目?

1 个答案:

答案 0 :(得分:1)

完全披露:我在Braintree工作。如果您有任何其他问题,请随时联系support

您无需payment_method_token即可创建PaymentMethod

要创建信用卡,您需要创建PaymentMethod。首先,从传入的请求中检索payment_method_nonce。接下来,使用PaymentMethod创建PaymentMethodRequest

//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);