1

Feb 8, 2018

My Ruby on Rails application has been successfully using ActiveMerchant::Billing::AuthorizeNetCimGateway with the payment type :credit_card for creating a customer profile with an embedded payment profile.

I'm now in the process of migrating to Authorize.Net's Accept.js which accepts credit card info directly sent from their hosted payment form and returns a payment nounce of type COMMON.ACCEPT.INAPP.PAYMENT that can be used for one time to create a payment transaction, customer profile, etc.

I constructed a payment_profile hash with :opaque_data in place of :credit_card. For example:

> payment_profile
=> {:payment=>
  {:opaque_data=>
    {:data_descriptor=>"COMMON.ACCEPT.INAPP.PAYMENT",
     :data_value=> "eyJjb2RlIjoiNTBfMl8wNjAwMDUzNjBDMzAwOUQ3OEUzOUQ1MDk4QTYxMjFGNzlCQ0Y3RDRGQUE4NTNCMEU3MkYyMUJBNTI3NUE0NjQ2Q0ZFQTVFNzMxMDI2Qjg5ODJGNjBFRUE2RDZFMTZCMUY5NzQ4NUJFIiwidG9rZW4iOiI5NTE4MDc3Njg5NDA4MTAwOTAzNTAyIiwidiI6IjEuMSJ9"}},
 :bill_to=>{:first_name=>"Firstname", :last_name=>"Lastname", :address=>nil, :city=>nil, :state=>nil, :zip=>nil, :country=>nil, :phone_number=>"(012) 234-5678"}}

I then tried to create a customer profile with an existing code similar to the following:

response = @gateway.create_customer_profile profile: {
  email: client.email,
  description: client.name,
  merchant_customer_id: client.id,
  payment_profiles: payment_profile
}

However, I received a response which had a result_code of Error and complained about "incomplete content" for element payment as follows:

> response
=> #<ActiveMerchant::Billing::Response:0x007f9827d14900
 @authorization=nil,
 @avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil},
 @cvv_result={"code"=>nil, "message"=>nil},
 @emv_authorization=nil,
 @error_code="E00003",
 @fraud_review=nil,
 @message=
  "The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData, emv' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.",
 @params=
  {"messages"=>
    {"result_code"=>"Error",
     "message"=>
      {"code"=>"E00003",
       "text"=>
    "The element 'payment' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'creditCard, bankAccount, trackData, encryptedTrackData, payPal, opaqueData, emv' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'."}}},
 @success=false,
 @test=true>

I have a few questions in my mind:

  1. Does ActiveMerchant::Billing::AuthorizeNetCimGateway even support Accept.js' :opaque_data in place of :credit_card?

  2. If ActiveMerchant::Billing::AuthorizeNetCimGateway does support :opaque_data, what's may be wrong with the above payment_profile and what other content that I'd need to provide for payment element?

I'd appreciate any help in resolving this issue.

Waihon Yew
  • 65
  • 6

1 Answers1

0

While this question is over 4 years old, and I'm assuming you have either found a solution or abandoned your effort, I ran into this same issue recently, and thought it would be helpful to add my findings in case someone else runs into this.

the AuthorizeNetCimGateway does not currently support Accept.js' opaqueData. In looking at the sourcecode for the active_merchant gem, specifically in /lib/active_merchant/billing/gateways/authorize_net_cim.rb, there is ultimately a method add_payment_profile that gets called. In that method, specifically on lines 759-761, you can see that the options are either a credit_card, bank_account, or drivers_license. A tokenized payment is not currently supported.

That being said, there is an open PR#2422 that adds support for this. At the time of writing this, it appears to be failing some rubocop specs, but hopefully it can get deployed in the near future!

pbybel
  • 13
  • 3
  • I no longer working on that code base. Thank you anyway for highlighting the PR, which is still open as of now. – Waihon Yew Sep 17 '22 at 07:12