mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
method to check if PUI is ready in admin screen
This commit is contained in:
parent
396352775b
commit
10da1f8067
2 changed files with 42 additions and 1 deletions
|
@ -21,6 +21,32 @@ use WC_Product_Variation;
|
||||||
*/
|
*/
|
||||||
class PayUponInvoiceHelper {
|
class PayUponInvoiceHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The selected shop country.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $shop_country;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The PUI seller product status.
|
||||||
|
*
|
||||||
|
* @var PayUponInvoiceProductStatus
|
||||||
|
*/
|
||||||
|
protected $pui_product_status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PayUponInvoiceHelper constructor.
|
||||||
|
*
|
||||||
|
* @param string $shop_country The selected shop country.
|
||||||
|
* @param PayUponInvoiceProductStatus $pui_product_status The PUI seller product status.
|
||||||
|
*/
|
||||||
|
public function __construct( string $shop_country, PayUponInvoiceProductStatus $pui_product_status ) {
|
||||||
|
|
||||||
|
$this->shop_country = $shop_country;
|
||||||
|
$this->pui_product_status = $pui_product_status;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures date is valid and at least 18 years back.
|
* Ensures date is valid and at least 18 years back.
|
||||||
*
|
*
|
||||||
|
@ -137,4 +163,17 @@ class PayUponInvoiceHelper {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether PUI is ready in admin screen.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function is_pui_ready_in_admin(): bool {
|
||||||
|
if ( $this->pui_product_status->pui_is_active() && $this->shop_country === 'DE' ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||||
namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
|
namespace WooCommerce\PayPalCommerce\WcGateway\Helper;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use Mockery;
|
||||||
use WooCommerce\PayPalCommerce\TestCase;
|
use WooCommerce\PayPalCommerce\TestCase;
|
||||||
|
|
||||||
class PayUponInvoiceHelperTest extends TestCase
|
class PayUponInvoiceHelperTest extends TestCase
|
||||||
|
@ -13,7 +14,8 @@ class PayUponInvoiceHelperTest extends TestCase
|
||||||
*/
|
*/
|
||||||
public function testValidateBirthDate($input, $output)
|
public function testValidateBirthDate($input, $output)
|
||||||
{
|
{
|
||||||
$this->assertSame((new PayUponInvoiceHelper())->validate_birth_date($input), $output);
|
$pui_product_status = Mockery::mock(PayUponInvoiceProductStatus::class);
|
||||||
|
$this->assertSame((new PayUponInvoiceHelper('DE', $pui_product_status))->validate_birth_date($input), $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function datesProvider(): array{
|
public function datesProvider(): array{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue