How to connect paystack payment gateway to my flutter e-commmerce app

215 Views Asked by At

I integrated Paystack payment gateway to my Flutter-Woocommerce app. Everyhting works fine as in the integration and all. I'm however having a little challenge in the e-commerce app I'm building while trying to pass the total amount of the cart to Paystack "amount". Whenever I do so, the Paystack popup payment window does not open. Please what could be wrong? Here is my code

chargeCard(BuildContext context) async {
    var cartItems = Provider.of<CartProvider>(context, listen: false);
      cartItems.fetchCartItems();
    var charge = Charge()
      ..amount =  (cartItems.totalAmount * 100) as int
      ..reference = _getReference()
      ..putCustomField('custom_id',
          '846gey6w') //to pass extra parameters to be retrieved on the response from Paystack
      ..email = '[email protected]';

    CheckoutResponse response = await plugin.checkout(
      context,
      method: CheckoutMethod.card,
      charge: charge,
    );

Please I need help. Thank you.

0

There are 0 best solutions below