- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ruby cim_trx.get_payment_profile always returns nil for street_address
suppose I retrieve a payment profile like so:
payment_profile_response = cim_trx.get_payment_profile '11243870', '12229069'
The street address is present in the response xml at /getCustomerPaymentProfileResponse/paymentProfile/billTo/address. This is verified by
puts payment_profile_response.xml.to_xml
However if I try to get that street address from the profile, it is always nil:
1.9.3p286 :021 > payment_profile_response.payment_profile.billing_address.street_address
=> nil
What's the problem?
โ02-22-2013 04:04 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi jemminger ,
The most likely problem is the order of execution that you are using. As is noted in the rubydocs for the get_payment_profile method, "If this transaction has already been run, this method will return nil." You must be sure that you are not trying to read the response after the fact.
Thanks,
Joy
โ02-25-2013 02:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Joy,
Read my original post again. The transaction is clearly not nil, because I can view the address in the XML:
puts payment_profile_response.xml.to_xml
It is the payment_profile_response.payment_profile.billing_address.street_address that is always nil.
โ02-25-2013 02:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi jemminger ,
We haven't heard of anyone else having this problem, perhaps someone else on the forums has encountered it and can suggest a solution for you.
Thanks,
Joy
โ02-25-2013 03:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is reproducible 100% of the time:
require 'rubygems'
require 'authorize-net'
def transaction
AuthorizeNet::CIM::Transaction.new('secret', 'secret', :gateway => :test)
end
# Create a new Customer
profile = AuthorizeNet::CIM::CustomerProfile.new(
:email => 'test@example.com',
:id => "Account_#{Time.now.to_i}"
)
response = transaction.create_profile(profile)
customer_id = response.profile_id
# Create a Payment Profile for the customer
credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '0120')
billing_address = AuthorizeNet::Address.new(
:first_name => 'Joe',
:last_name => 'Blow',
:street_address => '1234 Main St.',
:city => 'Here',
:state => 'ST',
:zip => '90210'
)
payment_profile = AuthorizeNet::CIM::PaymentProfile.new(
:billing_address => billing_address,
:payment_method => credit_card
)
response = transaction.create_payment_profile(payment_profile, customer_id)
payment_profile_id = response.payment_profile_id
# Now let's look that Payment Profile up
payment_profile_response = transaction.get_payment_profile payment_profile_id, customer_id
xml = payment_profile_response.xml.to_xml
street_address = payment_profile_response.payment_profile.billing_address.street_address
puts "
xml: #{xml}
street_address: #{street_address.inspect}
"
puts "
Is the street address '1234 Main St' present in the XML? #{xml.include?('1234 Main St')}
Is the street_address property of the billing_address present? #{!street_address.nil?}
"
โ02-27-2013 08:11 AM