Swedbank-SPP / swedbank-payment-portal

Swedbank Payment Portal API library for PHP
Other
36 stars 21 forks source link

Country format in documentation is not correct #6

Closed maijs closed 7 years ago

maijs commented 7 years ago

The problem

When I initiate a HPS payment with customer's country set in human readable format (for example, Latvia), upon transaction query I get non-interrupting error message which says The 'country' element is invalid - The value 'Latvia' is invalid according to its datatype 'Union' - The value 'Latvia' is not valid according to any of the memberTypes of the union. at line 0, position 0.

When I initiate a HPS payment with customer's country set to country code (for example, LV), I do not get such a message.

The solution

Docs should be updated with indication that country in customer's details should be formatted as a country code, not human readable format.

The logs

Scenario 1 (full country name)

Payment initiated with following billing data:

<!-- snip -->
<CustomerDetails>
  <OrderDetails>
    <BillingDetails>
      <name>John Doe</name>
      <zip_code>LV-1010</zip_code>
      <address_line1>Main street 1</address_line1>
      <address_line2></address_line2>
      <city>Riga</city>
      <country>Latvia</country>
    </BillingDetails>
  </OrderDetails>
  <PersonalDetails>
    <!-- snip -->
  </PersonalDetails>
  <ShippingDetails>
    <!-- snip -->
  </ShippingDetails>
  <PaymentDetails>
    <payment_method>CC</payment_method>
  </PaymentDetails>
  <RiskDetails>
    <!-- snip -->
  </RiskDetails>
</CustomerDetails>
<!-- snip -->

Transaction query response:

<!-- snip -->
<Risk>
  <action_response>
    <bankresult_response>
      <cpi_value></cpi_value>
      <response_code>00</response_code>
      <response_message>Successful</response_message>
      <transaction_id>xxxxxxxxxxxxxxxx</transaction_id>
    </bankresult_response>
    <error_response>
      <additional_messages>
        <message>The 'country' element is invalid - The value 'Latvia' is invalid according to its datatype 'Union' - The value 'Latvia' is not valid according to any of the memberTypes of the union. at line 0, position 0</message>
      </additional_messages>
      <response_code>997</response_code>
      <response_message>Validation of Xml message failed</response_message>
    </error_response>
  </action_response>
</Risk>
<!-- snip -->

Scenario 2 (country code)

Payment initiated with following billing data:

<!-- snip -->
<CustomerDetails>
  <OrderDetails>
    <BillingDetails>
      <name>John Doe</name>
      <zip_code>LV-1010</zip_code>
      <address_line1>Main street 1</address_line1>
      <address_line2></address_line2>
      <city>Riga</city>
      <country>LV</country>
    </BillingDetails>
  </OrderDetails>
  <PersonalDetails>
    <!-- snip -->
  </PersonalDetails>
  <ShippingDetails>
    <!-- snip -->
  </ShippingDetails>
  <PaymentDetails>
    <payment_method>CC</payment_method>
  </PaymentDetails>
  <RiskDetails>
    <!-- snip -->
  </RiskDetails>
</CustomerDetails>
<!-- snip -->

Transaction query response:

<!-- snip -->
<Risk>
  <action_response>
    <bankresult_response>
      <cpi_value></cpi_value>
      <response_code>00</response_code>
      <response_message>Successful</response_message>
      <transaction_id>xxxxxxxxxxxxxxxx</transaction_id>
    </bankresult_response>
    <screening_response>
      <additional_messages>
        <message></message>
      </additional_messages>
      <cpi_value></cpi_value>
      <response_code>00</response_code>
      <response_message>Transaction Approved</response_message>
      <transaction_id>xxxxxxxxxxxxxxxx</transaction_id>
    </screening_response>
  </action_response>
</Risk>
<!-- snip -->