Reply
Highlighted
Contributor
Posts: 11
Registered: ‎02-27-2015
Accepted Solution

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

[ Edited ]

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)


Accepted Solutions
Highlighted
Solution
Accepted by topic author Rockster160
‎08-21-2015 01:58 AM
Contributor
Posts: 11
Registered: ‎02-27-2015

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

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


All Replies
Highlighted
Solution
Accepted by topic author Rockster160
‎08-21-2015 01:58 AM
Contributor
Posts: 11
Registered: ‎02-27-2015

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

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"]