• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-12-11 22:43:23 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我已经实现了支持 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)applePayButtonTouchUpInsideid)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];
    }
}

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

- (void)paymentAuthorizationViewControllerPKPaymentAuthorizationViewController *)controller
                       didAuthorizePaymentPKPayment *)payment
                                   handlervoid (^)(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] initWithStatusKPaymentAuthorizationStatusSuccess 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] initWithStatusKPaymentAuthorizationStatusFailure 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];
         }
     }];
}



Best Answer-推荐答案


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

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

关于ios - Braintree Apple Sandbox Pay 扫描指纹 iOS 后显示付款未完成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55833666/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap