Flow to flag multiple failed payment attempts on single order

Flow to flag multiple failed payment attempts on single order

rossiedees
Tourist
4 0 3

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!

Replies 11 (11)

Kalen_Jordan
Shopify Partner
803 39 147

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

rossiedees
Tourist
4 0 3

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.

paul_n
Shopify Staff
1818 199 432

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
Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
rossiedees
Tourist
4 0 3

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? 

paul_n
Shopify Staff
1818 199 432

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")

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
innerbloom_team
Tourist
11 0 0

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!

rossiedee
Tourist
3 0 2

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.

innerbloom_team
Tourist
11 0 0

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 >

Screenshot 2025-05-05 at 5.30.03 PM.png

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!

 

rossiedee
Tourist
3 0 2

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.

innerbloom_team
Tourist
11 0 0

Hello Rossiedee,

 

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

rossiedee
Tourist
3 0 2

No problem!  Happy to help!