cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve PaymentProfile after user puts info in through CIM Hosted Form.

Me again- I'm having a lot of trouble integrating this.

 

Here is the goal:

User signs up on the website. Fast and easy, all that is required is their email and a password.

* This then also creates a Customer Profile at Authorize.Net, of which the ID is saved by our site.

The user can browse the site and check things out. However, the user cannot make any purchases until they put in their credit card info. (Obviously.)

The user goes to their Account Edit page, which generates a Hosted Page Token and a redirect button to Authorize.Net's hosted page. They follow the link and they can input their card info which is then saved by Authorize.Net.

 

Awesome. Everything works great up until that point. However, to create a transaction/charge to their account, I need the PaymentProfileID which should be created when they put their credit card info in. Since our site is not handling any of the users sensitive information at all, I don't have access to those things. 

 

My question is how can I get the PaymentProfileID from the Hosted Page after a user has put in their information?

(Btw, I'm using XML and Ruby on Rails)

Rockster160
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

Me again! (Again...)

 

Solved the issue. Posting here for future reference of others. :)

 

So it turns out, the Hosted Profile generates a payment/shipping profile when that information is typed in. This is expected. To retrieve that data, you must make a call to the getCustomerProfileRequest endpoint, and the payment/shipping profile is deep in there. 

Once again, using HTTParty gem.

    xml = "<?xml version='1.0' encoding='utf-8'?>
      <getCustomerProfileRequest xmlns='AnetApi/xml/v1/schema/AnetApiSchema.xsd'>
      <merchantAuthentication>
      <name>#{API_LOGIN}</name>
      <transactionKey>#{TRANSACTION_KEY}</transactionKey>
      </merchantAuthentication>
      <customerProfileId>#{self.auth_net_id}</customerProfileId>
      </getCustomerProfileRequest>
    "

    uri = URI('https://apitest.authorize.net/xml/v1/request.api')
    req = Net::HTTP::Post.new(uri.path)
    res = HTTParty.post(uri, body: xml, headers: { 'Content-Type' => 'application/xml' })

    payment_id = Hash.from_xml(res.body)["getCustomerProfileResponse"]["profile"]["paymentProfiles"]["customerPaymentProfileId"]

 

View solution in original post

Rockster160
Contributor
1 REPLY 1

Me again! (Again...)

 

Solved the issue. Posting here for future reference of others. :)

 

So it turns out, the Hosted Profile generates a payment/shipping profile when that information is typed in. This is expected. To retrieve that data, you must make a call to the getCustomerProfileRequest endpoint, and the payment/shipping profile is deep in there. 

Once again, using HTTParty gem.

    xml = "<?xml version='1.0' encoding='utf-8'?>
      <getCustomerProfileRequest xmlns='AnetApi/xml/v1/schema/AnetApiSchema.xsd'>
      <merchantAuthentication>
      <name>#{API_LOGIN}</name>
      <transactionKey>#{TRANSACTION_KEY}</transactionKey>
      </merchantAuthentication>
      <customerProfileId>#{self.auth_net_id}</customerProfileId>
      </getCustomerProfileRequest>
    "

    uri = URI('https://apitest.authorize.net/xml/v1/request.api')
    req = Net::HTTP::Post.new(uri.path)
    res = HTTParty.post(uri, body: xml, headers: { 'Content-Type' => 'application/xml' })

    payment_id = Hash.from_xml(res.body)["getCustomerProfileResponse"]["profile"]["paymentProfiles"]["customerPaymentProfileId"]

 

Rockster160
Contributor