diff --git a/modules/ppcp-api-client/src/Entity/class-payer.php b/modules/ppcp-api-client/src/Entity/class-payer.php index a5c0a5cc2..d20fd215a 100644 --- a/modules/ppcp-api-client/src/Entity/class-payer.php +++ b/modules/ppcp-api-client/src/Entity/class-payer.php @@ -70,7 +70,7 @@ class Payer { * @param PayerName $name The name. * @param string $email_address The email. * @param string $payer_id The payer id. - * @param Address $address The address. + * @param Address|null $address The address. * @param \DateTime|null $birthdate The birth date. * @param PhoneWithType|null $phone The phone. * @param PayerTaxInfo|null $tax_info The tax info. @@ -79,7 +79,7 @@ class Payer { PayerName $name, string $email_address, string $payer_id, - Address $address, + Address $address = null, \DateTime $birthdate = null, PhoneWithType $phone = null, PayerTaxInfo $tax_info = null @@ -133,9 +133,9 @@ class Payer { /** * Returns the address. * - * @return Address + * @return Address|null */ - public function address(): Address { + public function address() { return $this->address; } @@ -166,8 +166,13 @@ class Payer { $payer = array( 'name' => $this->name()->to_array(), 'email_address' => $this->email_address(), - 'address' => $this->address()->to_array(), ); + if ( $this->address() ) { + $payer['address'] = $this->address->to_array(); + if ( 2 !== strlen( $this->address()->country_code() ) ) { + unset( $payer['address'] ); + } + } if ( $this->payer_id() ) { $payer['payer_id'] = $this->payer_id(); } diff --git a/modules/ppcp-api-client/src/Factory/class-payerfactory.php b/modules/ppcp-api-client/src/Factory/class-payerfactory.php index 9b9c57a8f..fedeaa5a1 100644 --- a/modules/ppcp-api-client/src/Factory/class-payerfactory.php +++ b/modules/ppcp-api-client/src/Factory/class-payerfactory.php @@ -116,7 +116,10 @@ class PayerFactory { * @return Payer */ public function from_paypal_response( \stdClass $data ): Payer { - $address = $this->address_factory->from_paypal_response( $data->address ); + $address = null; + if ( isset( $data->address ) ) { + $address = $this->address_factory->from_paypal_response( $data->address ); + } $payer_name = new PayerName( isset( $data->name->given_name ) ? (string) $data->name->given_name : '', isset( $data->name->surname ) ? (string) $data->name->surname : '' diff --git a/modules/ppcp-api-client/src/Factory/class-purchaseunitfactory.php b/modules/ppcp-api-client/src/Factory/class-purchaseunitfactory.php index 5931ba49d..12395776d 100644 --- a/modules/ppcp-api-client/src/Factory/class-purchaseunitfactory.php +++ b/modules/ppcp-api-client/src/Factory/class-purchaseunitfactory.php @@ -153,8 +153,8 @@ class PurchaseUnitFactory { if ( $this->shipping_needed( ... array_values( $items ) ) && is_a( $customer, \WC_Customer::class ) ) { $shipping = $this->shipping_factory->from_wc_customer( \WC()->customer ); if ( - ! $shipping->address()->country_code() - || ( $shipping->address()->country_code() && ! $shipping->address()->postal_code() ) + 2 !== strlen( $shipping->address()->country_code() ) + || ( ! $shipping->address()->postal_code() ) ) { $shipping = null; } diff --git a/modules/ppcp-button/resources/js/modules/ErrorHandler.js b/modules/ppcp-button/resources/js/modules/ErrorHandler.js index 7134d952e..7a7d602e8 100644 --- a/modules/ppcp-button/resources/js/modules/ErrorHandler.js +++ b/modules/ppcp-button/resources/js/modules/ErrorHandler.js @@ -22,7 +22,7 @@ class ErrorHandler { } else { this.wrapper.classList.remove('ppcp-persist'); } - this.wrapper.innerText = this.sanitize(text); + this.wrapper.innerHTML = this.sanitize(text); jQuery.scroll_to_notices(jQuery('.woocommerce-notices-wrapper')) } diff --git a/modules/ppcp-button/src/Assets/class-smartbutton.php b/modules/ppcp-button/src/Assets/class-smartbutton.php index 3d7f03792..1f3bc261f 100644 --- a/modules/ppcp-button/src/Assets/class-smartbutton.php +++ b/modules/ppcp-button/src/Assets/class-smartbutton.php @@ -716,6 +716,7 @@ class SmartButton implements SmartButtonInterface { $this->environment->current_environment_is( Environment::SANDBOX ) && defined( 'WP_DEBUG' ) && \WP_DEBUG && is_user_logged_in() && WC()->customer && WC()->customer->get_billing_country() + && 2 === strlen( WC()->customer->get_billing_country() ) ) { $params['buyer-country'] = WC()->customer->get_billing_country(); }