chargify / chargify_api_ares

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

Setting Chargify::Subscription #next_billing_at= and the calling #save does not work. #78

Closed jkongie closed 10 years ago

jkongie commented 10 years ago

I'm trying to set a future billing date and it does not actually change the billing date for the subscription. I have tried this with new and existing subscriptions and it does not work.

# Creating a subscription
s = Chargify::Subscription.new(
  :customer_reference => "<YOUR CUSTOMER REFERENCE>",
  :product_handle => "<PRODUCT HANDLE>",
  :credit_card_attributes => {
    :first_name => "Michael",
    :last_name => "Klett",
    :expiration_month => 1,
    :expiration_year => 2020,
    :full_number => "1"
  },
  :next_billing_at => '2014-12-01'
)
s.save
# => true

# Updating a subscription
s = Chargify::Subscription.find("<SUBSCRIPTION ID>")
s.next_billing_at = '2014-12-01'
s.save
# => true

Both of the above examples do not actually update the the billing date in Chargify.

I have tested the API with curl and the HTTParty gem and both work if I have the subscription key in the json hash.

# curl example
curl -u <AUTH KEY>:x -X PUT -H "Content-Type: application/json" -d '{"subscription": { "next_billing_at": "2014-12-01" }}' https://<SUBDOMAIN>.chargify.com/subscriptions/<SUBSCRIPTION ID>.json
require 'httparty'

options = { 
  query: { subscription: { next_billing_at: "2014-12-01"  } },
  basic_auth: { username:'<AUTH KEY>' , password: 'x' }
}
ChangeCard.put('/<SUBSCRIPTION ID>.json', options)

Is there something I'm doing wrong in when using the ares gem or is this a bug?

Thanks

jkongie commented 10 years ago

OK....Sorry but ignore this for now.

After a whole day of it apparently not working, I tried again after posting this issue and it seems to be updating now. FML. :bomb:

jeremywrowe commented 10 years ago

Thanks please reopen if you continue to have the problem