From ea631f1f76fbb1505374a62fbad44b032c512ebf Mon Sep 17 00:00:00 2001 From: dpanta Date: Tue, 24 May 2022 21:41:09 +0300 Subject: [PATCH] CR amends --- .../class-wc-gateway-amazon-payments-advanced.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/class-wc-gateway-amazon-payments-advanced.php b/includes/class-wc-gateway-amazon-payments-advanced.php index e3af5a0e..7e3b90f4 100644 --- a/includes/class-wc-gateway-amazon-payments-advanced.php +++ b/includes/class-wc-gateway-amazon-payments-advanced.php @@ -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() ), @@ -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. *