【问题标题】:Braintree iOS v4 SDKBraintree iOS v4 SDK
【发布时间】:2016-12-15 09:32:24
【问题描述】:

我在我的应用程序中集成了 Braintree SDK。我的应用程序使用 Swift 语言构建。我的问题是,如果我在其中使用 iOS SDK,它还需要在服务器端进行一些设置用于 paymentMethodNonce?

【问题讨论】:

    标签: ios braintree


    【解决方案1】:

    使用BraintreePayPal生成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.                 
                }
            }];
    

    使用BraintreeApple 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);                                           
    
                                         }
                                     }];
    

    【讨论】:

      猜你喜欢
      • 2022-11-15
      • 2016-01-20
      • 1970-01-01
      • 2016-05-13
      • 2014-05-16
      • 2015-02-04
      • 2015-03-15
      • 1970-01-01
      • 2014-12-20
      相关资源
      最近更新 更多