7

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

在 handlePaymentAuthorizationWithPayment 方法的 createTokenWithPayment 下,我收到错误消息:

错误 Domain=com.stripe.lib Code=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 库。

谢谢。

4

2 回答 2

5

这一点 RnD 帮助了我。深入研究 Stripe 自己提供的CustomSampleProject ,ApplePayStubs 在STPCard被代表识别时工作得很好

- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                   didAuthorizePayment:(PKPayment *)payment
                            completion:(void (^)(PKPaymentAuthorizationStatus))completion

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

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

于 2015-04-01T17:33:12.100 回答
3

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

当我最初在我的应用程序中设置 Stripe / Apple Pay 时,当我尝试实施STPTestPaymentAuthorizationController. 我发现了这里描述的确切问题(Stripe payment library and undefined symbols for x86_64)。

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

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

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

于 2014-12-05T07:02:28.773 回答