Braintree Apple Sandbox Pay 扫描指纹 iOS 后显示付款未完成错误

Posted

技术标签:

【中文标题】Braintree Apple Sandbox Pay 扫描指纹 iOS 后显示付款未完成错误【英文标题】:Braintree Apple sandbox Pay shows payment not completed error after scanning finger prints iOS 【发布时间】:2019-04-24 15:27:38 【问题描述】:

我已经实现了支持 Apple Pay 的 Braintree。但我面临一个问题。一切运行正常,但每当我尝试付款时,它都会显示“付款未完成”的标志。我已检查我的域是否已通过验证。我用下面的代码调用了 Apple Pay 按钮。

- (PKPaymentRequest *)paymentRequest

    PKPaymentRequest *paymentRequest = [[PKPaymentRequest alloc] init];
    paymentRequest.merchantIdentifier = @"merchant.myIdentifier";
    //paymentRequest.merchantIdentifier = @"merchant.mysandboxIdentifier";
    paymentRequest.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkVisa, PKPaymentNetworkMasterCard];
    paymentRequest.merchantCapabilities = PKMerchantCapability3DS;
    paymentRequest.countryCode = @"US"; // e.g. US
    paymentRequest.currencyCode = @"USD"; // e.g. USD
//    self.requiredShippingAddressFields = PKAddressFieldPostalAddress;
//    paymentRequest.requiredShippingAddressFields = PKAddressFieldAll;

//    paymentRequest.shippingMethods = [self ShipingMethod];

//    paymentRequest.shippingContact = [self ShipingAddress:@"Delivered" :paymentRequest];
   paymentRequest.paymentSummaryItems = [self PaymentSummaryItems];
    return paymentRequest;



- (IBAction)applePayButtonTouchUpInside:(id)sender


    self.navigationController.navigationItem.backBarButtonItem.enabled = NO;
    self.iconLoadingIndicator.hidden = NO;
    [self.iconLoadingIndicator startAnimating];

    backBtn.enabled = NO;
    self.applePayBtn.enabled = NO;
    self.creditCardBtn.enabled = NO;
    self.checkoutBtn.enabled = NO;

    if([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa,PKPaymentNetworkDiscover]]) // Returns FALSE
    
        if ([PKPaymentAuthorizationViewController canMakePayments])
        
            PKPaymentRequest *paymentRequest = [self paymentRequest];
            PKPaymentAuthorizationViewController *vc = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest];
            if (vc)
            
                self.payment_mode = kApplePayMode;
                vc.delegate = self;
                [self.navigationController presentViewController:vc animated:YES completion:nil];

            
            else
            
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Something went wrong. Please Try Again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                [alert show];
               [self StopLoader];
            
        
    
    else
    
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Your card does not support Apple Pay." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];

       [self StopLoader];
    

此代表未调用,因为它卡在付款未完成过程中。

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                       didAuthorizePayment:(PKPayment *)payment
                                   handler:(void (^)(PKPaymentAuthorizationResult *result))completion API_AVAILABLE(ios(11.0), watchos(4.0));

    isApplePayInitiatingPayment = YES;

    // Example: Tokenize the Apple Pay payment
    BTApplePayClient *applePayClient = [[BTApplePayClient alloc]
                                        initWithAPIClient:self.braintreeClient];
    [applePayClient tokenizeApplePayPayment:payment
                                 completion:^(BTApplePayCardNonce *tokenizedApplePayPayment,
                                              NSError *error)
     
         if (tokenizedApplePayPayment)
         
             // On success, send nonce to your server for processing.
             // If applicable, address information is accessible in `payment`.
             NSLog(@"nonce = %@", tokenizedApplePayPayment.nonce);
             self.wcitiesBraintreeCreateTransaction = [[WcitiesBraintreeCreateTransaction alloc] init];
             [self.wcitiesBraintreeCreateTransaction CreateTransaction:self.totalPrice OneTimeNonce:tokenizedApplePayPayment.nonce paypal_payer_id:@"" payment_mode:kApplePayMode :^(NSMutableArray *result, NSError *error)
              
                  if (result.count>0)
                  
                      self.transaction_id = [result objectAtIndex:0];
                      [self generateClientOrder:NO];
                  
                  else
                  
                      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Transaction failure. Please try again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
                      [alert show];
                      [self StopLoader];
                  
              ];


             // Then indicate success or failure via the completion callback, e.g.
             PKPaymentAuthorizationResult *result = [[PKPaymentAuthorizationResult alloc] initWithStatus:PKPaymentAuthorizationStatusSuccess errors:nil];
             completion(result);
          else 
             // Tokenization failed. Check `error` for the cause of the failure.

             // Indicate failure via the completion callback:
             PKPaymentAuthorizationResult *result = [[PKPaymentAuthorizationResult alloc] initWithStatus:PKPaymentAuthorizationStatusFailure errors:nil];
             completion(result);
             UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Transaction failure. Please try again." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
             [alert show];
             [self StopLoader];
         
     ];

【问题讨论】:

我想警告你不要使用 Braintree。在拥有一个帐户多年后,他们开始为最简单的交易要求大量的文书工作 - 我们从未遇到任何争议或退款!后来我发现它们归 Paypal 所有,所以这可能说明了一切。 感谢您分享宝贵的经验。肯定会和我的团队讨论这件事。但至少如果你能帮助我解决我目前的情况,那真的很棒:) 【参考方案1】:

尝试使用 Apple 提供的其他测试信用卡。 https://developer.apple.com/apple-pay/sandbox-testing/

我也遇到了这个问题,并通过尝试不同的卡直到其中一张起作用来解决它。

【讨论】:

我知道回复有点晚了,但试过不同的 Apple 卡不工作。应用程序开发属于印度地区,所以我认为可能是地区会有问题,所以我将设备地区从设备设置更改为美国和英国,我也尝试使用 ***,但没有任何效果。

以上是关于Braintree Apple Sandbox Pay 扫描指纹 iOS 后显示付款未完成错误的主要内容,如果未能解决你的问题,请参考以下文章

Braintree - 插入式 UI - Apple Pay - Swift 3

如何使用 Braintree.js 与 Braintree 支付网关集成? [关闭]

Braintree v.Zero Drop In UI 是不是支持 Apple Pay?

Braintree Paypal 在沙盒中工作,但不是生产

www.sandbox.itunes.apple.com 已关闭

不能远程登录 gateway.sandbox.push.apple.com 2195?