skip to Main Content

I will like to setup a free trial in my shopify rails app. I am using the official Shopify Rails app gem https://github.com/Shopify/shopify_app. The config for billing looks like this

config.billing = ShopifyApp::BillingConfiguration.new(
charge_name: "Apps",
amount: 6.99,
interval: ShopifyApp::BillingConfiguration::INTERVAL_EVERY_30_DAYS,
currency_code: "USD", # Only supports USD for now)

How do I add an option for free trial ? I have had a look at this documentation https://shopify.dev/apps/billing/purchase-adjustments/free-trials but I dont think the api for a free trial is included in the config of the shopify rails gem

2

Answers


  1. I don’t remeber that free trials are supported by the Shopify Billing API.

    In the past I needed to implement the free trial functionality myself, outside of the Shopify Rails gem.

    One way you could do this is by creating a new plan in your app that is free, and then using the Shopify API to create a new recurring application charge for that plan

    Login or Signup to reply.
  2. At the moment shopify_app gem doesn’t support adding test property when creating a new charge.

    If you really want to add it you gonna have to implement it yourself.

    Here is how

    test_session = ShopifyAPI::Utils::SessionUtils.load_current_session(
      auth_header: request.auth_header,
      cookies: request.cookies,
    )
    
    application_charge = ShopifyAPI::ApplicationCharge.new(session: test_session)
    application_charge.name = "Super Duper Expensive action"
    application_charge.price = 100.0
    application_charge.return_url = "http://super-duper.shopifyapps.com"
    application_charge.test = true
    application_charge.save!
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search