Skip to content

Commit

Permalink
CR amends
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanta94 committed May 24, 2022
1 parent dddd9bd commit ea631f1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions includes/class-wc-gateway-amazon-payments-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,12 @@ public function update_address_details_for_classic( $payload, $checkout_session_
$phone_number = $order->get_shipping_phone();
$phone_number = $phone_number ? $phone_number : $order->get_billing_phone();

$shipping_state = $order->get_shipping_state();
$shipping_state = $order->get_shipping_state();
$shipping_country = $order->get_shipping_country( 'edit' );

if ( 'JP' === strtoupper( $shipping_country ) && 'JP' === strtoupper( WC_Amazon_Payments_Advanced_API::get_region() ) && isset( self::JP_REGION_CODE_MAP[ $shipping_state ] ) ) {
$shipping_state = self::JP_REGION_CODE_MAP[ $shipping_state ];
}

$payload['addressDetails'] = array(
'name' => rawurlencode( $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name() ),
Expand All @@ -2822,14 +2827,10 @@ public function update_address_details_for_classic( $payload, $checkout_session_
'city' => rawurlencode( $order->get_shipping_city() ),
'stateOrRegion' => rawurlencode( $shipping_state ),
'postalCode' => rawurlencode( $order->get_shipping_postcode() ),
'countryCode' => $order->get_shipping_country( 'edit' ),
'countryCode' => $shipping_country,
'phoneNumber' => rawurlencode( $phone_number ),
);

if ( 'JP' === strtoupper( $payload['addressDetails']['countryCode'] ) && 'JP' === strtoupper( WC_Amazon_Payments_Advanced_API::get_region() ) && isset( self::JP_REGION_CODE_MAP[ $shipping_state ] ) ) {
$payload['addressDetails']['stateOrRegion'] = rawurlencode( self::JP_REGION_CODE_MAP[ $shipping_state ] );
}

/**
* Address Validation for the EU region.
*
Expand Down

0 comments on commit ea631f1

Please sign in to comment.