【发布时间】:2016-12-15 09:32:24
【问题描述】:
我在我的应用程序中集成了 Braintree SDK。我的应用程序使用 Swift 语言构建。我的问题是,如果我在其中使用 iOS SDK,它还需要在服务器端进行一些设置用于 paymentMethodNonce?
【问题讨论】:
我在我的应用程序中集成了 Braintree SDK。我的应用程序使用 Swift 语言构建。我的问题是,如果我在其中使用 iOS SDK,它还需要在服务器端进行一些设置用于 paymentMethodNonce?
【问题讨论】:
使用Braintree为PayPal生成Nonce
BTPayPalRequest *request= [[BTPayPalRequest alloc] initWithAmount:amount];
request.currencyCode = @"USD"; // Optional; see BTPayPalRequest.h for other options
[payPalDriver requestOneTimePayment:request completion:^(BTPayPalAccountNonce * _Nullable tokenizedPayPalAccount, NSError * _Nullable error)
{
if (tokenizedPayPalAccount)
{
NSLog(@"Got a nonce: %@", tokenizedPayPalAccount.nonce);
}
else {
// Buyer canceled payment approval
// Tokenization failed. Check `error` for the cause of the failure.
}
}];
使用Braintree为Apple Pay生成Nonce
// Example: Tokenize the Apple Pay payment
BTApplePayClient *applePayClient = [[BTApplePayClient alloc]
initWithAPIClient:self.braintreeClient];
[applePayClient tokenizeApplePayPayment:payment
completion:^(BTApplePayCardNonce *tokenizedApplePayPayment,
NSError *error)
{
if (tokenizedApplePayPayment)
{
NSLog(@"nonce = %@", tokenizedApplePayPayment.nonce);
}
else
{
// Tokenization failed. Check `error` for the cause of the failure.
// Indicate failure via the completion callback:
completion(PKPaymentAuthorizationStatusFailure);
}
}];
【讨论】: