Forums/Community/Community Support

Answered

Error creating new customer alongside new subscription via chargify_api_ares 0.3.9

Jerry Cheung
asked this on June 17, 2011 04:58 pm

Following the documentation at http://docs.chargify.com/api-subscriptions

unknown attribute: customer_attributes

The original request was:

o = Chargify::Subscription.create(product_handle:'social-spring', customer_attributes:{first_name:'jerry',last_name:'cheung',email:'jch@wcc.com',reference:'1'},credit_card_attributes:{full_number:'1',expiration_month:5,expiration_year:'2014'})

The response was:

#<Chargify::Subscription:0x00000106fb3478 @attributes={"product_handle"=>"social-spring", "customer_attributes"=>#<Chargify::Subscription::CustomerAttributes:0x00000106fb1d08 @attributes={"first_name"=>"jerry", "last_name"=>"cheung", "email"=>"jch@wcc.com", "reference"=>"1"}, @prefix_options={}, @persisted=false>, "credit_card_attributes"=>#<Chargify::Subscription::CreditCardAttributes:0x00000106faf698 @attributes={"full_number"=>"1", "expiration_month"=>5, "expiration_year"=>"2014"}, @prefix_options={}, @persisted=false>}, @prefix_options={}, @persisted=false, @remote_errors=#<ActiveResource::ResourceInvalid: Failed.  Response code = 422.  Response message = Unprocessable Entity.>, @validation_context=nil, @errors=#<ActiveResource::Errors:0x00000106faded8 @base=#<Chargify::Subscription:0x00000106fb3478 ...>, @messages={:base=>["unknown attribute: customer_attributes"]}>>

Anyone run into something similar?  I can create the customer separately and it works fine.

 

Comments

User photo
Jochen Delabie

I am having the same error

July 08, 2011 04:52 pm
User photo
Nader Akhnoukh

This works for me if you pass in a hash instead of json:

params =
{
:product_handle => 'my_product'
:customer_attributes => {
 :first_name => u.first_name,
 :last_name => u.last_name,
 :email => u.email,
 :organization => u.organization,
 :reference => u.id.to_s
}
}
# create the customer and subscription with chargify
sub = Chargify::Subscription.create(params)

July 12, 2011 02:06 pm
User photo
Ben Hoskings

Nader— the original poster isn't using JSON, that's a ruby hash using the 1.9 syntax.

I'm also having this problem. Not sure what changed; the code that's now having `customer_attributes` rejected used to work fine.

July 31, 2011 10:20 pm
User photo
Barry Hoggard

I'm seeing this problem with Active Resource 3.1.0.rc5, but not on a Rails 3.07 app.  Are the rest of you trying with 3.1?

August 08, 2011 04:03 pm
User photo
Jordi Romero

Any news on this? I'm using the latest version of everything and I'm having this problem today.

December 12, 2011 12:18 pm
User photo
Barry Hoggard

Jordi, I'm not seeing the problem now. I'm using Rails 3.1.1 and chargify_api_ares 0.4.0.

December 13, 2011 01:16 pm