Search code examples
ruby-on-rails-3authorize.netactivemerchant

ActiveMerchant with Authorize.net CIM - How to Update Customer Payment Profile


I am currently using ActiveMerchant to integrate with Authorize.net CIM. It's working mostly fine. However, I'm having issues updating a customer's payment profile information (kind of similar to this - How can I update customer payment profile details in Authorize.NET (CIM)?)

Basically, when ActiveMerchant wants to send an API request to Authorize.net, it requires me to build a CreditCard model for the credit card payment details instead of just providing a hash. But for updating a customer's payment profile, I don't have the real values for that card, only masked strings like "XXXX1111" for the card number or "XXXX" for the expiration date.

I can't create a validate CreditCard model with those values, yet all I need to do is pass the masked values back to Authorize.net. I can't find any documentation on how to do this though. Has anyone else faced this issue?


Solution

  • You need to create an invalid CreditCard object using only the masked card number. The CreditCard object will detect that there is no year or month present and use 'XXXX' for the full expiration date. The CreditCard object itself will be invalid but it will create a valid update request.

    This is the only way I could figure out how to solve the issue because the update_customer_payment_profile method wants to be able to call the 'number' method on the object so it's expecting a credit card or another object with a 'number' there.