Solved

Non public app that can populate checkout page with products and discounts?

agentjuly
Excursionist
20 0 6

I am trying an experiment and I think I am close to a complete solution. I would like to do the following.

 

  1. I do not want to modify any of the liquid templates in my shopify site.
  2. I want to put a button with the text "Click Me" in the header of my shopify site.
  3. When the customer presses "Click Me", they will be taken to the shopify checkout page. The shopify checkout page must show a quantity of 2 for the product with variant_id 11111111111111 and the checkout page must show that a discount of $X will be applied to the checkout. The value of X must be a random number between 0 and 100. The value of X must not be associated with any existing discount codes in the shopify store.
  4. This solution must be available to only my store and no other store.

I created a prototype, but the best I could do was satisfy objectives 1-3. I do not know how to satisfy all 4 objectives. Is it possible to satisfy all 4 objectives? If so, what do I need to do?


Details on my prototype:

 

For my prototype I created an unpublished sales channel app called the ProtoApp. My ProtoApp will use the script_tag.json API endpoint to load a custom javascript file from one of my linux servers. My custom javascript file will add a new <button> element to the header of the webpage. The onclick event of the button will make an ajax call to my ProtoApp . My ProtoApp will make the following call via BASH on Linux

 

curl -i \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-H "X-Shopify-Access-Token: mytokenfromshopify" \
-X POST "https://mystore.myshopify.com/admin/api/2019-07/checkouts.json" \
-d @checkout.json

And my checkout.json looks like this

 

{
  "checkout": {
    "line_items": [
      {
        "variant_id": 11111111111111,
        "quantity": 2
      }
    ],
    "applied_discount": {
    "amount": ###autogen###,
    "title": "XYZ Promotion",
    "description": "Promotional item for blackfriday.",
    "value": ###autogen###,
    "value_type": "fixed_amount",
    "non_applicable_reason": null,
    "applicable": true
    }
  }
}

 

Shopify Checkout API will give me a success response. I will find a web_url with a value like https://mystore.myshopify.com/402423011/checkouts/2b3e24742ea6c087ec7c10e7c4117bba in the success response.  I send this web_url back to my javascript file and do a location.href = web_url, which causes the customer to go to the checkout page. The customer sees the appropriate discount applied. The customer can continue with checkout process and payment. Everything is perfect.

 

To my current understanding, the problem with this approach is that in order to use it in a production store, I must publish my app to the market. This means other people other than me will be able to use it. Hence failure to meet the 4th requirement mentioned above.

 

Based on my research, a private app will not allow me the write_checkout scope, which to my understanding, is necessary for my solution.


Any suggestions on what I can do to satisfy all 4 objectives?

Accepted Solution (1)
Visely-Team
Shopify Partner
1843 210 488

This is an accepted solution.

That wont work either. So I believe that is it.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog

View solution in original post

Replies 7 (7)

Visely-Team
Shopify Partner
1843 210 488

I am afraid there is no way to workaround this and cover for all 4 objectives above.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
agentjuly
Excursionist
20 0 6

Thanks for you insight!

 

When I ready about the Graph QL approach, I seem to see indications of a checkout API:

 

https://help.shopify.com/en/api/storefront-api/guides/checkout-guide#creating-the-checkout

 

Do you think that would allow me to cover all four of the requirements? 

Visely-Team
Shopify Partner
1843 210 488

I think the same constraints would apply, but you can give it a try.

 

On a second thought, you can publish the app and then within your code limit the usage to just the store you want it to run (check the server the request to your JS originated and exercise the actual functionality only if the domain matches the store or the list of stores you want), but that would look odd/confusing for merchants and I am more than sure Shopify wont certify such an app for publication in the app store.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
agentjuly
Excursionist
20 0 6

Thanks again for your insight.  You stated the exact reason why I do not want to make a public app.  Because I'm under the impression that a public app must be reviewed by Shopify.  And I can't see Shopify allowing an app like mine that was meant for only one merchant store to be publicly listed.

 

So I took another look at https://help.shopify.com/en/api/storefront-api/guides/checkout-guide#creating-the-checkout .  It says the prerequisite is to have access to StoreFront API.  And the prerequisite to StoreFront API is to create either a private app or a public app.  And I already ran into the problem that private does not offer the write_checkout scope.  And we are already saying that the public app will likely be rejected.

 

So is that it?  What I'm asking for is impossible?

agentjuly
Excursionist
20 0 6

Actually, can I keep my prototype as an unpublished sales channel app.  Then from my Shopify Partners account, some how gain access to my real shopify store.  Then install my prototype to my real shopify store? 

Visely-Team
Shopify Partner
1843 210 488

This is an accepted solution.

That wont work either. So I believe that is it.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
agentjuly
Excursionist
20 0 6

Agh...that is so irritating!  You're right, because my shopify partner account only allows me to install apps on development stores....

 

This is frustrating....why is it so difficult to share an app that requires write_checkouts scope with only one other store in the real world?  I just don't get the reason behind that....