Description
I get null in paymentIntent.
I/flutter (23072): NoSuchMethodError: The method '[]' was called on null.
I/flutter (23072): Receiver: null
I/flutter (23072): Tried calling: [] ("client_secret")
static Future payViaExistingCard({
String amount,
String currency,
String offerId,
CreditCard card,
}) async {
try {
var paymentMethod = await StripePayment.createPaymentMethod(
PaymentMethodRequest(
card: CreditCard(
number: '5555555555554444',
cvc: '123',
expMonth: 03,
expYear: 22,
currency: 'USD',
),
),
);
var paymentIntent =
await StripeService.createPaymentIntent(amount, currency, offerId).catchError((e){
print('EERROORR$e');
});
print('paymentIntent:$paymentIntent');
static Future<Map<String, dynamic>> createPaymentIntent(
String amount, String currency, String offerId) async {
try {
Map<String, dynamic> body = {
'amount': amount,
'currency': currency,
'payment_method_types[]': 'card',
'description': offerId,
};
var response = await http.post(
StripeService.paymentApiUrl,
body: body,
headers: StripeService.headers,
);
return jsonDecode(response.body);
} catch (e) {
Get.snackbar('Error', 'Transaction failed',
backgroundColor: Colors.red, colorText: Colors.white);
}
}