popekabu / pay_with_paystack

MIT License
9 stars 21 forks source link

Duplicate Transaction Reference #16

Closed Alade5673 closed 2 months ago

Alade5673 commented 8 months ago

I keep getting this error of duplicate transaction reference anytime I want to put in my card details. Immediately my keyboard shows up to start typing, it redirects and shows this error

below is my code

`PayWithPayStack().now(
        context: context,
        secretKey: '$secretKey',
        customerEmail: "$email",
        reference: DateTime.now().microsecondsSinceEpoch.toString(),
        callbackUrl: "/",
        currency: "NGN",
        paymentChannel:["card", "bank", "ussd", "qr", "mobile_money", "bank_transfer", "eft"],
        amount: couponValid == false ? "${int.parse(widget.item['amount']) * 100}" : "${(final_amount * 100).toString()}",
        transactionCompleted: () {
          print("Transaction Successful");

          setState(() {
            payment_ref = DateTime.now().microsecondsSinceEpoch.toString();
          });

          loader().showLoaderDialog(context);
          subscribe();

        },
        transactionNotCompleted: () {
          print("Transaction Not Successful!");
        });`
Screenshot 2023-12-14 at 7 15 40 PM
Alade5673 commented 8 months ago

@popekabu

popekabu commented 8 months ago

The reference you’re passing from your front end isn’t changing. Alternatively use a random string generator and see if it solves your issue

On Thu, 14 Dec 2023 at 8:26 PM, devlade @.***> wrote:

@popekabu https://github.com/popekabu

— Reply to this email directly, view it on GitHub https://github.com/popekabu/pay_with_paystack/issues/16#issuecomment-1856532835, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMACNJBLAJWYMCQ6K2GVELYJNOHFAVCNFSM6AAAAABAVIWTTSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJWGUZTEOBTGU . You are receiving this because you were mentioned.Message ID: @.***>

Alade5673 commented 8 months ago

@popekabu

It didn't work

even after using uuid

reference: "${DateTime.now().microsecondsSinceEpoch}_${Uuid().v4()}"

popekabu commented 8 months ago

That’s a strange behavior of the date time class. It’s beyond my control.

On Fri, 15 Dec 2023 at 7:00 AM, devlade @.***> wrote:

It didn't

I had to use uuid

reference: "${DateTime.now().microsecondsSinceEpoch}_${Uuid().v4()}"

— Reply to this email directly, view it on GitHub https://github.com/popekabu/pay_with_paystack/issues/16#issuecomment-1857374376, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMACNKW37JGPVHJQVSKBQDYJPYPPAVCNFSM6AAAAABAVIWTTSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJXGM3TIMZXGY . You are receiving this because you were mentioned.Message ID: @.***>

popekabu commented 8 months ago

@Alade5673 how about you try a static string and see if it works then change the static string again to see if it works. I dont really know where the issue is emanating from but I suspect the dateTime class is returning the same String and since that same string is a reference id already used in your paystack. Paystack denies it. I hope its not a windows issue.

Also you can try restarting your app or pc or debug the datetime string and see if the string is the same or changes from time to time.

I just tested it on mine, see video below. Keep me posted.

All the best!!

https://github.com/popekabu/pay_with_paystack/assets/26738997/23ea1195-bcd4-4681-853c-a11be929aa2d

Alade5673 commented 8 months ago

@popekabu it only happens when you want to pay with card option. Once you want to put in your card details it throws that error

Alade5673 commented 8 months ago

https://github.com/popekabu/pay_with_paystack/assets/39368095/16b81a69-1ba4-44bc-8462-151b5e140077

Alade5673 commented 8 months ago

@popekabu please can you take a look at the last video I sent?

Alade5673 commented 8 months ago

@popekabu

popekabu commented 8 months ago

Will do if I have the time. Thanks

On Sat, 16 Dec 2023 at 9:08 PM, devlade @.***> wrote:

@popekabu https://github.com/popekabu

— Reply to this email directly, view it on GitHub https://github.com/popekabu/pay_with_paystack/issues/16#issuecomment-1858930610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMACNODS7DHCFO7A64DK6DYJYETBAVCNFSM6AAAAABAVIWTTSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJYHEZTANRRGA . You are receiving this because you were mentioned.Message ID: @.***>

popekabu commented 8 months ago

@Alade5673 I had a look at your video the day you posted it, Im not sure where the issue is from. Might be a paystack issue

Alade5673 commented 8 months ago

alright no problem

thanks

popekabu commented 8 months ago

To be safe. Be sure you're using uuidv4 as your reference and not dateTime. Initialize it in the parameter directly. Please keep me posted on what happens from there.

Thanks

popekabu commented 2 months ago

try using uuid as a unique id generator. Get it from pub.dev