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.

Billing API - Does the recurring charge turn active automatically?

Solved

Billing API - Does the recurring charge turn active automatically?

kcin1993
Shopify Partner
63 0 5

Hi, all Experts

 

# What I have done

(1) Create recurring charge API

(2) App(User) request for billing and get the param of confirmationUrl and redirect user to confirm the payment page

(3) User approval the payment

(4) Show the list of recurring charge on app

 

# My question

According the doc, when (3) user approval the payment, the charge status should be the "accepted" then I have to active that charge to make it paid . But the result I query from the list of recurring charge. The latest one charge's status is always "active".

I think that the charge become active after user approval is good.
Because I don't have to hook the accept behavior and then call active charge API by myself.

But I want to confirm that does Shopify let the recurring charge to be "active" after user approval? I only use test mode to simulate the approval of payment. The result always return the charge to be "active".

 

Thanks to help.

Accepted Solution (1)
Josh
Shopify Staff
1134 84 235

This is an accepted solution.

Hey again @kcin1993 , 

 

Yes, your charge was created in test mode. There's no way to automatically have a real recurring charge activate itself, you'll have to do it yourself. 

 

When a user accepts a charge, they'll be sent to the return_url that you set when creating the recurring charge initially. So when users are sent to your return_url, you can look up the charge and make sure that its status is 'accepted' and then activate it by following step 3 here.

Josh | 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 the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 7 (7)

Josh
Shopify Staff
1134 84 235

Hi @kcin1993 , 

 

You do in fact need to activate a recurring application charge after the user accepts it - the flow is outlined in this doc

 

If you're seeing charges that you've created as 'active', they must have been activated by your app at some point. If you have an example of one of these charges, I could take a look at our logs to confirm for you if you could provide me the ID (it would need to have been created/activated within the past 12 days).

Josh | 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 the Shopify Help Center or the Shopify Blog

kcin1993
Shopify Partner
63 0 5

@Josh 

Thanks for reply. I will check my code again.

 

Because we need the charged Id to activate the charge. I there any way to make it automatically(in our code)?

I mean that when store owner accept the charge. How do we know there is a charge accepted by store owner and we have to activate the charge from the certain charge_id?

 

Thanks

kcin1993
Shopify Partner
63 0 5

@Josh 

The ID:6294601824 
In our code I think I only create the charge and paid it in test mode. 

Here is the response for our demo store.

      {
        "id": 6294601824,
        "name": "JIOUKOU Basic",
        "api_client_id": 2941547,
        "price": "24.00",
        "status": "active",
        "return_url": "http://shopify-app-production.yosgo.com/setting",
        "billing_on": "2019-08-14",
        "created_at": "2019-08-14T01:11:20-04:00",
        "updated_at": "2019-08-14T01:11:51-04:00",
        "test": true,
        "activated_on": "2019-08-14",
        "cancelled_on": null,
        "trial_days": 0,
        "trial_ends_on": "2019-08-14",
        "decorated_return_url": "http://shopify-app-production.yosgo.com/setting?charge_id=6294601824"
      }
Josh
Shopify Staff
1134 84 235

This is an accepted solution.

Hey again @kcin1993 , 

 

Yes, your charge was created in test mode. There's no way to automatically have a real recurring charge activate itself, you'll have to do it yourself. 

 

When a user accepts a charge, they'll be sent to the return_url that you set when creating the recurring charge initially. So when users are sent to your return_url, you can look up the charge and make sure that its status is 'accepted' and then activate it by following step 3 here.

Josh | 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 the Shopify Help Center or the Shopify Blog

kcin1993
Shopify Partner
63 0 5

@Josh 

 

That is clear.

I might create a new page for the return_url. Trigger the activate charge on that page.

oneluca
Tourist
9 1 5

Hey there,

Is this still the case in December 2020? The documentation is a bit unclear in this regard. 

We have an app in the App Store, the activation happens automatically and seems to work fine. However, we are currently in review with another app and the reviewer told us, that "Recurring charge accepted" still needs to be shown in the event history. I'm not sure how to accomplish this when the charge is transitioning from pending to active.

I also created a new topic on this:

https://community.shopify.com/c/Shopify-APIs-SDKs/Recurring-charge-accepted-not-being-shown-in-event...

 

 

Fe
Tourist
6 0 4

Hey, if you use the new API (2021-01) you don't have to worry about activating the charge. It is done automatically as soon as they accept the charge. It's written here: https://shopify.dev/docs/admin-api/rest/reference/billing/recurringapplicationcharge - If you use the old API then yes you have to activate it yourself.