Billing API

Shopify Partner
23 0 2
Hi Everyone, I hope you are doing fine. I am trying to add the billing part into a "Ruby on Rails" app. in the documentation there provide this function below,, but I don't know where to place it,, any ideas please, Thanks!
def create_recurring_application_charge
unless ShopifyAPI::RecurringApplicationCharge.current
recurring_application_charge =
name: "Gift Basket Plan",
price: 9.99,
return_url: "https:\/\/#{APP_URL}\/activatecharge",
test: true,
trial_days: 7,
capped_amount: 100,
terms: "$0.99 for every order created")
if @tokens[:confirmation_url] = recurring_application_charge.confirmation_url redirect recurring_application_charge.confirmation_url
Reply 1 (1)
Shopify Partner
46 0 4

DOn't know much about RUBY.  You need to place the above snippet (which creates a recurring charge) in the charge creation end point. This will give you a  object which have most importantly a charge_id and confirmation_url. Then you need to redirect user to the confirmation_url. Upon accepting the charge the customer is redirected to whatever activation_url you provided  with charge_id as query parameter. You can use this query parameter to activate the corresponding charge