AuthorizeNet / sdk-ruby

Ruby SDK for the Authorize.Net API
Other
87 stars 111 forks source link

CustomerPaymentProfileExType missing properties compared to the xsd schema? #189

Closed pandaiolo closed 3 weeks ago

pandaiolo commented 2 years ago

Considering the following CustomerPaymentProfileType:

  # {AnetApi/xml/v1/schema/AnetApiSchema.xsd}customerPaymentProfileType
  #   customerType - CustomerTypeEnum
  #   billTo - CustomerAddressType
  #   payment - PaymentType
  #   driversLicense - DriversLicenseType
  #   taxId - SOAP::SOAPString
  #   defaultPaymentProfile - SOAP::SOAPBoolean
  #   subsequentAuthInformation - SubsequentAuthInformation
  class CustomerPaymentProfileType
    include ROXML
    xml_accessor :customerType
    xml_accessor :billTo, as: CustomerAddressType
    xml_accessor :payment, as: PaymentType
    xml_accessor :driversLicense, as: DriversLicenseType
    xml_accessor :taxId
    xml_accessor :defaultPaymentProfile
    xml_accessor :subsequentAuthInformation, as: SubsequentAuthInformation

    def initialize(customerType = nil, billTo = nil, payment = nil, driversLicense = nil, taxId = nil, defaultPaymentProfile = nil, subsequentAuthInformation = nil)
      @customerType = customerType
      @billTo = billTo
      @payment = payment
      @driversLicense = driversLicense
      @taxId = taxId
      @defaultPaymentProfile = defaultPaymentProfile
      @subsequentAuthInformation = subsequentAuthInformation
    end
  end

Why is CustomerPaymentProfileExType defined in the following way?

# {AnetApi/xml/v1/schema/AnetApiSchema.xsd}customerPaymentProfileExType
  #   customerType - CustomerTypeEnum
  #   billTo - CustomerAddressType
  #   payment - PaymentType
  #   driversLicense - DriversLicenseType
  #   taxId - SOAP::SOAPString
  #   customerPaymentProfileId - (any)
  class CustomerPaymentProfileExType
    include ROXML
    xml_accessor :customerType
    xml_accessor :billTo, as: CustomerAddressType
    xml_accessor :payment, as: PaymentType
    xml_accessor :driversLicense, as: DriversLicenseType
    xml_accessor :taxId
    xml_accessor :customerPaymentProfileId

    def initialize(customerType = nil, billTo = nil, payment = nil, driversLicense = nil, taxId = nil, customerPaymentProfileId = nil)
      @customerType = customerType
      @billTo = billTo
      @payment = payment
      @driversLicense = driversLicense
      @taxId = taxId
      @customerPaymentProfileId = customerPaymentProfileId
    end
  end

Given the relevant portion of the xsd schema:

<xs:complexType name="customerPaymentProfileExType">
  <xs:complexContent>
    <xs:extension base="anet:customerPaymentProfileType">
      <xs:sequence>
        <xs:element name="customerPaymentProfileId" type="anet:numericString" minOccurs="0"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

Expected instead:

I would expect the CustomerPaymentProfileExType to include the same properties as the CustomerPaymentProfileType does, which means: defaultPaymentProfile and subsequentAuthInformation

Or am I missing something?

Extra question:

As asked in the community, I patched the above on my local copy of the sdk, but the server responded with an error:

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

Is this from the server or from the lib? In any case, why is the defaultPaymentProfile property refused from that request , despite it is clearly defined in the schema, and, also, necessary to update the underlying concept of a default payment profile in a customer profile...

Thanks for your help.

pandaiolo commented 2 years ago

As seen in this SO answer the server only accepts XML children in the right order. Hence the issue using the provided SDK type (which missed the prop alltogether) or monkey patched type (which would add the missing type in the wrong order)

Anybody experiencing the same can use this custom type until this is fixed:

module AuthorizeNet::API 
  class CustomerPaymentProfileExTypePatched
    include ROXML
    xml_accessor :customerType
    xml_accessor :billTo, as: AuthorizeNet::API::CustomerAddressType
    xml_accessor :payment, as: AuthorizeNet::API::PaymentType
    xml_accessor :driversLicense, as: AuthorizeNet::API::DriversLicenseType
    xml_accessor :taxId
    xml_accessor :defaultPaymentProfile
    xml_accessor :subsequentAuthInformation
    xml_accessor :customerPaymentProfileId

    def initialize(customerType = nil, billTo = nil, payment = nil, driversLicense = nil, taxId = nil, defaultPaymentProfile = nil, subsequentAuthInformation = nil, customerPaymentProfileId = nil)
      @customerType = customerType
      @billTo = billTo
      @payment = payment
      @driversLicense = driversLicense
      @taxId = taxId
      @defaultPaymentProfile = defaultPaymentProfile
      @subsequentAuthInformation = subsequentAuthInformation
      @customerPaymentProfileId = customerPaymentProfileId
    end
  end
end
gnongsie commented 3 weeks ago

Closing this as the fix has been added as part of a commit.