mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add PayPal merchant country to seller status
This commit is contained in:
parent
22ddf2597f
commit
86317a63d1
3 changed files with 14 additions and 4 deletions
|
@ -160,7 +160,7 @@ class PartnersEndpoint {
|
||||||
|
|
||||||
$this->failure_registry->clear_failures( FailureRegistry::SELLER_STATUS_KEY );
|
$this->failure_registry->clear_failures( FailureRegistry::SELLER_STATUS_KEY );
|
||||||
|
|
||||||
$status = $this->seller_status_factory->from_paypal_reponse( $json );
|
$status = $this->seller_status_factory->from_paypal_response( $json );
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,15 +28,23 @@ class SellerStatus {
|
||||||
*/
|
*/
|
||||||
private $capabilities;
|
private $capabilities;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merchant country on PayPal.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $country;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SellerStatus constructor.
|
* SellerStatus constructor.
|
||||||
*
|
*
|
||||||
* @param SellerStatusProduct[] $products The products.
|
* @param SellerStatusProduct[] $products The products.
|
||||||
* @param SellerStatusCapability[] $capabilities The capabilities.
|
* @param SellerStatusCapability[] $capabilities The capabilities.
|
||||||
|
* @param string $country Merchant country on PayPal.
|
||||||
*
|
*
|
||||||
* @psalm-suppress RedundantConditionGivenDocblockType
|
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||||
*/
|
*/
|
||||||
public function __construct( array $products, array $capabilities ) {
|
public function __construct( array $products, array $capabilities, string $country = '' ) {
|
||||||
foreach ( $products as $key => $product ) {
|
foreach ( $products as $key => $product ) {
|
||||||
if ( is_a( $product, SellerStatusProduct::class ) ) {
|
if ( is_a( $product, SellerStatusProduct::class ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -52,6 +60,7 @@ class SellerStatus {
|
||||||
|
|
||||||
$this->products = $products;
|
$this->products = $products;
|
||||||
$this->capabilities = $capabilities;
|
$this->capabilities = $capabilities;
|
||||||
|
$this->country = $country;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,6 +104,7 @@ class SellerStatus {
|
||||||
return array(
|
return array(
|
||||||
'products' => $products,
|
'products' => $products,
|
||||||
'capabilities' => $capabilities,
|
'capabilities' => $capabilities,
|
||||||
|
'country' => $this->country,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class SellerStatusFactory {
|
||||||
*
|
*
|
||||||
* @return SellerStatus
|
* @return SellerStatus
|
||||||
*/
|
*/
|
||||||
public function from_paypal_reponse( \stdClass $json ) : SellerStatus {
|
public function from_paypal_response( \stdClass $json ) : SellerStatus {
|
||||||
$products = array_map(
|
$products = array_map(
|
||||||
function( $json ) : SellerStatusProduct {
|
function( $json ) : SellerStatusProduct {
|
||||||
$product = new SellerStatusProduct(
|
$product = new SellerStatusProduct(
|
||||||
|
@ -49,6 +49,6 @@ class SellerStatusFactory {
|
||||||
isset( $json->capabilities ) ? (array) $json->capabilities : array()
|
isset( $json->capabilities ) ? (array) $json->capabilities : array()
|
||||||
);
|
);
|
||||||
|
|
||||||
return new SellerStatus( $products, $capabilities );
|
return new SellerStatus( $products, $capabilities, $json->country ?? '' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue