Shopify Post-purchase get Checkout Id

Solved

Shopify Post-purchase get Checkout Id

ripci
Shopify Partner
5 1 8

I have created a simple app following https://shopify.dev/apps/checkout/post-purchase/update-an-order-for-a-checkout-post-purchase-app-ext... tutorial. I am customizing it and a big part of the functionality will be for me to be able to read the checkout id.

 

The URL is url.myshopify.com/checkouts/c/UUID/post-purchase , but due to it being run in a web worker, you can not fetch the URL to parse the UUID. I am wondering if there is a simple way to get this. I think this is probably a crucial functionality for a lot of apps, so it seems weird that it's this difficult.

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 511

This is an accepted solution.

Hey @ripci - the best way to do this would be to set up a webhook subscription for your app to the checkouts/create or checkouts/update topics, if you haven't looked at this as an option yet. This would trigger Shopify to send out checkout-related data when the checkout is created (include the checkout ID/URL) in JSON format. Let us know if you have any other questions and we'd be happy to answer on our end. Hope this helps!

 

Al | Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1453 238 511

This is an accepted solution.

Hey @ripci - the best way to do this would be to set up a webhook subscription for your app to the checkouts/create or checkouts/update topics, if you haven't looked at this as an option yet. This would trigger Shopify to send out checkout-related data when the checkout is created (include the checkout ID/URL) in JSON format. Let us know if you have any other questions and we'd be happy to answer on our end. Hope this helps!

 

Al | Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

ripci
Shopify Partner
5 1 8

While I have you, is it possible to make authenticated calls from post-purchase? For testing purposes, I want to just send the checkout id manually, but I can not figure out how to have it authenticated.

 

I am using the sample app for QR Codes, which on the admin dashboard sends the session using authenticatedFetch to the backend, so it is authenticated that way. It doesn't seem possible to use authenticatedFetch from post purchase, so is there another way?

ShopifyDevSup
Shopify Staff
1453 238 511

Hey @ripci,

 

According to our post purchase documentation it's possible to make an optional network request to your app server, but I don't see any more details or examples.

 

There is also a list of performance considerations to take into account if you are still trying to implement this.

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog