I have followed Stripe's documentation and Example App on integrating Apple Pay.
我已经关注了Stripe的文档和示例应用程序来集成Apple Pay。
In the handlePaymentAuthorizationWithPayment method, under createTokenWithPayment, I am getting the error:
在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 .}
错误Domain = 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。}
Anyone know how to resolve this? I am using the latest Stripe library.
有谁知道如何解决这个问题?我正在使用最新的Stripe库。
Thanks.
谢谢。
2 个解决方案
#1
5
This little bit of RnD helped me. Digging into the CustomSampleProject provided by Stripe themselves, ApplePayStubs works pretty well when the STPCard is recognized when the delegate
这一点RnD对我有所帮助。深入研究Stripe自己提供的CustomSampleProject,当代表识别出STPCard时,ApplePayStubs运行良好
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus))completion
of PKPaymentAuthorizationViewControllerDelegate is called. The sample code here checked if the code was run in debug that is for ApplePayStubs, the (PKPayment *)payment in the delegate is converted to a STPCard and is launched to the STPAPIClient for STPToken generation. Following is the body of the above mentioned delegate:
调用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
This worked for me. With ApplePayStubs (on Simulator) and without them (on Device) Hope this Helps :)
这对我有用。使用ApplePayStubs(在模拟器上)并且没有它们(在设备上)希望这有助于:)
#2
3
I think I know what happened here. Leaving this up in case it helps anybody.
我想我知道这里发生了什么。离开这个以防万一它可以帮助任何人。
When I initially set up Stripe / Apple Pay into my app, I kept getting numerous errors when I attempted to implement STPTestPaymentAuthorizationController
. I found the exact problem described here (Stripe payment library and undefined symbols for x86_64).
当我最初将Stripe / Apple Pay设置到我的应用程序中时,当我尝试实现STPTestPaymentAuthorizationController时,我不断收到大量错误。我发现了这里描述的确切问题(条带支付库和x86_64的未定义符号)。
I replicated the solution defined above by commenting out part of Stripe's code, which maybe (?) produced the Error Domain=com.stripe.lib Code=50
error.
我通过注释掉Stripe代码的一部分来复制上面定义的解决方案,这可能会(?)产生Error Domain = com.stripe.lib Code = 50错误。
I fixed this by not using STPTestPaymentAuthorizationController
at all, just replacing that with PKPaymentAuthorizationViewController
in #DEBUG
mode.
我通过不使用STPTestPaymentAuthorizationController来解决这个问题,只是在#DEBUG模式下用PKPaymentAuthorizationViewController替换它。
tl:dr Not completely sure why STPTestPaymentAuthorization didn't work; avoided situation completely by running PKPaymentAuthorizationViewController with my iPhone and Stripe dashboard in test mode.
tl:dr不完全确定为什么STPTestPaymentAuthorization不起作用;通过在测试模式下使用我的iPhone和Stripe仪表板运行PKPaymentAuthorizationViewController完全避免了这种情况。
#1
5
This little bit of RnD helped me. Digging into the CustomSampleProject provided by Stripe themselves, ApplePayStubs works pretty well when the STPCard is recognized when the delegate
这一点RnD对我有所帮助。深入研究Stripe自己提供的CustomSampleProject,当代表识别出STPCard时,ApplePayStubs运行良好
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
didAuthorizePayment:(PKPayment *)payment
completion:(void (^)(PKPaymentAuthorizationStatus))completion
of PKPaymentAuthorizationViewControllerDelegate is called. The sample code here checked if the code was run in debug that is for ApplePayStubs, the (PKPayment *)payment in the delegate is converted to a STPCard and is launched to the STPAPIClient for STPToken generation. Following is the body of the above mentioned delegate:
调用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
This worked for me. With ApplePayStubs (on Simulator) and without them (on Device) Hope this Helps :)
这对我有用。使用ApplePayStubs(在模拟器上)并且没有它们(在设备上)希望这有助于:)
#2
3
I think I know what happened here. Leaving this up in case it helps anybody.
我想我知道这里发生了什么。离开这个以防万一它可以帮助任何人。
When I initially set up Stripe / Apple Pay into my app, I kept getting numerous errors when I attempted to implement STPTestPaymentAuthorizationController
. I found the exact problem described here (Stripe payment library and undefined symbols for x86_64).
当我最初将Stripe / Apple Pay设置到我的应用程序中时,当我尝试实现STPTestPaymentAuthorizationController时,我不断收到大量错误。我发现了这里描述的确切问题(条带支付库和x86_64的未定义符号)。
I replicated the solution defined above by commenting out part of Stripe's code, which maybe (?) produced the Error Domain=com.stripe.lib Code=50
error.
我通过注释掉Stripe代码的一部分来复制上面定义的解决方案,这可能会(?)产生Error Domain = com.stripe.lib Code = 50错误。
I fixed this by not using STPTestPaymentAuthorizationController
at all, just replacing that with PKPaymentAuthorizationViewController
in #DEBUG
mode.
我通过不使用STPTestPaymentAuthorizationController来解决这个问题,只是在#DEBUG模式下用PKPaymentAuthorizationViewController替换它。
tl:dr Not completely sure why STPTestPaymentAuthorization didn't work; avoided situation completely by running PKPaymentAuthorizationViewController with my iPhone and Stripe dashboard in test mode.
tl:dr不完全确定为什么STPTestPaymentAuthorization不起作用;通过在测试模式下使用我的iPhone和Stripe仪表板运行PKPaymentAuthorizationViewController完全避免了这种情况。