Re: [BUG] Automatic product discount codes prevent subscription from billing

[BUG] Automatic product discount codes prevent subscription from billing

Brian_S
Shopify Partner
170 21 43

There's an easily reproducible bug right now with automatic product discount codes and subscription billings. If you create an automatic discount code thats an Amount off Product that applies to all recurring payments, the original checkout works just fine but any renewal (ie billing attempt) of the resulting subscription contract will fail with the generic error code `UNEXPECTED_ERROR`.

 

Below are steps to reproduce, an example discount code screenshot and Id and an example subscription contract gId and billing attempt gId:

 

Steps to reproduce: 

  1. create an automatic discount that is applicable to a specific product
  2. Set the discount value to a percentage, make it compatible with subscriptions, and applicable to all recurring orders
  3. Attempt to purchase a subscription to the product you picked in step 1
  4. Notice that it automatically gets discounted on cart/checkout
  5. Create a billing attempt for the resulting subscription contract
  6. Notice that the billing attempt failed with a generic error code `UNEXPECTED_ERROR`
  7. Remove the discount code from the subscription contract and try creating a billing attempt again
  8. Notice that it works

 

Example discount code screenshot:

Brian_S_0-1704749990659.png

 

Example Discount Id:  1369508380974

 

Example Subscription Contract gId with discount ^ above: gid://shopify/SubscriptionContract/12478939438

 

Example failed Billing Attempt gId from contract ^ above: gid://shopify/SubscriptionBillingAttempt/36484415790

 

This is causing merchants' subscription contracts to fail to bill without even attempting to bill the payment methods. 

 

 

Any help would be greatly appreciated! Thank you : )

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
Replies 14 (14)

JoshArnold
Shopify Staff
30 7 6

Hi @Brian_S! I found some logs for this specific failure and what I'm seeing is:

 

 {:"discount_applications.price_rule_id"=>["can't be blank"]}

 

I dug into your discounts/contracts data and eventually found the discounts for that subscription, which appears like it may have been somehow duplicated? I see the same UUID, one has a price_rule_id, the other is blank.

I'll forward my findings onto the team to see what we can figure out!

 

EDIT: Spoke with the team and we tried to reproduce this issue, but nothing wrong happened on rebilling. And when I checked the database, we only show 1 entry for our automatic discount. I'm wondering if this is possibly a bug in your subscriptions app you are using, where it is accidentally generating duplicate subscriptions_discounts?

Josh (aka Master Chief) | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Brian_S
Shopify Partner
170 21 43

Thanks for the response @JoshArnold !  

 

The reason you see that duplicate discount is because we had to create a method to correct our merchant's issue so we found that by removing the original discount and adding a completely identical manual discount that we solved the issue. We tested on the subscription contracts for this store so it would make sense for you to see the duplicate manual discounts.  However, this is a very difficult thing to do proactively and seems like it shouldn't have to be done.  It is odd that you have identical UUIDs for a manual discount that was added by shopify and one that was added by me via API but I don't know enough about your BE system.

 

It's easy for me to reproduce this (see steps above) so I've created another subscription contract that's in the state I describe that you should be able to check and only see a single discount for:

 

Example Discount Id: 1369508380974 (same one)

 

Example Subscription Contract gId with discount ^ above: gid://shopify/SubscriptionContract/12493193518

 

Example failed Billing Attempt gId from contract ^ above: gid://shopify/SubscriptionBillingAttempt/36580131118

 

 

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
Brian_S
Shopify Partner
170 21 43

I'm reviewing your screenshot again. It seems odd that an automatic discount code was able to get added twice, isnt it?  Automatic discount codes aren't like normal discount codes as far as I'm aware. They can't be added via any API (only by Shopify at checkout).  Seems like something strange is going on. 

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
JoshArnold
Shopify Staff
30 7 6

Agreed. It may have been a one-off scenario with a weird checkout/order issue. If you create a brand new automatic discount does it have the same issues as this one? We have created an issue on our end to see if we can find any other instances of duplication and see if this is a recent trend or just a one-off issue.

Josh (aka Master Chief) | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Brian_S
Shopify Partner
170 21 43

