本文介绍了我如何在真实设备上测试Braintree + Apple Pay?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为来自美国以外的美国客户开发使用Apple Pay的应用程序。我正在使用Braintree + Apple Pay。我们支持真正的信用卡给Passbook,但我们无法验证它们。



我成功生成了一个客户令牌, self.braintree ,并尝试过BT的两种集成方式。


  1. BTPaymentProvider - 我们对付款方式创建的抽象。

      if(self.braintree&&![self.braintree isKindOfClass:[NSNull class]])
    {
    self.provider = [braintree paymentProviderWithDelegate:self];
    if([self.provider canCreatePaymentMethodWithProviderType:BTPaymentProviderTypeApplePay])
    {
    self.provider.paymentSummaryItems = @ [[PKPaymentSummaryItem summaryItemWithLabel:@XXXXamount:[NSDecimalNumber decimalNumberWithString:@1 ]]];
    }
    [self.provider createPaymentMethod:BTPaymentProviderTypeApplePay];
    }

    但它不会推送 PKPaymentAuthorizationViewController 。

  2. PassKit - Apple的ApplePay API。

      if([PKPaymentAuthorizationViewController canMakePayments])//它返回TRUE 
    {
    PKPaymentRequest * paymentRequest = [[PKPaymentRequest alloc] init];
    paymentRequest.countryCode = @US;
    paymentRequest.currencyCode = @USD;
    paymentRequest.merchantCapabilities = PKMerchantCapabilityEMV | PKMerchantCapability3DS;
    paymentRequest.merchantIdentifier = MERCHANTID;
    paymentRequest.supportedNetworks = @ [PKPaymentNetworkAmex,PKPaymentNetworkMasterCard,PKPaymentNetworkVisa];
    paymentRequest.paymentSummaryItems = @ [[PKPaymentSummaryItem summaryItemWithLabel:@TESTamount:[NSDecimalNumber decimalNumberWithString:@1]]];

    if([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@ [PKPaymentNetworkAmex,PKPaymentNetworkMasterCard,PKPaymentNetworkVisa]])//返回FALSE
    {
    PKPaymentAuthorizationViewController * vc = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest] ;
    vc.delegate = self;
    [self presentViewController:vc animated:YES completion:nil];


    $ / code $ / pre
    $ b $

    这给出了vc是零。

  3. 如果错了,请纠正我的错误。如何在真实设备上测试它?

    解决方案

    很可能您的应用的Apple Pay授权设置不正确。 / p>

    我注意到 canMakePayments 返回 YES 和 canMakePaymentsUsingNetworks:返回 NO ,当权利没有被设置。

    (我也注意到,当你在 PKPaymentRequest 上设置的商家ID不匹配时,它们都可以返回 YES 在这种情况下,您的 PKPaymentAuthorizationViewController 将不为零,但会在控制台中记录一个隐晦的错误)。



    因此,为了验证您的应用程序是否配置了Apple Pay,请确保您的目标设置的Capabilities部分中的Apple Pay为On,并且它具有商家标识符你需要)。



    然后:


    • 如果使用 BTPaymentProvider 集成方法,确保在Braintree控制面板中正确设置证书和商户标识符。

    • 如果使用直接 PassKit 集成方法,确保您将 merchantIdentifier 属性设置为授权中匹配的商户标识符。

    I am developing an app using Apple Pay for a US Client from outside the US. I am using Braintree + Apple Pay. We support real credit cards to Passbook, but we can't verify them.

    I successfully generated a client token, self.braintree and tried BT's both ways of integration.

    1. BTPaymentProvider - Our abstraction on payment method creation.

      if(self.braintree && ![self.braintree isKindOfClass:[NSNull class]])
      {
          self.provider = [braintree paymentProviderWithDelegate:self];
          if ([self.provider canCreatePaymentMethodWithProviderType:BTPaymentProviderTypeApplePay])
          {
              self.provider.paymentSummaryItems = @[[PKPaymentSummaryItem summaryItemWithLabel:@"XXXX" amount:[NSDecimalNumber decimalNumberWithString:@"1"]]];
          }
          [self.provider createPaymentMethod:BTPaymentProviderTypeApplePay];
      }
      

      but its not pushing "PKPaymentAuthorizationViewController". No exception too to track it down.

    2. PassKit - Apple's ApplePay APIs.

      if([PKPaymentAuthorizationViewController canMakePayments]) // It returns TRUE
      {
          PKPaymentRequest *paymentRequest = [[PKPaymentRequest alloc] init];
          paymentRequest.countryCode = @"US";
          paymentRequest.currencyCode = @"USD";
          paymentRequest.merchantCapabilities = PKMerchantCapabilityEMV | PKMerchantCapability3DS;
          paymentRequest.merchantIdentifier = MERCHANTID;
          paymentRequest.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa];
          paymentRequest.paymentSummaryItems = @[ [PKPaymentSummaryItem summaryItemWithLabel:@"TEST" amount:[NSDecimalNumber decimalNumberWithString:@"1"]] ];
      
          if([PKPaymentAuthorizationViewController canMakePaymentsUsingNetworks:@[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa]]) // Returns FALSE
          {
              PKPaymentAuthorizationViewController *vc = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:paymentRequest];
              vc.delegate = self;
              [self presentViewController:vc animated:YES completion:nil];
          }
      }
      

      This gives "vc" is nil.

    Correct me, if it's wrong. How do I test it on a real device?

    解决方案

    It's likely that your app's Apple Pay entitlement is not set up correctly.

    I've noticed canMakePayments returns YES and canMakePaymentsUsingNetworks: returns NO when the entitlement is not set.

    (I've also noticed that they can both return YES when the merchant ID you set on your PKPaymentRequest does not match the merchant ID of your Apple Pay entitlement. In this case, your PKPaymentAuthorizationViewController will be non-nil, but presenting it logs a cryptic error in the console).

    So to verify that Apple Pay is configured for your app, ensure that "Apple Pay" is "On" in the Capabilities section of your target settings, and that it has a merchant identifier (which you'll need to set up if you haven't already).

    Then either:

    • If using your BTPaymentProvider integration method, ensure that the certificate and merchant identifier are correctly set up in the Braintree control panel.
    • If using your direct PassKit integration method, ensure that you are setting merchantIdentifier property to the matching merchant identifier in the entitlement.

    这篇关于我如何在真实设备上测试Braintree + Apple Pay?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 08:02