mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +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 );
|
||||
|
||||
$status = $this->seller_status_factory->from_paypal_reponse( $json );
|
||||
$status = $this->seller_status_factory->from_paypal_response( $json );
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,15 +28,23 @@ class SellerStatus {
|
|||
*/
|
||||
private $capabilities;
|
||||
|
||||
/**
|
||||
* Merchant country on PayPal.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $country;
|
||||
|
||||
/**
|
||||
* SellerStatus constructor.
|
||||
*
|
||||
* @param SellerStatusProduct[] $products The products.
|
||||
* @param SellerStatusCapability[] $capabilities The capabilities.
|
||||
* @param string $country Merchant country on PayPal.
|
||||
*
|
||||
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||
*/
|
||||
public function __construct( array $products, array $capabilities ) {
|
||||
public function __construct( array $products, array $capabilities, string $country = '' ) {
|
||||
foreach ( $products as $key => $product ) {
|
||||
if ( is_a( $product, SellerStatusProduct::class ) ) {
|
||||
continue;
|
||||
|
@ -52,6 +60,7 @@ class SellerStatus {
|
|||
|
||||
$this->products = $products;
|
||||
$this->capabilities = $capabilities;
|
||||
$this->country = $country;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,6 +104,7 @@ class SellerStatus {
|
|||
return array(
|
||||
'products' => $products,
|
||||
'capabilities' => $capabilities,
|
||||
'country' => $this->country,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class SellerStatusFactory {
|
|||
*
|
||||
* @return SellerStatus
|
||||
*/
|
||||
public function from_paypal_reponse( \stdClass $json ) : SellerStatus {
|
||||
public function from_paypal_response( \stdClass $json ) : SellerStatus {
|
||||
$products = array_map(
|
||||
function( $json ) : SellerStatusProduct {
|
||||
$product = new SellerStatusProduct(
|
||||
|
@ -49,6 +49,6 @@ class SellerStatusFactory {
|
|||
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