cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot set default payment profile when using updateCustomerPaymentProfile in ruby

Hi everyone,

 

I am using updateCustomerPaymentProfile endpoint to try to update a payment profile. This works well, except one field, defaultPaymentProfile

 

The docs say it is an expected field, but the type does not allow it in ruby SDK, see in the official source code:

https://github.com/AuthorizeNet/sdk-ruby/blob/002019e03a94ef582aa82983edf6a7a1a22b2316/lib/authorize...

 

Even after monkey patching the type, it sends the request but I receive an error response as following:

 

AuthorizeNetException: E00003: The element 'paymentProfile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'defaultPaymentProfile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd

As a reference, the block of code that I am using:

 

        profile = AuthorizeNet::API::CustomerPaymentProfileExType.new
        profile.customerPaymentProfileId = current_profile.customerPaymentProfileId
        profile.billTo = billTo
        profile.payment = AuthorizeNet::API::PaymentType.new(AuthorizeNet::API::CreditCardType.new(cc_data.cardNumber, cc_data.expirationDate)) 
        profile.taxId = user.tax_id if user.tax_id
        profile.defaultPaymentProfile = true
        profile.customerType = 'individual'

        request = AuthorizeNet::API::UpdateCustomerPaymentProfileRequest.new
        request.paymentProfile = profile
        request.customerProfileId = customer_profile_id
        request.validationMode = AuthorizeNet::API::ValidationModeEnum::LiveMode

        response = transaction.update_customer_payment_profile(request)

What am i doing wrong?

 

Thanks for your help!

pandaiolo
Member
3 REPLIES 3

Anyone from Authorize.Net can confirm this / advise what to do?

 

Thanks

pandaiolo
Member

I dumped the raw XML sent by the request when I patch the SDK:

 

<updateCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantAuthentication>
    <name>REDACTED</name>
    <transactionKey>REDACTED</transactionKey>
  </merchantAuthentication>
  <customerProfileId>REDACTED</customerProfileId>
  <paymentProfile>
    <customerType>individual</customerType>
    <billTo>
      <firstName>REDACTED</firstName>
      <lastName>REDACTED</lastName>
      <address>REDACTED</address>
      <city>REDACTED</city>
      <state>REDACTED</state>
      <zip>REDACTED</zip>
      <country>REDACTED</country>
      <phoneNumber>REDACTED</phoneNumber>
    </billTo>
    <payment>
      <creditCard>
        <cardNumber>XXXX4242</cardNumber>
        <expirationDate>2022-03</expirationDate>
      </creditCard>
    </payment>
    <customerPaymentProfileId>REDACTED</customerPaymentProfileId>
    <defaultPaymentProfile>true</defaultPaymentProfile>
  </paymentProfile>
  <validationMode>liveMode</validationMode>
</updateCustomerPaymentProfileRequest>

Yes, this returns a malformed request response from the srever:

 

E00003 : The element 'paymentProfile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'defaultPaymentProfile' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.

 

This appears to be the same XML structure as shown in the API docs, yet it does not work.

 

Any help appreciated