flutter_stripe_payment icon indicating copy to clipboard operation
flutter_stripe_payment copied to clipboard

NullPointerException: When creating payment method

Open raffger-sese opened this issue 4 years ago • 2 comments

I am currently trying to create a payment method by supplying credit card.

var paymentMethod = await StripePayment.createPaymentMethod(PaymentMethodRequest(card: creditCard));

But I am getting this error (in Android only, works well in IOS)

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.stripe.android.Stripe.createPaymentMethod(com.stripe.android.model.PaymentMethodCreateParams, com.stripe.android.ApiResultCallback)' on a null object reference

I read the API for android sdk and saw that createPaymentMethod() method is expecting @NotNull ApiResultCallback.. How do I pass that if the PaymentMethodRequest only accepts the following?

final BillingAddress billingAddress; final CreditCard card; final Token token; final Map<String, String> metadata;

raffger-sese avatar Jul 10 '20 10:07 raffger-sese

same here

devapalanisamy avatar Dec 09 '20 00:12 devapalanisamy

did you init your StripePayment in the initState() on the page that has the error? image

KennyChan94P avatar Jun 16 '21 07:06 KennyChan94P