Skip to content

Please help. Do not working PayViaExistingCard() #9

Open
@Hopheylalal

Description

@Hopheylalal

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);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions