mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #73 from woocommerce/issue-67-no-country-selected
No country selected
This commit is contained in:
commit
13176decc8
5 changed files with 18 additions and 9 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 : ''
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'))
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue