Reccuring Charge Change Activation

- 1 answer

I've built an app which implements the recurring charge api and I have some issues...

In the docs ( it states:

Each shop may have only one recurring charge per application. When a new RecurringApplicationCharge is activated for a shop that already has a recurring charge for that application, the existing recurring charge will be cancelled and replaced by the new charge. The new recurring charge will then activate. This means that upgrading and downgrading a user’s recurring charge or plan is straightforward; just change their plan, have them accept, and Shopify takes care of the rest.

So I have some users which I have on either "test" recurring charge and some on "trial"... how can I "force" them to accept the new plan (change of the name of the plan or price)...

The thing that bugs me is that you're supposed to check for any active reccuring charges, example from the app sample on github (

    def create_recurring_application_charge
      # checks to see if there is already an RecurringApplicationCharge created and activated
      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 the new RecurringApplicationCharge saves,redirect the user to the confirmation URL,
        # so they can accept or decline the charge
          @tokens[:confirmation_url] = recurring_application_charge.confirmation_url
          redirect recurring_application_charge.confirmation_url

the method in charge of checking for an active payment is (

module ShopifyAPI
  class RecurringApplicationCharge < Base
    undef_method :test

    class << self
      def current
        (all || []).find { |c| c.status == 'active' }

      [:pending, :cancelled, :accepted, :declined].each do |status|
        define_method(status) { (all || []).select { |c| c.status == status.to_s } }

    def usage_charges
      UsageCharge.find(:all, params: { recurring_application_charge_id: id })

    def cancel

    def activate

    def customize(customize_recurring_app_charge_params = {})
      load_attributes_from_response(put(:customize, recurring_application_charge: customize_recurring_app_charge_params ))

Disclaimer: I've never coded in ruby nor is my app built in ruby, but this is the only example I could find, other were just carbon copies of the official test app.

So as far as I undrestand this method just checks the API for an active reccuring charge before issuing another reccuring charge call.

So If I change the plan "name" or "price" nothing is going to happen because there's an existing 'active' recurring charge (the check is done before the call to create a new reccuring plan).

So I don't get it... how can I make this work?

Also what happens to the current test users (they also have a valid 'reccuring test' charge), what about trial users, after trial expiration... does Shopify delete the 'active trial' reccuring plan?

Thank you for all your answers!

I've also posted this on the shopify forums:



Just delete the active charge with the test or trial status, and issue the new one. Simple. It will replace the old one when the merchant chooses to accept the new charge, which should be offered to them.