Thanks @JoshArnold! It doesn't seem one-off because it's 100% replicable across shops/discounts/customers/subscriptions/etc.  Let me know if there's anything else we can do to support you and the team. 

 

If you create a brand new automatic discount does it have the same issues as this one?

yes - my team and I are easily able to replicate it on any shop following those ^ steps. Let me know if you'd like more examples

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
JoshArnold
Shopify Staff
30 7 6

We are still unable to reproduce this on multiple test shops. Please do send over examples from other stores if you have them!

Josh (aka Master Chief) | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Brian_S
Shopify Partner
170 21 43

No problem! These values are from a new shop: 

  • Example Discount Id: 1290706682085
  • Example Subscription Contract gId with discount ^ above: gid://shopify/SubscriptionContract/7983104229
  • Example failed Billing Attempt gId from contract ^ above: gid://shopify/SubscriptionBillingAttempt/13758300389

Brian_S_0-1705093875966.png

 

 

and here are some from another: 

  • Example Discount Id: 1152640417852
  • Example Subscription Contract gId with discount ^ above: gid://shopify/SubscriptionContract/26999816252
  • Example failed Billing Attempt gId from contract ^ above: gid://shopify/SubscriptionBillingAttempt/51439632444

Brian_S_1-1705094155190.png

 

 

 

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
Brian_S
Shopify Partner
170 21 43

Any more followup @JoshArnold ? We're having more and more subs that we're not able to bill through Shopify's APIs because of this. 

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
Brian_S
Shopify Partner
170 21 43

I just found the thing that seems to break the automatic discount, though it doesn't make much sense why it'd break it.  

 

This should help you replicate it though @JoshArnold 

 

Updated teps to reproduce:

  1. create an automatic discount that is applicable to a specific product
  2. Set the discount value to a percentage, make it compatible with subscriptions, and applicable to all recurring orders
  3. Attempt to purchase a subscription to the product you picked in step 1
  4. Notice that it automatically gets discounted on cart/checkout
  5. Create a billing attempt for the resulting subscription contract
  6. Billing Attempt Success and Order is Created
  7. [NEW STEP] Remove the sellingPlanName OR remove the sellingPlanId from the line the discount has been applied to
  8. Create another billing attempt for the subscription contract
  9. Notice that the billing attempt failed with a generic error code `UNEXPECTED_ERROR`

 

The same thing happens even if you just change the sellingPlanName on the line with the discount (it doesn't have to be removed)

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
Brian_S
Shopify Partner
170 21 43

Oh wow.. its even worse than that.  All I have to do is make ANY change to the line with the discount.  If I update the quantity it breaks it too. 

 

I've confirmed this in multiple apps now

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic
JoshArnold
Shopify Staff
30 7 6

Hi Brian, thank you for the update! I've shared the new details with the team and bumped up the issue severity. Can you give me a sense of the volume of subscriptions impacted by this? Are they all using a specific Subscriptions app?

Also, can you clarify why this new step is being done? Apologies if the answer should be obvious to me 😅
"[NEW STEP] Remove the sellingPlanName OR remove the sellingPlanId from the line the discount has been applied to"

EDIT: I see you found out it is related to any change to the line with the discount and is impacting multiple apps. That is very helpful new information, thank you!

Josh (aka Master Chief) | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Alex409
Shopify Partner
2 0 1

Hey @JoshArnold ,

We have been facing the same issue across a few of our stores where hundreds of subscriptions have the same billing failures with automatic discounts. Here is the ticket id for reference: 46118288

Please do let us know when we can expect a resolution on this.

Thanks.

JoshArnold
Shopify Staff
30 7 6

Hi @Alex409,

I've bumped this back up to the team and they are going to reprioritize this. I can't give a specific timeframe on the resolution, but it will be worked on again this week.

So sorry for the long delay on this solution!

Josh (aka Master Chief) | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Brian_S
Shopify Partner
170 21 43

Seems like maybe this got fixed. You know if it got worked on @JoshArnold?

Brian Singer
CTO & Cofounder of Subscription Service - Awtomic