title: Reccuring charge change activation
body: <p>I&#39;ve built an app which implements the recurring charge api and I have some issues...</p>
  
  <p>In the docs (<a href="https://help.shopify.com/api/reference/recurringapplicationcharge" rel="nofollow noreferrer"><a href="https://help.shopify.com/api/reference/recurringapplicationcharge" rel="nofollow noreferrer">https://help.shopify.com/api/reference/recurringapplicationcharge</a></a>) it states:</p>
  
  <blockquote>
  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&rsquo;s recurring charge or plan is straightforward; just change their plan, have them accept, and Shopify takes care of the rest.
  </blockquote>
  
  <p>So I have some users which I have on either &quot;test&quot; recurring charge and some on &quot;trial&quot;... how can I &quot;force&quot; them to accept the new plan (change of the name of the plan or price)...</p>
  
  <p>The thing that bugs me is that you&#39;re supposed to check for any active reccuring charges, example from the app sample on github (<a href="https://github.com/Shopify/example-ruby-app/blob/master/02%20Charging%20For%20Your%20App/app.rb" rel="nofollow noreferrer"><a href="https://github.com/Shopify/example-ruby-app/blob/master/02%20Charging%20For%20Your%20App/app.rb" rel="nofollow noreferrer">https://github.com/Shopify/example-ruby-app/blob/master/02%20Charging%20For%20Your%20App/app.rb</a></a>):</p>
  
  <pre>
      def create_recurring_application_charge
        # checks to see if there is already an RecurringApplicationCharge created and activated
        unless ShopifyAPI::RecurringApplicationCharge.current
          recurring_application_charge = ShopifyAPI::RecurringApplicationCharge.new(
                  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
          if recurring_application_charge.save
            @tokens[:confirmation_url] = recurring_application_charge.confirmation_url
            redirect recurring_application_charge.confirmation_url
          end
        end
  end</pre>
  
  <p>the method in charge of checking for an active payment is (<a href="https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/resources/recurring_application_charge.rb" rel="nofollow noreferrer"><a href="https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/resources/recurring_application_charge.rb" rel="nofollow noreferrer">https://github.com/Shopify/shopify_api/blob/master/lib/shopify_api/resources/recurring_application_charge.rb</a></a>):</p>
  
  <pre>
  module ShopifyAPI
    class RecurringApplicationCharge &lt; Base
      undef_method :test
  
      class &lt;&lt; self
        def current
          (all || []).find { |c| c.status == 'active' }
        end
  
        [:pending, :cancelled, :accepted, :declined].each do |status|
          define_method(status) { (all || []).select { |c| c.status == status.to_s } }
        end
      end
  
      def usage_charges
        UsageCharge.find(:all, params: { recurring_application_charge_id: id })
      end
  
      def cancel
        load_attributes_from_response(self.destroy)
      end
  
      def activate
        load_attributes_from_response(post(:activate))
      end
  
      def customize(customize_recurring_app_charge_params = {})
        load_attributes_from_response(put(:customize, recurring_application_charge: customize_recurring_app_charge_params ))
      end
    end
  end</pre>
  
  <p>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.</p>
  
  <p>So as far as I undrestand this method just checks the API for an active reccuring charge before issuing another reccuring charge call.</p>
  
  <p>So If I change the plan &quot;name&quot; or &quot;price&quot; nothing is going to happen because there&#39;s an existing &#39;active&#39; recurring charge (the check is done before the call to create a new reccuring plan).</p>
  
  <p>So I don&#39;t get it... how can I make this work?</p>
  
  <p>Also what happens to the current test users (they also have a valid &#39;reccuring test&#39; charge), what about trial users, after trial expiration... does Shopify delete the &#39;active trial&#39; reccuring plan?</p>
  
  <p>Thank you for all your answers!</p>
  
  <p>I've also posted this on the shopify forums: <a href="https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/reccuring-charge-change-activation-402080" rel="nofollow noreferrer">https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/reccuring-charge-change-activation-402080</a></p>