stripe / stripe-ios

Stripe iOS SDK
https://stripe.com
MIT License
2.12k stars 979 forks source link

[BUG] STPPaymentMethodParams CRASH IOS #2113

Closed calaforrai closed 1 year ago

calaforrai commented 1 year ago

Hello, I want to set STPPaymentMethodParams to cardtextfield, I want to fill the cardtextfield automaticaly if the user have made a payment, I don't want the user need to re-enter the card information, but have the field already filled in. so i tried doing this with STPcardParams and setting it to cardtextfield but it seems deprecated

STPCardParams *mycardParams = [STPCardParams new];
        mycardParams.name = @"Jenny Rosen";
        mycardParams.number = @"4242424242424242";
        mycardParams.expMonth = 12;
        mycardParams.expYear = 18;
        mycardParams.cvc = @"123";
mycardTextField.cardParams = mycardParams; 

that cause a crash

so I change this by with STPPaymentMethodParams

STPPaymentMethodParams *mycardParams = [[STPPaymentMethodParams alloc]init];
        mycardParams.card.name = @"Jenny Rosen";
        mycardParams.card.number = @"4242424242424242";
        mycardParams.card.expMonth = 12;
        mycardParams.card.expYear = 18;
        mycardParams.card.cvc = @"123";
mycardTextField.paymentMethodParams = mycardParams; 

but that crash too with this error message

Fatal error: STPPaymentCardTextField only supports Card STPPaymentMethodParams: file StripePaymentsUI/STPPaymentCardTextField.swift, line 445

can someone help me please Thank

yuki-stripe commented 1 year ago

Hello @calaforrai,

I believe in your code example, mycardParams.card is nil. You'll need to set mycardParams.card = [[STPPaymentMethodCardParams alloc] init] before setting name, number, etc.