Flow to flag multiple failed payment attempts on single order

Hi! I have created a flow that emails me when there is a failed payment attempt on an order… it works fine, but what I’m looking for is multiple declines on the same order.

For example, a person may innocently input the wrong zip code or CVV and get a decline error once or even twice, but then enter the info correctly and successfully place their order. I’m not really worried about those scenarios. I want to be notified if there are more than THREE payment attempts (“declined” error code or “failed” transaction status).

As mentioned, I have a flow in place to let me know of one failed payment attempt. Does anyone know if Shopify Flow is able to “count” the number of payment attempts on a given order and only trigger the action if the condition has happened a certain number of times?

Thanks for any ideas!

1 Like

What trigger are you using currently for the single failed payment flow?

Hi Kalen! I have tried it two ways:

  1. With “order created” as the trigger and “transactions_item.status” equal to FAILURE.
  2. With “order transaction created” as the trigger and “orderTransaction.errorCode” equal to CARD_DECLINED

Both of these successfully trigger an internal email, but I’m not sure how to tell Flow to only trigger if it happens three times on the same order.

1 Like

I’m not too familiar with how the transaction events come through. Are you seeing the workflow trigger 3 times using Order transaction created?

If so, you could store them in a metafield or tag each time they happen. And then check the metafield before sending that internal email.

You might also be able to use something like:

  • Every day
  • Get orders (using the financial_status field for the query)
  • For each order:
    • Check if it has 3 tries
    • If true
      • Send email
1 Like

Yes, I do get multiple email notifications for repeat events on the same order for the card decline, but the transaction status failure flow only triggers once.

I’ll try the flow you suggested, but not sure on some of the steps. Here’s what I have:

  1. Scheduled to run every day
  2. Then: Get order data
  3. Then Check if:
    1. At least one of get order data, at least one of transactions, “transactions_item.status” is equal to FAILURE
    2. -or- if “transactions_item.errorCode” exists
  4. Then Count items in getOrderData
  5. Then Check if: Count is greater than 3
  6. Then send internal email

Is this right? Seems a little convoluted?

1 Like

Yeah, I think if the trigger works then it will be the easiest for you.

If you go with “Get data” then I would use Run code instead of the condition and count above. It gives you a lot more flexibility and you won’t have to write logic twice. Usually, I prefer to return the full string for the email body plus a boolean to use in a condition (something like “hasThirdDecline”)

hello,

checking in to see if this worked? I have many people who try and scam us by charging mulitple stolen cards. Sometimes up to 12 different cards that fail.

if it has worked, can you write the steps in detail? sorry, im new to this!

thank you!

Yes! The below flow has been working great for me!

  1. Trigger “When order created”
  2. THEN if
    1. At least one of order / transactions STATUS (transactions_item.status) is equal to FAILURE - OR -
    2. At least one of order / transactions STATUS (transactions_item.status) is equal to ERROR
  3. THEN “Count” transactions (order.transactions)
  4. THEN Check if “Count” is greater than or equal to 5 (or whatever threshold you want to set)
  5. THEN… whatever you want it to do, cancel the order, add an order tag, send internal email, etc.

The count function will obviously count successful charges, too, so find a number that makes sense for you. To me, if someone’s credit card gets declined 4 times, that’s enough to justify a fraud flag. (4 declines + 1 successful authorization = 5 transactions) I have my flow set up to add an order tag, add an order note for the warehouse, and email me). I take a look at the activity, and if it’s the same card declined 4 times, that’s obviously someone who has fat fingers or doesn’t know their billing address and I usually let those process. But if it’s 4 declines with 4 different cards, I manually cancel the order.

1 Like

Hello,

I did the following based on what you said, but wanted to confirm I’m choosing the correct actions.

  1. Order Created > THEN

  2. IF “transactions_item.status” equal “failure” OR “transactions_item.status” equal “error” > THEN

  3. ACTION > COUNT “order.transactions” > THEN

  4. IF Count equal to 4 > THEN

  5. ACTION >

whatever I want

I set 4 to allow customers 3 tries of failure and they need to get it on the 4th try or they are out.

Thanks for popping back into the thread with your help!

Looks good! I would just suggest “greater than or equal to” as the count qualifier, because the way you have it written, the number of transactions on the order has to be exactly 4 to auto-cancel the order… and if you have one of your 12-attempt scam orders come through, it won’t trigger the last action.

1 Like

Hello Rossiedee,

Thanks for that catch. I misread your initial msg, but have made the changes. Thank you for all your help!

No problem! Happy to help!