FROM CACHE - en_header

About Create a billing attempt API in subscription api

Solved
parth-gondaliya
Shopify Partner
20 0 7

I am stuck at the point where I don't know how to deal with billing attempt API  while a customer creates an order of subscription products for the first time?

My requirement is,

1) I want to automate the billing process of the subscription product when customers purchase a product with a subscription?

2) do we manually set the billing process or Shopify do it for us.

Well, I have read all documents regarding a subscription on Shopify but I am confused totally.

PLEASE HELP !!!

Accepted Solution (1)

Accepted Solutions
jlalande
Shopify Staff
Shopify Staff
16 3 10

This is an accepted solution.

should we call API using the concept of crone job or what is a standard way to call billing attempt API?

There is no "standard" way, It's really up to the app developer to decide on the implementation. You could definitely build a solution that uses cron jobs to trigger billing attempts.

What is the procedure to call billing attempt API after getting contract id within webhook??

It really depends on how you implement your app. Like mentioned in: https://shopify.dev/tutorials/create-manage-subscription-contracts#subscription-related-webhooks, when you subscribe to the subscription_contracts/create webhook, your app gets notified when a new contract is created from a Shopify checkout. You can use the contract id in the payload of the webhook to query the contract and run any application logic your app might have to do with this contract. This could be scheduling a billing attempt for the next billing date of the contract for example.

Would you please explain to me what is an actual and standard way to deal (workflow) with billing attempt API ???

The best thing I can do is redirect you to this page https://shopify.dev/tutorials/create-manage-subscription-contracts. It explains the entire flow from selling plans, to creating billing attempts for contracts. It does it way better than I could in a forum post. Let me know if something is not clear in the page, I will gladly expand on it :).

View solution in original post

Replies 5 (5)
jlalande
Shopify Staff
Shopify Staff
16 3 10

Hello @parth-gondaliya,

1) I want to automate the billing process of the subscription product when customers purchase a product with a subscription?

When a buyer purchases a subscription product, Shopify will create a subscription contract, and record the payment method so that it can be used to bill the buyer in the future. Once you have a subscription contract, you can create a billing attempt. If the billing attempt is successful, an order is created and the buyer has been billed via the recorded payment method. In this sense, your app is responsible to trigger billing attempts when the subscription has to be renewed.

2) do we manually set the billing process or Shopify do it for us.

I'm not sure that I understand the question. Can you elaborate a little bit more?

Thanks for reaching out! 

parth-gondaliya
Shopify Partner
20 0 7

@jlalande  Thanks for the reply,

where should I call billing attempt API like after getting contract id within webhook or Should call it using crone job ??

should we call API using the concept of crone job or what is a standard way to call billing attempt API? 

What is the procedure to call billing attempt API after getting contract id within webhook??

Would you please explain to me what is an actual and standard way to deal (workflow) with billing attempt API  ???

 

jlalande
Shopify Staff
Shopify Staff
16 3 10

This is an accepted solution.

should we call API using the concept of crone job or what is a standard way to call billing attempt API?

There is no "standard" way, It's really up to the app developer to decide on the implementation. You could definitely build a solution that uses cron jobs to trigger billing attempts.

What is the procedure to call billing attempt API after getting contract id within webhook??

It really depends on how you implement your app. Like mentioned in: https://shopify.dev/tutorials/create-manage-subscription-contracts#subscription-related-webhooks, when you subscribe to the subscription_contracts/create webhook, your app gets notified when a new contract is created from a Shopify checkout. You can use the contract id in the payload of the webhook to query the contract and run any application logic your app might have to do with this contract. This could be scheduling a billing attempt for the next billing date of the contract for example.

Would you please explain to me what is an actual and standard way to deal (workflow) with billing attempt API ???

The best thing I can do is redirect you to this page https://shopify.dev/tutorials/create-manage-subscription-contracts. It explains the entire flow from selling plans, to creating billing attempts for contracts. It does it way better than I could in a forum post. Let me know if something is not clear in the page, I will gladly expand on it :).

HD_WORK
New Member
20 0 0

@parth-gondaliya can you help me with this.

i have created app, customer can purchase subscription. i am getting subscription contract but its not creating order on next billing date. I thought billing api can help me in this.

can help me with sharing your experience of how to deal with billing api problem of yours ?????

 

najeeba
Shopify Partner
13 2 4

Hi @HD_WORK 

Don't know if you found a solution. I hope it will be of help to others who are going through same situation.

Once you get the subscriptioncontract, save the next billing date. You can call the billing API on the next billing date and submit it. An order will be created in Shopify if the billing attempt is successful. Calculate the next billing date of the contract with the blilling policy available in the contract and save it into your database, so that you the crone job/scheduler will take it up again on that day and submit the billing. Hope this is clear to you.