2016-08-01 48 views
0

我正在嘗試創建信用卡,因此我需要致電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

完全披露:我在布倫特裏工作。如果您有任何其他問題,請隨時聯繫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); 
+0

謝謝你清理那個! :) – displayname

+0

我們如何檢索payment_method_nonce? –