views:

198

answers:

1

I'm using ActiveMerchant with Braintree as my payment processor. I want to take advantage of Braintree's customer vault functionality to store credit card info.

Storage goes fine, but I can't figure out the correct way to charge the credit card with the customer_vault_id. It seems very straight-forward according to the Braintree documentation, but I'm not sure how to pass this through ActiveMerchant. I get validation errors from Braintree if I send a credit card with empty data, and errors from ActiveMerchant if I try nil. The only thing that seems obvious is to send the customer_vault_id in the purchase_options hash, like:

GATEWAY.purchase(self.price_in_cents, self.credit_card, 
                 :ip => self.ip_address,
                 :customer_vault_id => 12345)

Is this the correct way to use a stored customer vault?

If so, what is the correct second argument for this line if I want to use a stored customer vault as payment method?

Thanks.

+1  A: 

I discovered that you can substitute the customer_vault_id as a string for the ActiveMerchant::Billing::CreditCard in the purchase method. The docs really don't have any indication of this :(

Ben