lyang / braintree-rails

MIT License
65 stars 22 forks source link

Add :credit_card attribute to Customer model. #15

Closed jmophoto closed 11 years ago

jmophoto commented 11 years ago

This allows for creation of a credit card with a customer using nested forms.

When using the Braintree gem, a user can create a customer and credit card in one call by using nested attributes. This extends that ability to this gem by adding the credit_card attribute to the Customer model.

Thus:

BraintreeRails::Customer.new(email: "user@example.com", credit_card: { number: "5105105105105100", expiration_date: "11/2013" })

Creates a customer with an associated card.

Also works to update, either adding a card or updating existing card.

No tests written, yet, but can be if this is something you want to merge.

Thanks for the gem!

lyang commented 11 years ago

Thank you very much for the pull request, @jmophoto!

I'll add some tests around this change. And, in the customer validator, I'll add code to validate the credit card param if it presents.