Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.6 kB
10
Indexable
Never
Future<void> thawaniPayment() async {
    appStore.isLoading = true;
    Thawani.pay(
      context,
      getSavedCustomer: (id) {
        print(id);
      },
      onCreateCustomer: (data) {},
      metadata: {"customer name": "My name", "phone number": "0369369369", "email address": "hello@gmail.com"},
      testMode: false,
      api: '46ubTDB9LIKGnj5r6qVsWHunzs05RT',
      pKey: '9rYI9EhUCbv6P0qQe3HHLsqoOo6U2A',
      clintID: getIntAsync(USER_ID).toString(),
      onError: (e) {
        print(e);
        appStore.isLoading = false;
      },
      products: [
        {"name": "Wallet", "unit_amount": (widget.totalAmount * 1000).toInt(), "quantity": 1.toString()}
      ],
      onCreate: (v) {
        print("===================oncreate order${v.toString()}");
      },
      onCancelled: (v) {
        toast('Payment Cancel');
        appStore.isLoading = false;
      },
      savedCards: (d) {},
      onPaid: (v) {
        print(v);
        log('Payment done ${v.data.toString()}  ');
        log('Payment done ${v.code.toString()} ');
        log('Payment done ${v.description}  ');
        log('Payment done ${v.success}  ');
        if (v.success == true) {
          if (widget.isWallet == true) {
            paymentConfirm();
          } else {
            savePaymentApiCall(paymentType: PAYMENT_TYPE_THAWANI, paymentStatus: PAYMENT_PAID);
          }
        } else {
          toast("Payment Failed");
          appStore.isLoading = false;
        }
      },
      saveCard: false,
    );
    await Future.delayed(Duration(seconds: 3));
    appStore.isLoading = false;
  }
Leave a Comment