gpt4 book ai didi

ios - Apple Pay/Stripe 集成问题

转载 作者:可可西里 更新时间:2023-11-01 03:29:57 26 4
gpt4 key购买 nike

我已按照 Stripe 的文档和示例应用程序了解如何集成 Apple Pay。

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

Error Domain=com.stripe.lib Code=50 "Your payment information is formatted improperly. Please make sure you're correctly using the latest version of our iOS library. For more information see https://stripe.com/docs/mobile/ios ." UserInfo=0x170261b40 {com.stripe.lib:ErrorMessageKey=Your payment information is formatted improperly. Please make sure you're correctly using the latest version of our iOS library. For more information see https://stripe.com/docs/mobile/ios ., NSLocalizedDescription=Your payment information is formatted improperly. Please make sure you're correctly using the latest version of our iOS library. For more information see https://stripe.com/docs/mobile/ios .}

有人知道怎么解决吗?我正在使用最新的 Stripe 库。

谢谢。

最佳答案

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

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

PKPaymentAuthorizationViewControllerDelegate 被调用。此处的示例代码检查代码是否在针对 ApplePayStubs 的调试中运行,委托(delegate)中的 (PKPayment *)payment 转换为 STPCard 并启动到STPAPIClient 用于STTPoken 生成。以下是上述代表的正文:

#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(在模拟器上)和没有它们(在设备上)希望这有帮助:)

关于ios - Apple Pay/Stripe 集成问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27241112/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com