Billing API in Embedded Apps

Shopify Partner
5 0 0

Hey,

I have created an embedded app. Now I want to integrate Billing API. My question is what will be the flow.

First user will land on the permission page, after selecting the app from App store. 

Will I charge the user right after that authentication, or will I create a screen with a button showing user that now you will be charged. will the confirmation_url and return_url will work same as they are work for non-embedded apps?

 

Regards

Junaid

0 Likes
Shopify Partner
411 0 51

It works the same. We put payment as part of the signature checking process or otherwise it can be bypassed if it is only in your install flow.

  1. Check Signature
  2. Check if customer has a billing agreement
  3. If not redirect to billing agreement page, If yes show app.
  4. Send back to app
  5. Start from Step 1 again.
Want an app but can't find what you need? Let us know we custom build apps for Free
0 Likes
Shopify Partner
411 0 51

The one thing we did notice is the billing page can sometimes get nested with an additional shopify menu so we use a javascript redirect rather than a server side one.

Want an app but can't find what you need? Let us know we custom build apps for Free
0 Likes
Highlighted
Shopify Partner
5 0 0

Thanks for the answer. can you tell me how to check signatures for billing agreement. and what is the link for billing agreement page where user will be redirected?

Thanks in advance. 

0 Likes
Shopify Partner
411 0 51

Yeah this is kinda of a hairy one

  1. you need to send a POST request to generate a charge
  2. This will give you the confirmation_url which we throw in to a javascript redirect
  3. The user then accepts or declines
  4. If they accept shopify send back a ?charge_id=xxxxxx to the redirect url you specified (This is where it is a bit hairy as it would be good to have a shop,signature, timestamp)
  5. We already have a session since step 1 so we use our session information to figure out where the charge_id is coming from however you can probably use a better return_url to identify where this is coming from.
  6. You then need to GET the charge from the API
  7. Then you need to post the charge back to the API with a POST request to the /admin/recurring_application_charges/'.$request->get('charge_id').'/activate.json endpoint.
  8. Now your done.
Want an app but can't find what you need? Let us know we custom build apps for Free
1 Like