ios - Apple pay integration with Stripe (STPTestPaymentAuthorizationViewController in debug) -
i trying integrate apple pay stripe in ios app. using applepaystub provide stripe check apple pay in debug mode
i using latest stripe , applepaystub code git
trying run on iphone 6 simulator , code using is:
paymentcontroller = [[stptestpaymentauthorizationviewcontroller alloc] initwithpaymentrequest:request]; ((stptestpaymentauthorizationviewcontroller*) paymentcontroller).delegate = self;
getting error:
error domain=com.stripe.lib code=50 "your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios ." userinfo=0xxxxxxxxxxx {com.stripe.lib:errormessagekey=your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios ., nslocalizeddescription=your payment information formatted improperly. please make sure you're correctly using latest version of our ios library. more information see https://stripe.com/docs/mobile/ios .},
any appreciated.
@wizyashas, setup of stptestpaymentauthorizationviewcontroller fine. problem happens when try generate token via stpapiclient. there's gets messy.
this little bit of rnd helped me. digging customsampleproject provided stripe themselves, applepaystubs works pretty when stpcard recognized when delegate
- (void)paymentauthorizationviewcontroller:(pkpaymentauthorizationviewcontroller *)controller didauthorizepayment:(pkpayment *)payment completion:(void (^)(pkpaymentauthorizationstatus))completion
of pkpaymentauthorizationviewcontrollerdelegate called. sample code here checked if code run in debug applepaystubs, (pkpayment *)payment in delegate converted stpcard , launched stpapiclient stptoken generation. following body of above mentioned delegate:
#if debug // handle test result 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 me. applepaystubs (on simulator) , without them (on device).
hope helps :)
Comments
Post a Comment