Apple Pay / Stripe Integration Issue

I followed the Stripe documentation and sample application for Apple Pay integration.

In the handlePaymentAuthorizationWithPayment method, in createTokenWithPayment, I get an error message:

Domain error = com.stripe.lib Code = 50 "Payment information is not formatted correctly. Make sure you are using the latest version of our iOS library correctly. For more details see https://stripe.com/docs/mobile/ios ." UserInfo = 0x170261b40 {com.stripe.lib: ErrorMessageKey = Your billing information was formatted incorrectly. Make sure you are using the latest version of our iOS library correctly. For more information, see https://stripe.com/docs/mobile/ios ., NSLocalizedDescription = Payment information is not formatted properly. Make sure you are using the latest version of our iOS library correctly. See https://stripe.com/docs/mobile/ios for more information.}

Does anyone know how to solve this? I use the latest Stripe library.

Thanks.

+6
source share
2 answers

I think I know what happened here. Leaving this in case this helps someone.

When I initially set up Stripe / Apple Pay in my application, I continued to receive numerous errors while trying to implement STPTestPaymentAuthorizationController . I found the specific problem described here ( Strip payment library and undefined characters for x86_64 ).

I reproduced the solution defined above by commenting on the part of the Stripe code that possibly (?) Caused the Error Domain=com.stripe.lib Code=50 error.

I fixed this without using STPTestPaymentAuthorizationController at all, just replacing it with PKPaymentAuthorizationViewController in #DEBUG .

tl: dr Not quite sure why STPTestPaymentAuthorization does not work; completely avoiding the situation by running PKPaymentAuthorizationViewController with my iPhone and Stripe panel in test mode.

+3
source

This little RnD helped me. Digging into the CustomSampleProject provided by Stripe itself, ApplePayStubs works very well when the STPCard is recognized when the delegate

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

from PKPaymentAuthorizationViewControllerDelegate . The sample code here checked if the code was run during debugging, which is intended for ApplePayStubs, the payment (PKPayment *) in the delegate is converted to STPCard and run on STPAPIClient for the STPToken generation. The following is the body of the above delegate:

 #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 

It worked for me. With and without ApplePayStubs (on the Simulator) (on the device) I hope this helps :)

+5
source

Source: https://habr.com/ru/post/978971/


All Articles