skip to Main Content

I’m using a dependency to impliment a payment system in my flutter app using Paystack Payment system. This is the dependency pay_with_paystak

In the dependency it’s expeting me to give a callbackUrl. What is this callbackUrl and how do I create one for both Android and iOS?

PayWithPayStack().now(
    secretKey:
    "sk_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXX",
    customerEmail: "[email protected]",
    reference:
    DateTime.now().microsecondsSinceEpoch.toString(),
    callbackUrl: "setup in your paystack dashboard"//How do I do this?
    currency: "GHS",
    paymentChannel:["mobile_money", "card"],
    amount: "20000",
    transactionCompleted: () {
        print("Transaction Successful");
    },
    transactionNotCompleted: () {
        print("Transaction Not Successful!");
    });

2

Answers


  1. The documentation explains it:

    callbackUrl URL to redirect to after payment is successful, this helps close the session. This is setup in the Dashboard of paystack and the same URL setup is then provided here by you again.

    Having said that, their example doesn’t have one so it’s probably optional. I don’t have access to a dashboard to verify this.

    PayWithPayStack().now(
        context: context,
        secretKey:
        "sk_live_XXXXXXXXXXXXXXXXXXX",
        customerEmail: "[email protected]",
        reference: DateTime.now().microsecondsSinceEpoch.toString(),
        currency: "GHS",
        amount: "20000",
        transactionCompleted: () {
            print("Transaction Successful");
        },
        transactionNotCompleted: () {
            print("Transaction Not Successful!");
        });
    
    Login or Signup to reply.
  2. Pay_with_paystack uses WebView internally.

    So CallbackURL denotes, After the successful transaction where you want to redirect. This helps PayStack to close the session. If you want to have this sort of functionality in Flutter you might have to set up a URL that redirects to your Flutter Screen, which I won’t recommend.

    2 Good Ways to Solve this Issue

    1. Displaying Checkout in Your WebView – Here they used Webview to work with PayStack
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        body: WebView(
          initialUrl: 'https://checkout.paystack.com/7zu1ot06d0qn9h6',
          javascriptMode: JavascriptMode.unrestricted,
          userAgent: 'Flutter;Webview',
        ),
      );
    }
    
    
    1. Use Flutter_PayStack instead.
      People are using it day in and day out and it works nicely.
    • To achieve redirect after the successful transaction you may use pushAndRemoveUntil.
    // Just for reference
     CheckoutResponse response = await plugin.checkout(
          context,
          method: CheckoutMethod.card,
          charge: charge,
        );
    
        if (response.status == true) {
          message = 'Payment was successful. Ref: ${response.reference}';
          if (mounted) {}
          Navigator.pushAndRemoveUntil(
              context,
              MaterialPageRoute(
                  builder: (context) => SuccessScreen(message: message)),
              ModalRoute.withName('/'));
        } else {
          print(response.message);
        }
    

    Thanks

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search