chargify / chargify_api_ares

A Chargify API wrapper for Ruby using ActiveResource
http://chargify.com
MIT License
161 stars 95 forks source link

Subscription#remove_coupon ignores coupon code argument #166

Closed dharmamike closed 6 years ago

dharmamike commented 6 years ago

The Subscription#remove_coupon method optionally takes a coupon code string as an argument. The behavior of the underlying API method is such that if the subscription has only one coupon, the specified coupon will be removed if the coupon code is passed or not.

The bug present is that within chargify-api-ares the value passed to the API is essentially ignored because it is sent with the wrong parameter, code instead of coupon_code.

    def remove_coupon(code=nil)
      process_capturing_errors do
        if code.nil?
          delete :remove_coupon
        else
          delete :remove_coupon, :code => code
        end
      end
    end

Given a subscription with a single coupon, the end result is as expected, but the bug manifests itself if there are multiple coupons on a subscription. In this case, the API method currently removes no coupon codes with or without a code being passed. However, it should result in removal of only the specified coupon if a coupon code is passed.

A proposed solution is available in https://github.com/chargify/chargify_api_ares/pull/165

dharmamike commented 6 years ago

Fixed with https://github.com/chargify/chargify_api_ares/pull/165