菜鸟教程小白 发表于 2022-12-11 22:43:23

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


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

<pre><code>- (PKPaymentRequest *)paymentRequest
{
    PKPaymentRequest *paymentRequest = [ init];
    paymentRequest.merchantIdentifier = @&#34;merchant.myIdentifier&#34;;
    //paymentRequest.merchantIdentifier = @&#34;merchant.mysandboxIdentifier&#34;;
    paymentRequest.supportedNetworks = @;
    paymentRequest.merchantCapabilities = PKMerchantCapability3DS;
    paymentRequest.countryCode = @&#34;US&#34;; // e.g. US
    paymentRequest.currencyCode = @&#34;USD&#34;; // e.g. USD
//    self.requiredShippingAddressFields = PKAddressFieldPostalAddress;
//    paymentRequest.requiredShippingAddressFields = PKAddressFieldAll;

//    paymentRequest.shippingMethods = ;

//    paymentRequest.shippingContact = ;
   paymentRequest.paymentSummaryItems = ;
    return paymentRequest;
}


- (IBAction)applePayButtonTouchUpInside:(id)sender
{

    self.navigationController.navigationItem.backBarButtonItem.enabled = NO;
    self.iconLoadingIndicator.hidden = NO;
    ;

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

    if(]) // Returns FALSE
    {
      if ()
      {
            PKPaymentRequest *paymentRequest = ;
            PKPaymentAuthorizationViewController *vc = [ initWithPaymentRequest:paymentRequest];
            if (vc)
            {
                self.payment_mode = kApplePayMode;
                vc.delegate = self;
                ;

            }
            else
            {
                UIAlertView *alert = [ initWithTitle:@&#34;&#34; message:@&#34;Something went wrong. Please Try Again.&#34; delegate:self cancelButtonTitle:@&#34;OK&#34; otherButtonTitles:nil, nil];
                ;
               ;
            }
      }
    }
    else
    {
      UIAlertView *alert = [ initWithTitle:@&#34;&#34; message:@&#34;Your card does not support Apple Pay.&#34; delegate:self cancelButtonTitle:@&#34;OK&#34; otherButtonTitles:nil, nil];
      ;

       ;
    }
}
</code></pre>

<p>此代表未调用,因为它卡在付款未完成过程中。 <a href="/image/vWN8s.jpg" rel="noreferrer noopener nofollow"><img src="/image/vWN8s.jpg" alt="enter image description here"/></a> </p>

<pre><code>- (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 = [
                                        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(@&#34;nonce = %@&#34;, tokenizedApplePayPayment.nonce);
             self.wcitiesBraintreeCreateTransaction = [ init];
             [self.wcitiesBraintreeCreateTransaction CreateTransaction:self.totalPrice OneTimeNonce:tokenizedApplePayPayment.nonce paypal_payer_id:@&#34;&#34; payment_mode:kApplePayMode :^(NSMutableArray *result, NSError *error)
            {
                  if (result.count&gt;0)
                  {
                      self.transaction_id = ;
                      ;
                  }
                  else
                  {
                      UIAlertView *alert = [ initWithTitle:@&#34;&#34; message:@&#34;Transaction failure. Please try again.&#34; delegate:self cancelButtonTitle:@&#34;OK&#34; otherButtonTitles:nil, nil];
                      ;
                      ;
                  }
            }];


             // Then indicate success or failure via the completion callback, e.g.
             PKPaymentAuthorizationResult *result = [ 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 = [ initWithStatus:PKPaymentAuthorizationStatusFailure errors:nil];
             completion(result);
             UIAlertView *alert = [ initWithTitle:@&#34;&#34; message:@&#34;Transaction failure. Please try again.&#34; delegate:self cancelButtonTitle:@&#34;OK&#34; otherButtonTitles:nil, nil];
             ;
             ;
         }
   }];
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>尝试使用 Apple 提供的其他测试信用卡。 <a href="https://developer.apple.com/apple-pay/sandbox-testing/" rel="noreferrer noopener nofollow">https://developer.apple.com/apple-pay/sandbox-testing/</a> </p>

<p>我也遇到了这个问题,并通过尝试不同的卡直到其中一张起作用来解决它。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Braintree Apple Sandbox Pay 扫描指纹 iOS 后显示付款未完成错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/55833666/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/55833666/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Braintree Apple Sandbox Pay 扫描指纹 iOS 后显示付款未完成错误