- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hopefully this is going to be the right place to get some help...
- My first message to developer@authorize.net was:
Currently, we are using Customer Profiles & Payment Profiles to save our subscribers bill-to information and I need to give them the ability to update their billing information (first name, last name, address, etc...) without changing the credit card information.
I have been trying to use the UpdateCustomerPaymentProfileRequest class, sending only the billTo information and the response that always get from the request is "Failed to update payment profile ID XXXX. Payment information is required". Reading posts and comments in your dev community blog, several people recommend "For card information you can pass exactly what comes back from GetCustomerPaymentProfileRequest if you don't need to update that info", but using this solution I always get the response "The element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'cardType' in namespace".
Everything that I have tried has failed.
So my main question would be, is possible to update the information not related to the credit card in the Payment profiles using the Authorize.net API (of course without sending the payment information)? - They answer me with:
If fields are not submitted or submitted blank using the updateCustomerPaymentProfileRequest, then the original profile information will be removed. You will want to submit getCustomerPaymentProfileRequest to obtain the most current details including the masked payment information. You can change the needed fields and reuse the fields you received with updates, using the updateCustomerPaymentProfileRequest API call. - I answered with:
Unfortunately I still have problems implementing your suggestion... The following is the class that I created with your suggestions and I'm still receiving errors from the API... Could you please give me some advices about how to solve this?module AuthorizeTransactionManager
require 'authorizenet'
include AuthorizeNet::APIclass ANProposedSolution
def initialize
@transaction = Transaction.new(
AUTHORIZE_API_LOGIN,
AUTHORIZE_API_KEY,
:gateway => AUTHORIZE_GATEWAY
)
enddef request_customer_payment_profile
request = GetCustomerPaymentProfileRequest.new
request.customerProfileId = 1507241273
request.customerPaymentProfileId = 1506634046response = @transaction.get_customer_payment_profile(request)
if response.messages.resultCode == MessageTypeEnum::Ok
response.paymentProfile
else
puts response.messages.messages[0].text
puts "Failed to get payment profile information with ID #{request.customerPaymentProfileId}."
nil
end
enddef update_customer_payment_profile_option_a
current_payment_profile = request_customer_payment_profile
unless current_payment_profile.blank?
current_payment_profile.billTo.firstName = "New firstName"
current_payment_profile.billTo.lastName = "New lastName"
current_payment_profile.billTo.company = "New company"request = UpdateCustomerPaymentProfileRequest.new(current_payment_profile)
response = @transaction.update_customer_payment_profile(request)if response.messages.resultCode == MessageTypeEnum::Ok
puts "Successfully updated customer payment profile with ID #{request.paymentProfile.customerPaymentProfileId}."
else
puts response.messages.messages[0].text
# ERROR! => The element 'updateCustomerPaymentProfileRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'merchantAuthentication' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'clientId, refId, customerProfileId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
puts "Failed to update customer with customer payment profile ID #{request.paymentProfile.customerPaymentProfileId}."
# ERROR! => NoMethodError: undefined method `customerPaymentProfileId' for nil:NilClass
end
else
puts "Failed to get payment profile information"
end
enddef update_customer_payment_profile_option_b
current_payment_profile = request_customer_payment_profile
unless current_payment_profile.blank?
current_payment_profile.billTo.firstName = "New firstName"
current_payment_profile.billTo.lastName = "New lastName"
current_payment_profile.billTo.company = "New company"request = UpdateCustomerPaymentProfileRequest.new
payment = PaymentType.new(current_payment_profile.payment)
profile = CustomerPaymentProfileExType.new(nil,current_payment_profile.billTo,payment,nil,nil)request.paymentProfile = profile
request.customerProfileId = current_payment_profile.customerProfileId
profile.customerPaymentProfileId = current_payment_profile.customerPaymentProfileIdresponse = @transaction.update_customer_payment_profile(request)
if response.messages.resultCode == MessageTypeEnum::Ok
puts "Successfully updated customer payment profile with ID #{request.paymentProfile.customerPaymentProfileId}."
else
puts response.messages.messages[0].text
# ERROR! => The element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'cardNumber' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
puts "Failed to update customer with customer payment profile ID #{request.paymentProfile.customerPaymentProfileId}."
end
else
puts "Failed to get payment profile information"
end
end
end
end - They answer me with:
As long as you are providing all data, you should not see any errors. I would recommend providing this information to our developers in the forum as we provide limited support here.
I know is a long story... I just want to give you the whole picture...
Any help? Thanks!
Solved! Go to Solution.
04-26-2019 02:34 PM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @asaavedra ,
In your post you are mentioning that you are getting an error -"The element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'cardType' in namespace" when you pass the card information that comes back from GetCustomerPaymentProfileRequest. The GetCustomerPaymentProfileResponse will have payment information like below:
<payment> <creditCard> <cardNumber> XXXX1733 </cardNumber> <expirationDate> XXXX </expirationDate> <cardType> Visa </cardType> </creditCard> </payment>
But when you make the UpdateCustomerPaymentProfileRequest in the payment information only pass the cardNumber and expirationDate like this:
<payment> <creditCard> <cardNumber> XXXX1733 </cardNumber> <expirationDate> XXXX </expirationDate> </creditCard> </payment>
04-29-2019 10:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @asaavedra,
Do not pass the cardType field in the UpdateCustomerPaymentProfileRequest. You can copy the billTo and payment from getCustomerPaymentProfileResponse to the UpdateCustomerPaymentProfileRequest. Make your changes in billTo and remove cardType from payment. This is a sample UpdateCustomerPaymentProfileRequest using the default test merchant credentials from https://developer.authorize.net/api/reference/index.html:
<updateCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>4vzCzTK46uB</name> <transactionKey>4eT533qH5xD4v62S</transactionKey> </merchantAuthentication> <customerProfileId>36227533</customerProfileId> <paymentProfile> <billTo> <firstName>fasfghjk</firstName> <lastName>gfsakjdhf</lastName> <address>kajshfg</address> <city>kfjasdfghk</city> <state>fjkshadf</state> <zip>566666</zip> <country>Jamaica</country> <phoneNumber>123141666</phoneNumber> </billTo> <payment> <creditCard> <cardNumber> XXXX1733 </cardNumber> <expirationDate> XXXX </expirationDate> </creditCard> </payment> <customerPaymentProfileId>1831340201</customerPaymentProfileId> </paymentProfile> </updateCustomerPaymentProfileRequest>
04-28-2019 11:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @rahulr!
Thanks so much for your help!
Currently, I am developing in RoR and due to this I have followed the Sample Code > Ruby (this is the GitHub source) and I have examined the rubydoc about the AuthorizeNet gem and the method UpdateCustomerPaymentProfileRequest requires a CustomerPaymentProfileExType (=paymentProfile) object. If I do not send the PaymentType object I receive the following error "Failed to update payment profile ID XXXX. Payment information is required".
Or probably I am not understanding your comment about "cardType", I don't see that reference in my code neither in the sample UpdateCustomerPaymentProfileRequest.
Or are you recommending me not use the Gem and instead use XML requests?
Thanks so much for your time and answer!
04-29-2019 10:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @asaavedra ,
In your post you are mentioning that you are getting an error -"The element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'cardType' in namespace" when you pass the card information that comes back from GetCustomerPaymentProfileRequest. The GetCustomerPaymentProfileResponse will have payment information like below:
<payment> <creditCard> <cardNumber> XXXX1733 </cardNumber> <expirationDate> XXXX </expirationDate> <cardType> Visa </cardType> </creditCard> </payment>
But when you make the UpdateCustomerPaymentProfileRequest in the payment information only pass the cardNumber and expirationDate like this:
<payment> <creditCard> <cardNumber> XXXX1733 </cardNumber> <expirationDate> XXXX </expirationDate> </creditCard> </payment>
04-29-2019 10:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @rahulr.
OMG! I am so sorry! I totally forgot my firsts attempts to solve this and I was just focused into the last class I posted (ANProposedSolution)... and... THANK YOU SO MUCH!!! Your solution works! I am almost sure that I tried what you proposed before posting my problem here but I can't remember what happened... but... THANK YOU SOOO MUCH!!!
The following is the method that I created (added to the ANProposedSolution class) using your solution and it works perfectly!
... def update_customer_payment_profile_solution current_payment_profile = request_customer_payment_profile cc_data = request_customer_payment_profile.payment.creditCard unless current_payment_profile.blank? current_payment_profile.billTo.firstName = "New firstName" current_payment_profile.billTo.lastName = "New lastName" current_payment_profile.billTo.company = "New company" request = UpdateCustomerPaymentProfileRequest.new payment = PaymentType.new(CreditCardType.new(cc_data.cardNumber, cc_data.expirationDate)) profile = CustomerPaymentProfileExType.new(nil,current_payment_profile.billTo,payment,nil,nil) request.paymentProfile = profile request.customerProfileId = current_payment_profile.customerProfileId profile.customerPaymentProfileId = current_payment_profile.customerPaymentProfileId response = @transaction.update_customer_payment_profile(request) if response.messages.resultCode == MessageTypeEnum::Ok puts "Successfully updated customer payment profile with ID #{request.paymentProfile.customerPaymentProfileId}." else puts response.messages.messages[0].text puts "Failed to update customer with customer payment profile ID #{request.paymentProfile.customerPaymentProfileId}." end else puts "Failed to get payment profile information" end end ...
05-06-2019 11:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@asaavedra I'd like to thank you for this very thourough post and also for documenting the solution with the code. It helped me a lot to succeed update a customer payment profile without requesting payment information again.
Cheers!
09-29-2021 08:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for sharing such a helpful instruction, really appreciate for your article.
10-01-2021 03:16 AM

