How to get full app URL including API key?

Highlighted
Tourist
24 0 1

I'm trying to add recurring billing to my app:

recurring_application_charge = ShopifyAPI::RecurringApplicationCharge.new(
   name: "My App",
   price: 25,
   return_url: "https:\/\/#{domain}\/admin\/apps\/{ENV['SHOPIFY_CLIENT_API_KEY']}\/activatecharge",
   test: true,
   trial_days: 3,
   capped_amount: 25,
   terms: "$25 charged monthly")

I'm having trouble with the return_url field. It looks like it only accepts absolute URLs, so I can't use rails paths. So I need to generate the full app URL with the API key. Right now I'm having to get the API key directly from my environment variables. Is there a better way to do this? Like maybe accessing the API key through the ShopifyAPI object. ShopifyAPI.api_key doesn't work.

Thanks!

- Lucas

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1555 81 282

Hey Lucas,

Typically I see API keys in environment variables as you are, or stored in a DB that the app makes use of as well. You cannot request an API key with an API request.

Cheers.

1 Like
Highlighted
New Member
1 0 0
Hello,
I want a app url with API key.
Thank you
0 Likes