2015-05-27 47 views
1

我想將Braintree API集成到我的android應用程序中。我參考Braintree頁面,我瞭解瞭如何將它集成到應用程序中。但是當我想在我目前顯示的活動佈局的下方顯示Drop-In UI時,我遇到了一個問題。但在演示中,它將開始新的活動BraintreePaymentActivity.javaAndroid Braintree SDK在當前應用程序的活動中集成

我不想打開新的活動我只想在我的活動中顯示相同的操作。爲此我推薦Card-form demo並在Purchase.And上添加了我的自定義按鈕,並在購買按鈕上單擊我在以下代碼中調用。但在這裏我不明白從哪裏我可以得到Nonce值?

Braintree.setup (this, CLIENT_TOKEN_FROM_SERVER, new Braintree.BraintreeSetupFinishedListener() { 
@Override 
public void onBraintreeSetupFinished (boolean setupSuccessful, Braintree braintree, String errorMessage, Exception exception) { 
    if (setupSuccessful) { 
     // braintree is now setup and available for use 
    } else { 
     // Braintree could not be initialized, check errors and try again 
     // This is usually a result of a network connectivity error 
    } 
}}); 

如果任何人有任何想法,那麼請在這裏建議。

我被困在Braintree API

在此先感謝。

回答

1

您的用例不適合Drop-in用戶界面。

爲了添加一個PaymentMethodNonce聽衆,一旦設置了Braintree,只需撥打Braintree.addListener並提供Braintree.PaymentMethodNonceListener實施。我在下面包含了一個例子。您也可以參閱Braintree文檔中信用卡指南中的client side integration部分。

Braintree.setup (this, CLIENT_TOKEN_FROM_SERVER, new Braintree.BraintreeSetupFinishedListener() { 
    @Override 
    public void onBraintreeSetupFinished (boolean setupSuccessful, Braintree braintree, String errorMessage, Exception exception) { 
     if (setupSuccessful) { 
      // braintree is now setup and available for use 
      braintree.addListener(new Braintree.PaymentMethodNonceListener() { 
       public void onPaymentMethodNonce(String paymentMethodNonce) { 
        // Communicate the nonce to your server 
       } 
      }); 
     } else { 
      // Braintree could not be initialized, check errors and try again 
      // This is usually a result of a network connectivity error 
     } 
    } 
}); 
相關問題