![](/img/trans.png)
[英]Apple pay integration with Stripe (STPTestPaymentAuthorizationViewController in debug)
[英]Issue with Apple Pay / Stripe integration
我已經按照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庫。
謝謝。
這一點RnD幫助了我。 深入挖掘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(在模擬器上)和沒有它們(在設備上)希望這有助於:)
我想我知道這里發生了什么。 離開這個以防萬一它可以幫助任何人。
當我最初將Stripe / Apple Pay設置到我的應用程序中時,當我嘗試實現STPTestPaymentAuthorizationController
時,我不斷收到大量錯誤。 我發現了這里描述的確切問題( 條帶支付庫和x86_64的未定義符號 )。
我通過注釋掉Stripe代碼的一部分來復制上面定義的解決方案,這可能會(?)產生Error Domain=com.stripe.lib Code=50
錯誤。
我通過不使用STPTestPaymentAuthorizationController
解決這個問題,只是在#DEBUG
模式下用PKPaymentAuthorizationViewController
替換它。
tl:dr不完全確定為什么STPTestPaymentAuthorization不起作用; 通過在測試模式下使用我的iPhone和Stripe儀表板運行PKPaymentAuthorizationViewController完全避免了這種情況。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.