2
votes

I'm trying to not allow users access to my app if they decline the payment charge. How do I check what 'state' shop is in after a charge has been accepted or declined?

This from Shopify api doc

After the charge has been accepted or declined, Shopify redirects the shop owner to the return_url set in the request. At this point the shop is either in an accepted or declined state. In order to actually receive payment for this charge it must be activated by your application.

1

1 Answers

2
votes

Just check the charge status. It will be accepted or declined.

eg:

charge = ShopifyAPI::ApplicationCharge.find(params[:charge_id])
puts charge.status == 'accepted' ? "accepted" : "declined or other"

or

charge = ShopifyAPI::RecurringApplicationCharge.find(params[:charge_id])
puts charge.status == 'accepted' ? "accepted" : "declined or other"