Apple Pay/Stripe集成问题

May*_*ang 7 objective-c ios stripe-payments parse-platform applepay

我已经按照Stripe的文档和示例应用程序来集成Apple Pay.

在handlePaymentAuthorizationWithPayment方法中,在createTokenWithPayment下,我收到错误:

错误域= com.stripe.lib代码= 50"您的付款信息格式不正确.请确保您使用的是最新版本的iOS库.有关详细信息,请参阅https://stripe.com/docs/mobile/ios." UserInfo = 0x170261b40 {com.stripe.lib:ErrorMessageKey =您的付款信息格式不正确.请确保您正确使用我们iOS库的最新版本.有关详细信息,请参阅https://stripe.com/docs/mobile/ios.,NSLocalizedDescription =您的付款信息格式不正确.请确保您正确使用我们iOS库的最新版本.有关详细信息,请参阅https://stripe.com/docs/mobile/ios.}

有谁知道如何解决这个问题?我正在使用最新的Stripe库.

谢谢.

Moh*_*med 5

这一点RnD帮助了我.深入挖掘CustomSampleProject由条纹自行提供,ApplePayStubs工作时很好STPCard时确认委托

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                   didAuthorizePayment:(PKPayment *)payment
                            completion:(void (^)(PKPaymentAuthorizationStatus))completion
Run Code Online (Sandbox Code Playgroud)

PKPaymentAuthorizationViewControllerDelegate被调用.此处的示例代码检查代码是否在ApplePayStubs的调试中运行,代理中的(PKPayment*)付款转换为STPCard并启动到STPAPIClient以进行STPToken生成.以下是上述代表的正文:

#if DEBUG // This is to handle a test result from ApplePayStubs
if (payment.stp_testCardNumber)
{
    STPCard *card = [STPCard new];
    card.number = payment.stp_testCardNumber;
    card.expMonth = 12;
    card.expYear = 2020;
    card.cvc = @"123";
    [[STPAPIClient sharedClient] createTokenWithCard:card
                                          completion:^(STPToken *token, NSError *error)
    {
        if (error)
        {
            completion(PKPaymentAuthorizationStatusFailure);
            [[[UIAlertView alloc] initWithTitle:@"Error"
                                        message:@"Payment Unsuccessful! \n Please Try Again"
                                       delegate:self
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil] show];
            return;
        }
    /*
     Handle Token here
     */
                                            }];
}
#else
[[STPAPIClient sharedClient] createTokenWithPayment:payment
                                         completion:^(STPToken *token, NSError *error)
{
    if (error)
    {
        completion(PKPaymentAuthorizationStatusFailure);
        [[[UIAlertView alloc] initWithTitle:@"Error"
                                    message:@"Payment Unsuccessful!"
                                   delegate:self
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil] show];
        return;
    }
    /*
     Handle Token here
     */
}];
#endif
Run Code Online (Sandbox Code Playgroud)

这对我有用.使用ApplePayStubs(在模拟器上)和没有它们(在设备上)希望这有助于:)


May*_*ang 3

我想我知道这里发生了什么。留下这个以防它对任何人有帮助。

当我最初在我的应用程序中设置 Stripe / Apple Pay 时,当我尝试实施时,我不断收到许多错误STPTestPaymentAuthorizationController。我找到了此处描述的确切问题(Stripe payment Library and undefined keywords for x86_64)。

我通过注释掉 Stripe 的部分代码来复制上面定义的解决方案,这可能(?)产生了错误Error Domain=com.stripe.lib Code=50

我通过STPTestPaymentAuthorizationController根本不使用来解决这个问题,只是将其替换为PKPaymentAuthorizationViewControllerin#DEBUG模式。

tl:dr不完全确定为什么 STPTestPaymentAuthorization 不起作用;通过在测试模式下使用我的 iPhone 和 Stripe 仪表板运行 PKPaymentAuthorizationViewController 完全避免了这种情况。

  • @SaiJithendra 正确,即使交易在您的手机上显示成功,它也不会从您的卡中扣费。 (3认同)