Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Shopify creating Usage Charge having price more then the capped amount value

Shopify creating Usage Charge having price more then the capped amount value

user072319
Shopify Partner
131 0 17

I have created a recurring charge with capped amount of $49.99. I checked the Recurring Charge API and its showing capped amount correclty ($49.44) in the result.

 

However, when I try to create a usage charge above $49.99 say, $486.72, the usage charge is getting created without giving any error regarding the capped amount exceeded and when I pull up the Usage Charge API result I can see the balance remaining as some negative number.

 

array (
'usage_charge' =>
array (
'id' => xxxxx,
'description' => 'xxxxxxx',
'price' => '486.72',
'created_at' => '2021-11-26T04:34:51-06:00',
'billing_on' => '2021-11-26',
'balance_used' => 491.71,
'balance_remaining' => -441.71999999999997,
'risk_level' => 0.0,
),
)

 

Why its creating the usage charge above the capped amount? How can I restrict to create usage charge upto capped amount only?

Reply 1 (1)

LetterT
Shopify Partner
53 5 19

I check the balance_remaining before trying to create the usage charge. Perhaps that's why I haven't encountered that error. I don't think it is safe to rely on the Shopify API to catch that situation (which I think it should check and return error) I have an uneasy feeling about possible bugs (edge cases?) in RecurringApplicationCharge & UsageCharge so I strongly suggest checking what you reasonably can, and logging responses in case of disputes.

 

I've also had another case of balance_used, balance_remaining not updating properly which is even more difficult to catch.

Don't be shy, click that like button!