Forum Academy Marketplace Showcase Pricing Features

Unique ID is triggering Luhn check algorithm for credit cards

I need to pass a unique value for an “order id” with a payments API. I’ve been just passing the Bubble unique ID for an order, but unfortunately that has sometimes triggered a Luhn check which is designed to prevent passing anything that looks like a credit card number. An appropriate precaution on the processor’s side but annoying for me because they will then mask part of the provided order ID, thus making my records not match their records.

Can any of you provide advice for how to quickly generate a unique value that won’t trigger a Luhn check algorithm that looks for credit card numbers? I’m thinking about trying either a UNIX timestamp or just the current date/time formatted down to the current second or something.

Any reason you can’t prefix the Order ID with a string, to bypass the Luhn check? (ex: ORD-123456). If you can’t use Order ID as a string, then timestamp sounds like a good idea.

An excellent suggestion if my app created an order first and then sought payment for it.

I guess I worded my first post incorrectly - my app doesn’t create an “order” itself until the grand total is either paid in full or a “pay later” type of button is pressed. This way a new transaction could be abandoned in the middle without repercussions. The downside is that I don’t know the order number ahead of time so I’m left searching for some other kind of unique identifier that could be “throwaway” if needed. I do create a “split tender” object each time an attempt is made at a payment transaction; if successful then it’s kept, if unsuccessful then it’s tossed.

The API requires the order ID to be alphanumeric so I can’t use dashes or colons. Last night I settled on some silly-looking thing that I’m certain won’t trigger the Luhn check because it’s got letters interspersed all throughout. It looks like this: 21y07m06d07H37M07s. It only has to be unique per user so this is – I think – unique enough.

Got it. That’s a good workaround too. Good luck with your project.