mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Remove ApplicationContext
This commit is contained in:
parent
ab5ddd9fab
commit
da45fb1baf
23 changed files with 76 additions and 707 deletions
|
@ -73,7 +73,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Helper\OrderHelper;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\OrderTransient;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\PurchaseUnitSanitizer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\CustomerRepository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\OrderRepository;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\PartnerReferralsData;
|
||||
|
@ -253,7 +252,6 @@ return array(
|
|||
assert( $settings instanceof Settings );
|
||||
|
||||
$intent = $settings->has( 'intent' ) && strtoupper( (string) $settings->get( 'intent' ) ) === 'AUTHORIZE' ? 'AUTHORIZE' : 'CAPTURE';
|
||||
$application_context_repository = $container->get( 'api.repository.application-context' );
|
||||
$subscription_helper = $container->get( 'wc-subscriptions.helper' );
|
||||
return new OrderEndpoint(
|
||||
$container->get( 'api.host' ),
|
||||
|
@ -262,7 +260,6 @@ return array(
|
|||
$patch_collection_factory,
|
||||
$intent,
|
||||
$logger,
|
||||
$application_context_repository,
|
||||
$subscription_helper,
|
||||
$container->get( 'wcgateway.is-fraudnet-enabled' ),
|
||||
$container->get( 'wcgateway.fraudnet' ),
|
||||
|
@ -314,11 +311,6 @@ return array(
|
|||
$container->get( 'woocommerce.logger.woocommerce' )
|
||||
);
|
||||
},
|
||||
'api.repository.application-context' => static function( ContainerInterface $container ) : ApplicationContextRepository {
|
||||
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
return new ApplicationContextRepository( $settings );
|
||||
},
|
||||
'api.repository.partner-referrals-data' => static function ( ContainerInterface $container ) : PartnerReferralsData {
|
||||
|
||||
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
||||
|
@ -436,11 +428,9 @@ return array(
|
|||
'api.factory.order' => static function ( ContainerInterface $container ): OrderFactory {
|
||||
$purchase_unit_factory = $container->get( 'api.factory.purchase-unit' );
|
||||
$payer_factory = $container->get( 'api.factory.payer' );
|
||||
$application_context_repository = $container->get( 'api.repository.application-context' );
|
||||
return new OrderFactory(
|
||||
$purchase_unit_factory,
|
||||
$payer_factory,
|
||||
$application_context_repository
|
||||
$payer_factory
|
||||
);
|
||||
},
|
||||
'api.factory.payments' => static function ( ContainerInterface $container ): PaymentsFactory {
|
||||
|
|
|
@ -11,9 +11,9 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Endpoint;
|
|||
|
||||
use stdClass;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\AuthorizationStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection;
|
||||
|
@ -25,7 +25,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PatchCollectionFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\ErrorResponse;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\FraudNet\FraudNet;
|
||||
|
@ -87,13 +86,6 @@ class OrderEndpoint {
|
|||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* The application context repository.
|
||||
*
|
||||
* @var ApplicationContextRepository
|
||||
*/
|
||||
private $application_context_repository;
|
||||
|
||||
/**
|
||||
* True if FraudNet support is enabled in settings, otherwise false.
|
||||
*
|
||||
|
@ -118,17 +110,16 @@ class OrderEndpoint {
|
|||
/**
|
||||
* OrderEndpoint constructor.
|
||||
*
|
||||
* @param string $host The host.
|
||||
* @param Bearer $bearer The bearer.
|
||||
* @param OrderFactory $order_factory The order factory.
|
||||
* @param PatchCollectionFactory $patch_collection_factory The patch collection factory.
|
||||
* @param string $intent The intent.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param ApplicationContextRepository $application_context_repository The application context repository.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
* @param bool $is_fraudnet_enabled true if FraudNet support is enabled in settings, otherwise false.
|
||||
* @param FraudNet $fraudnet The FraudNet entity.
|
||||
* @param string $bn_code The BN Code.
|
||||
* @param string $host The host.
|
||||
* @param Bearer $bearer The bearer.
|
||||
* @param OrderFactory $order_factory The order factory.
|
||||
* @param PatchCollectionFactory $patch_collection_factory The patch collection factory.
|
||||
* @param string $intent The intent.
|
||||
* @param LoggerInterface $logger The logger.
|
||||
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
||||
* @param bool $is_fraudnet_enabled true if FraudNet support is enabled in settings, otherwise false.
|
||||
* @param FraudNet $fraudnet The FraudNet entity.
|
||||
* @param string $bn_code The BN Code.
|
||||
*/
|
||||
public function __construct(
|
||||
string $host,
|
||||
|
@ -137,24 +128,22 @@ class OrderEndpoint {
|
|||
PatchCollectionFactory $patch_collection_factory,
|
||||
string $intent,
|
||||
LoggerInterface $logger,
|
||||
ApplicationContextRepository $application_context_repository,
|
||||
SubscriptionHelper $subscription_helper,
|
||||
bool $is_fraudnet_enabled,
|
||||
FraudNet $fraudnet,
|
||||
string $bn_code = ''
|
||||
) {
|
||||
|
||||
$this->host = $host;
|
||||
$this->bearer = $bearer;
|
||||
$this->order_factory = $order_factory;
|
||||
$this->patch_collection_factory = $patch_collection_factory;
|
||||
$this->intent = $intent;
|
||||
$this->logger = $logger;
|
||||
$this->application_context_repository = $application_context_repository;
|
||||
$this->bn_code = $bn_code;
|
||||
$this->is_fraudnet_enabled = $is_fraudnet_enabled;
|
||||
$this->subscription_helper = $subscription_helper;
|
||||
$this->fraudnet = $fraudnet;
|
||||
$this->host = $host;
|
||||
$this->bearer = $bearer;
|
||||
$this->order_factory = $order_factory;
|
||||
$this->patch_collection_factory = $patch_collection_factory;
|
||||
$this->intent = $intent;
|
||||
$this->logger = $logger;
|
||||
$this->bn_code = $bn_code;
|
||||
$this->is_fraudnet_enabled = $is_fraudnet_enabled;
|
||||
$this->subscription_helper = $subscription_helper;
|
||||
$this->fraudnet = $fraudnet;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,9 +164,8 @@ class OrderEndpoint {
|
|||
* Creates an order.
|
||||
*
|
||||
* @param PurchaseUnit[] $items The purchase unit items for the order.
|
||||
* @param string $shipping_preference One of ApplicationContext::SHIPPING_PREFERENCE_ values.
|
||||
* @param string $shipping_preference One of ExperienceContext::SHIPPING_PREFERENCE_ values.
|
||||
* @param Payer|null $payer The payer off the order.
|
||||
* @param string $user_action The user action.
|
||||
* @param string $payment_method WC payment method.
|
||||
* @param array $request_data Request data.
|
||||
* @param PaymentSource|null $payment_source The payment source.
|
||||
|
@ -189,7 +177,6 @@ class OrderEndpoint {
|
|||
array $items,
|
||||
string $shipping_preference,
|
||||
Payer $payer = null,
|
||||
string $user_action = ApplicationContext::USER_ACTION_CONTINUE,
|
||||
string $payment_method = '',
|
||||
array $request_data = array(),
|
||||
PaymentSource $payment_source = null
|
||||
|
@ -201,7 +188,7 @@ class OrderEndpoint {
|
|||
static function ( PurchaseUnit $item ) use ( $shipping_preference ): array {
|
||||
$data = $item->to_array();
|
||||
|
||||
if ( $shipping_preference !== ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE ) {
|
||||
if ( $shipping_preference !== ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE ) {
|
||||
// Shipping options are not allowed to be sent when not getting the address from PayPal.
|
||||
unset( $data['shipping']['options'] );
|
||||
}
|
||||
|
|
|
@ -1,252 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* The application context object.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\ApiClient\Entity
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
|
||||
/**
|
||||
* Class ApplicationContext
|
||||
*/
|
||||
class ApplicationContext {
|
||||
|
||||
const LANDING_PAGE_LOGIN = 'LOGIN';
|
||||
const LANDING_PAGE_BILLING = 'BILLING';
|
||||
const LANDING_PAGE_NO_PREFERENCE = 'NO_PREFERENCE';
|
||||
const VALID_LANDING_PAGE_VALUES = array(
|
||||
self::LANDING_PAGE_LOGIN,
|
||||
self::LANDING_PAGE_BILLING,
|
||||
self::LANDING_PAGE_NO_PREFERENCE,
|
||||
);
|
||||
|
||||
const SHIPPING_PREFERENCE_GET_FROM_FILE = 'GET_FROM_FILE';
|
||||
const SHIPPING_PREFERENCE_NO_SHIPPING = 'NO_SHIPPING';
|
||||
const SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS = 'SET_PROVIDED_ADDRESS';
|
||||
const VALID_SHIPPING_PREFERENCE_VALUES = array(
|
||||
self::SHIPPING_PREFERENCE_GET_FROM_FILE,
|
||||
self::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
self::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS,
|
||||
);
|
||||
|
||||
const USER_ACTION_CONTINUE = 'CONTINUE';
|
||||
const USER_ACTION_PAY_NOW = 'PAY_NOW';
|
||||
const VALID_USER_ACTION_VALUES = array(
|
||||
self::USER_ACTION_CONTINUE,
|
||||
self::USER_ACTION_PAY_NOW,
|
||||
);
|
||||
|
||||
const PAYMENT_METHOD_UNRESTRICTED = 'UNRESTRICTED';
|
||||
const PAYMENT_METHOD_IMMEDIATE_PAYMENT_REQUIRED = 'IMMEDIATE_PAYMENT_REQUIRED';
|
||||
|
||||
/**
|
||||
* The brand name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $brand_name;
|
||||
|
||||
/**
|
||||
* The locale.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $locale;
|
||||
|
||||
/**
|
||||
* The landing page.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $landing_page;
|
||||
|
||||
/**
|
||||
* The shipping preference.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $shipping_preference;
|
||||
|
||||
/**
|
||||
* The user action.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $user_action;
|
||||
|
||||
/**
|
||||
* The return url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $return_url;
|
||||
|
||||
/**
|
||||
* The cancel url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cancel_url;
|
||||
|
||||
/**
|
||||
* The payment method preference.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $payment_method_preference;
|
||||
|
||||
/**
|
||||
* ApplicationContext constructor.
|
||||
*
|
||||
* @param string $return_url The return URL.
|
||||
* @param string $cancel_url The cancel URL.
|
||||
* @param string $brand_name The brand name.
|
||||
* @param string $locale The locale.
|
||||
* @param string $landing_page The landing page.
|
||||
* @param string $shipping_preference The shipping preference.
|
||||
* @param string $user_action The user action.
|
||||
* @param string $payment_method_preference The payment method preference.
|
||||
*
|
||||
* @throws RuntimeException When values are not valid.
|
||||
*/
|
||||
public function __construct(
|
||||
string $return_url = '',
|
||||
string $cancel_url = '',
|
||||
string $brand_name = '',
|
||||
string $locale = '',
|
||||
string $landing_page = self::LANDING_PAGE_NO_PREFERENCE,
|
||||
string $shipping_preference = self::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
string $user_action = self::USER_ACTION_CONTINUE,
|
||||
string $payment_method_preference = self::PAYMENT_METHOD_IMMEDIATE_PAYMENT_REQUIRED
|
||||
) {
|
||||
|
||||
if ( ! in_array( $landing_page, self::VALID_LANDING_PAGE_VALUES, true ) ) {
|
||||
throw new RuntimeException( 'Landingpage not correct' );
|
||||
}
|
||||
if ( ! in_array( $shipping_preference, self::VALID_SHIPPING_PREFERENCE_VALUES, true ) ) {
|
||||
throw new RuntimeException( 'Shipping preference not correct' );
|
||||
}
|
||||
if ( ! in_array( $user_action, self::VALID_USER_ACTION_VALUES, true ) ) {
|
||||
throw new RuntimeException( 'User action preference not correct' );
|
||||
}
|
||||
$this->return_url = $return_url;
|
||||
$this->cancel_url = $cancel_url;
|
||||
$this->brand_name = $brand_name;
|
||||
$this->locale = $locale;
|
||||
$this->landing_page = $landing_page;
|
||||
$this->shipping_preference = $shipping_preference;
|
||||
$this->user_action = $user_action;
|
||||
$this->payment_method_preference = $payment_method_preference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the brand name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function brand_name(): string {
|
||||
return $this->brand_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function locale(): string {
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the landing page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function landing_page(): string {
|
||||
return $this->landing_page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shipping preference.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function shipping_preference(): string {
|
||||
return $this->shipping_preference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user action.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function user_action(): string {
|
||||
return $this->user_action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the return URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function return_url(): string {
|
||||
return $this->return_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cancel URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function cancel_url(): string {
|
||||
return $this->cancel_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the payment method preference.
|
||||
*/
|
||||
public function payment_method_preference(): string {
|
||||
return $this->payment_method_preference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object as array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function to_array(): array {
|
||||
$data = array();
|
||||
if ( $this->user_action() ) {
|
||||
$data['user_action'] = $this->user_action();
|
||||
}
|
||||
if ( $this->shipping_preference() ) {
|
||||
$data['shipping_preference'] = $this->shipping_preference();
|
||||
}
|
||||
if ( $this->landing_page() ) {
|
||||
$data['landing_page'] = $this->landing_page();
|
||||
}
|
||||
if ( $this->locale() ) {
|
||||
$data['locale'] = $this->locale();
|
||||
}
|
||||
if ( $this->brand_name() ) {
|
||||
$data['brand_name'] = $this->brand_name();
|
||||
}
|
||||
if ( $this->return_url() ) {
|
||||
$data['return_url'] = $this->return_url();
|
||||
}
|
||||
if ( $this->cancel_url() ) {
|
||||
$data['cancel_url'] = $this->cancel_url();
|
||||
}
|
||||
if ( $this->payment_method_preference ) {
|
||||
$data['payment_method'] = array(
|
||||
'payee_preferred' => $this->payment_method_preference,
|
||||
);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -64,13 +64,6 @@ class Order {
|
|||
*/
|
||||
private $update_time;
|
||||
|
||||
/**
|
||||
* The application context.
|
||||
*
|
||||
* @var ApplicationContext|null
|
||||
*/
|
||||
private $application_context;
|
||||
|
||||
/**
|
||||
* The payment source.
|
||||
*
|
||||
|
@ -83,21 +76,19 @@ class Order {
|
|||
*
|
||||
* @see https://developer.paypal.com/docs/api/orders/v2/#orders-create-response
|
||||
*
|
||||
* @param string $id The ID.
|
||||
* @param PurchaseUnit[] $purchase_units The purchase units.
|
||||
* @param OrderStatus $order_status The order status.
|
||||
* @param ApplicationContext|null $application_context The application context.
|
||||
* @param PaymentSource|null $payment_source The payment source.
|
||||
* @param Payer|null $payer The payer.
|
||||
* @param string $intent The intent.
|
||||
* @param \DateTime|null $create_time The create time.
|
||||
* @param \DateTime|null $update_time The update time.
|
||||
* @param string $id The ID.
|
||||
* @param PurchaseUnit[] $purchase_units The purchase units.
|
||||
* @param OrderStatus $order_status The order status.
|
||||
* @param PaymentSource|null $payment_source The payment source.
|
||||
* @param Payer|null $payer The payer.
|
||||
* @param string $intent The intent.
|
||||
* @param \DateTime|null $create_time The create time.
|
||||
* @param \DateTime|null $update_time The update time.
|
||||
*/
|
||||
public function __construct(
|
||||
string $id,
|
||||
array $purchase_units,
|
||||
OrderStatus $order_status,
|
||||
ApplicationContext $application_context = null,
|
||||
PaymentSource $payment_source = null,
|
||||
Payer $payer = null,
|
||||
string $intent = 'CAPTURE',
|
||||
|
@ -105,15 +96,14 @@ class Order {
|
|||
\DateTime $update_time = null
|
||||
) {
|
||||
|
||||
$this->id = $id;
|
||||
$this->application_context = $application_context;
|
||||
$this->payer = $payer;
|
||||
$this->order_status = $order_status;
|
||||
$this->intent = ( 'CAPTURE' === $intent ) ? 'CAPTURE' : 'AUTHORIZE';
|
||||
$this->purchase_units = $purchase_units;
|
||||
$this->create_time = $create_time;
|
||||
$this->update_time = $update_time;
|
||||
$this->payment_source = $payment_source;
|
||||
$this->id = $id;
|
||||
$this->payer = $payer;
|
||||
$this->order_status = $order_status;
|
||||
$this->intent = ( 'CAPTURE' === $intent ) ? 'CAPTURE' : 'AUTHORIZE';
|
||||
$this->purchase_units = $purchase_units;
|
||||
$this->create_time = $create_time;
|
||||
$this->update_time = $update_time;
|
||||
$this->payment_source = $payment_source;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,16 +169,6 @@ class Order {
|
|||
return $this->order_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the application context.
|
||||
*
|
||||
* @return ApplicationContext|null
|
||||
*/
|
||||
public function application_context() {
|
||||
|
||||
return $this->application_context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the payment source.
|
||||
*
|
||||
|
@ -225,9 +205,6 @@ class Order {
|
|||
if ( $this->update_time() ) {
|
||||
$order['update_time'] = $this->update_time()->format( 'Y-m-d\TH:i:sO' );
|
||||
}
|
||||
if ( $this->application_context() ) {
|
||||
$order['application_context'] = $this->application_context()->to_array();
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentSource;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
|
||||
|
||||
/**
|
||||
* Class OrderFactory
|
||||
|
@ -65,7 +64,6 @@ class OrderFactory {
|
|||
$order->id(),
|
||||
$purchase_units,
|
||||
$order->status(),
|
||||
$order->application_context(),
|
||||
$order->payment_source(),
|
||||
$order->payer(),
|
||||
$order->intent(),
|
||||
|
@ -142,7 +140,6 @@ class OrderFactory {
|
|||
$order_data->id,
|
||||
$purchase_units,
|
||||
new OrderStatus( $order_data->status ),
|
||||
null,
|
||||
$payment_source,
|
||||
$payer,
|
||||
$order_data->intent,
|
||||
|
|
|
@ -10,7 +10,7 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
||||
|
||||
use WC_Cart;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ class ShippingPreferenceFactory {
|
|||
): string {
|
||||
$contains_physical_goods = $purchase_unit->contains_physical_goods();
|
||||
if ( ! $contains_physical_goods ) {
|
||||
return ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
}
|
||||
|
||||
$has_shipping = null !== $purchase_unit->shipping();
|
||||
|
@ -45,20 +45,20 @@ class ShippingPreferenceFactory {
|
|||
if ( $shipping_address_is_fixed ) {
|
||||
// Checkout + no address given? Probably something weird happened, like no form validation?
|
||||
if ( ! $has_shipping ) {
|
||||
return ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
}
|
||||
|
||||
return ApplicationContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS;
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS;
|
||||
}
|
||||
|
||||
if ( 'card' === $funding_source ) {
|
||||
if ( ! $has_shipping ) {
|
||||
return ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING;
|
||||
}
|
||||
// Looks like GET_FROM_FILE does not work for the vaulted card button.
|
||||
return ApplicationContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS;
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS;
|
||||
}
|
||||
|
||||
return ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE;
|
||||
return ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Returns the current application context.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\ApiClient\Repository
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Repository;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Endpoint\ReturnUrlEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class ApplicationContextRepository
|
||||
*/
|
||||
class ApplicationContextRepository {
|
||||
|
||||
/**
|
||||
* The Settings.
|
||||
*
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* ApplicationContextRepository constructor.
|
||||
*
|
||||
* @param ContainerInterface $settings The settings.
|
||||
*/
|
||||
public function __construct( ContainerInterface $settings ) {
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current application context.
|
||||
*
|
||||
* @param string $shipping_preferences The shipping preferences.
|
||||
* @param string $user_action The user action.
|
||||
*
|
||||
* @return ApplicationContext
|
||||
*/
|
||||
public function current_context(
|
||||
string $shipping_preferences = ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
string $user_action = ApplicationContext::USER_ACTION_CONTINUE
|
||||
): ApplicationContext {
|
||||
|
||||
$brand_name = $this->settings->has( 'brand_name' ) ? $this->settings->get( 'brand_name' ) : '';
|
||||
$locale = $this->valid_bcp47_code();
|
||||
$landingpage = $this->settings->has( 'landing_page' ) ?
|
||||
$this->settings->get( 'landing_page' ) : ApplicationContext::LANDING_PAGE_NO_PREFERENCE;
|
||||
$payment_preference = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ?
|
||||
ApplicationContext::PAYMENT_METHOD_IMMEDIATE_PAYMENT_REQUIRED : ApplicationContext::PAYMENT_METHOD_UNRESTRICTED;
|
||||
$context = new ApplicationContext(
|
||||
home_url( \WC_AJAX::get_endpoint( ReturnUrlEndpoint::ENDPOINT ) ),
|
||||
(string) wc_get_checkout_url(),
|
||||
(string) $brand_name,
|
||||
$locale,
|
||||
(string) $landingpage,
|
||||
$shipping_preferences,
|
||||
$user_action,
|
||||
$payment_preference
|
||||
);
|
||||
return $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PayPal-supported BCP-47 code, for example de-DE-formal becomes de-DE.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function valid_bcp47_code() {
|
||||
$locale = str_replace( '_', '-', get_user_locale() );
|
||||
|
||||
if ( preg_match( '/^[a-z]{2}(?:-[A-Z][a-z]{3})?(?:-(?:[A-Z]{2}))?$/', $locale ) ) {
|
||||
return $locale;
|
||||
}
|
||||
|
||||
$parts = explode( '-', $locale );
|
||||
if ( count( $parts ) === 3 ) {
|
||||
$ret = substr( $locale, 0, strrpos( $locale, '-' ) );
|
||||
if ( false !== $ret ) {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 'en';
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ use Exception;
|
|||
use WC_Order;
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentSource;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ShippingPreferenceFactory;
|
||||
|
@ -307,7 +306,6 @@ class AxoGateway extends WC_Payment_Gateway {
|
|||
array( $purchase_unit ),
|
||||
$shipping_preference,
|
||||
null,
|
||||
ApplicationContext::USER_ACTION_CONTINUE,
|
||||
'',
|
||||
array(),
|
||||
$payment_source
|
||||
|
|
|
@ -15,7 +15,7 @@ use stdClass;
|
|||
use Throwable;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Amount;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Money;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
||||
|
@ -464,16 +464,16 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
);
|
||||
|
||||
$action = in_array( $this->parsed_request_data['context'], $this->pay_now_contexts, true ) ?
|
||||
ApplicationContext::USER_ACTION_PAY_NOW : ApplicationContext::USER_ACTION_CONTINUE;
|
||||
ExperienceContext::USER_ACTION_PAY_NOW : ExperienceContext::USER_ACTION_CONTINUE;
|
||||
|
||||
if ( 'card' === $funding_source ) {
|
||||
if ( CardBillingMode::MINIMAL_INPUT === $this->card_billing_data_mode ) {
|
||||
if ( ApplicationContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS === $shipping_preference ) {
|
||||
if ( ExperienceContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS === $shipping_preference ) {
|
||||
if ( $payer ) {
|
||||
$payer->set_address( null );
|
||||
}
|
||||
}
|
||||
if ( ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING === $shipping_preference ) {
|
||||
if ( ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING === $shipping_preference ) {
|
||||
if ( $payer ) {
|
||||
$payer->set_name( null );
|
||||
}
|
||||
|
@ -499,7 +499,6 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
array( $this->purchase_unit ),
|
||||
$shipping_preference,
|
||||
$payer,
|
||||
$action,
|
||||
$payment_method,
|
||||
$data,
|
||||
$payment_source
|
||||
|
@ -523,7 +522,6 @@ class CreateOrderEndpoint implements EndpointInterface {
|
|||
array( $this->purchase_unit ),
|
||||
$shipping_preference,
|
||||
$payer,
|
||||
$action,
|
||||
$payment_method,
|
||||
$data,
|
||||
$payment_source
|
||||
|
|
|
@ -9,7 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\Compat\Settings;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\PurchaseUnitSanitizer;
|
||||
use WooCommerce\PayPalCommerce\Button\Helper\ContextTrait;
|
||||
|
||||
|
@ -104,10 +104,10 @@ class SettingsTabMapHelper {
|
|||
}
|
||||
|
||||
return $landing_page === 'login'
|
||||
? ApplicationContext::LANDING_PAGE_LOGIN
|
||||
? ExperienceContext::LANDING_PAGE_LOGIN
|
||||
: ( $landing_page === 'guest_checkout'
|
||||
? ApplicationContext::LANDING_PAGE_BILLING
|
||||
: ApplicationContext::LANDING_PAGE_NO_PREFERENCE
|
||||
? ExperienceContext::LANDING_PAGE_GUEST_CHECKOUT
|
||||
: ExperienceContext::LANDING_PAGE_NO_PREFERENCE
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\Vaulting;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WC_Customer;
|
||||
use WC_Order;
|
||||
|
@ -168,7 +167,6 @@ class VaultedCreditCardHandler {
|
|||
array( $purchase_unit ),
|
||||
$shipping_preference,
|
||||
$payer,
|
||||
ApplicationContext::USER_ACTION_CONTINUE,
|
||||
'',
|
||||
array(),
|
||||
$selected_token->to_payment_source()
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway;
|
|||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\BillingAgreementsEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
||||
|
@ -875,15 +875,15 @@ return array(
|
|||
'type' => 'select',
|
||||
'class' => array(),
|
||||
'input_class' => array( 'wc-enhanced-select' ),
|
||||
'default' => ApplicationContext::LANDING_PAGE_LOGIN,
|
||||
'default' => ExperienceContext::LANDING_PAGE_LOGIN,
|
||||
'desc_tip' => true,
|
||||
'description' => __(
|
||||
'Type of PayPal page to display.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
'options' => array(
|
||||
ApplicationContext::LANDING_PAGE_LOGIN => __( 'Login (PayPal account login)', 'woocommerce-paypal-payments' ),
|
||||
ApplicationContext::LANDING_PAGE_BILLING => __( 'Billing (Non-PayPal account)', 'woocommerce-paypal-payments' ),
|
||||
ExperienceContext::LANDING_PAGE_LOGIN => __( 'Login (PayPal account login)', 'woocommerce-paypal-payments' ),
|
||||
ExperienceContext::LANDING_PAGE_GUEST_CHECKOUT => __( 'Billing (Non-PayPal account)', 'woocommerce-paypal-payments' ),
|
||||
),
|
||||
'screens' => array(
|
||||
State::STATE_START,
|
||||
|
|
|
@ -13,7 +13,6 @@ use Psr\Log\LoggerInterface;
|
|||
use WC_Order;
|
||||
use WC_Payment_Gateway;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentSource;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
|
@ -200,7 +199,6 @@ class OXXOGateway extends WC_Payment_Gateway {
|
|||
array( $purchase_unit ),
|
||||
$shipping_preference,
|
||||
null,
|
||||
ApplicationContext::USER_ACTION_CONTINUE,
|
||||
'',
|
||||
array(),
|
||||
new PaymentSource(
|
||||
|
|
|
@ -13,7 +13,6 @@ use Exception;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use WC_Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
|
@ -328,7 +327,6 @@ class OrderProcessor {
|
|||
array( $pu ),
|
||||
$shipping_preference,
|
||||
$this->payer_factory->from_wc_order( $wc_order ),
|
||||
ApplicationContext::USER_ACTION_PAY_NOW,
|
||||
'',
|
||||
array(),
|
||||
new PaymentSource(
|
||||
|
|
|
@ -15,7 +15,6 @@ use WC_Payment_Tokens;
|
|||
use WC_Subscription;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentTokensEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentSource;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
||||
|
@ -353,7 +352,6 @@ class RenewalHandler {
|
|||
array( $purchase_unit ),
|
||||
$shipping_preference,
|
||||
$payer,
|
||||
ApplicationContext::USER_ACTION_CONTINUE,
|
||||
'',
|
||||
array(),
|
||||
$payment_source
|
||||
|
@ -395,7 +393,6 @@ class RenewalHandler {
|
|||
array( $purchase_unit ),
|
||||
$shipping_preference,
|
||||
$payer,
|
||||
ApplicationContext::USER_ACTION_CONTINUE,
|
||||
'',
|
||||
array(),
|
||||
$payment_source
|
||||
|
@ -418,7 +415,6 @@ class RenewalHandler {
|
|||
array( $purchase_unit ),
|
||||
$shipping_preference,
|
||||
$payer,
|
||||
ApplicationContext::USER_ACTION_CONTINUE,
|
||||
'',
|
||||
array(),
|
||||
$token->to_payment_source()
|
||||
|
|
|
@ -7,9 +7,9 @@ use Hamcrest\Matchers;
|
|||
use Requests_Utility_CaseInsensitiveDictionary;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Address;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection;
|
||||
|
@ -23,7 +23,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PatchCollectionFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\ErrorResponse;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
|
||||
use Mockery;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcSubscriptions\Helper\SubscriptionHelper;
|
||||
|
@ -66,7 +65,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
@ -80,7 +78,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -127,7 +124,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
@ -141,7 +137,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -181,7 +176,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -193,7 +187,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -247,7 +240,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -259,7 +251,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -316,7 +307,6 @@ class OrderEndpointTest extends TestCase
|
|||
|
||||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -328,7 +318,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -361,7 +350,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -373,7 +361,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -413,7 +400,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -425,7 +411,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -467,7 +452,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -481,7 +465,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -547,7 +530,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -561,7 +543,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -649,7 +630,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -661,7 +641,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -745,7 +724,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger->shouldReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -759,7 +737,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -820,7 +797,6 @@ class OrderEndpointTest extends TestCase
|
|||
|
||||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
|
||||
$fraudnet = Mockery::mock(FraudNet::class);
|
||||
|
@ -832,7 +808,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -875,15 +850,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContext = Mockery::mock(ApplicationContext::class);
|
||||
$applicationContext
|
||||
->expects('to_array')
|
||||
->andReturn(['applicationContext']);
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$applicationContextRepository
|
||||
->expects('current_context')
|
||||
->with(ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING, ApplicationContext::USER_ACTION_CONTINUE)
|
||||
->andReturn($applicationContext);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -896,7 +862,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -941,7 +906,7 @@ class OrderEndpointTest extends TestCase
|
|||
->expects('email_address')
|
||||
->andReturn('');
|
||||
|
||||
$result = $testee->create([$purchaseUnit], ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING, $payer);
|
||||
$result = $testee->create([$purchaseUnit], ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING, $payer);
|
||||
$this->assertEquals($expectedOrder, $result);
|
||||
}
|
||||
|
||||
|
@ -978,15 +943,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContext = Mockery::mock(ApplicationContext::class);
|
||||
$applicationContext
|
||||
->expects('to_array')
|
||||
->andReturn(['applicationContext']);
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$applicationContextRepository
|
||||
->expects('current_context')
|
||||
->with(ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE, ApplicationContext::USER_ACTION_CONTINUE)
|
||||
->andReturn($applicationContext);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -999,7 +955,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -1030,7 +985,7 @@ class OrderEndpointTest extends TestCase
|
|||
$payer = Mockery::mock(Payer::class);
|
||||
$payer->expects('email_address')->andReturn('email@email.com');
|
||||
$payer->expects('to_array')->andReturn(['payer']);
|
||||
$result = $testee->create([$purchaseUnit], ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE, $payer);
|
||||
$result = $testee->create([$purchaseUnit], ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE, $payer);
|
||||
$this->assertEquals($expectedOrder, $result);
|
||||
}
|
||||
|
||||
|
@ -1058,15 +1013,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('warning');
|
||||
$logger->shouldReceive('debug');
|
||||
$applicationContext = Mockery::mock(ApplicationContext::class);
|
||||
$applicationContext
|
||||
->expects('to_array')
|
||||
->andReturn(['applicationContext']);
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$applicationContextRepository
|
||||
->expects('current_context')
|
||||
->with(ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING, ApplicationContext::USER_ACTION_CONTINUE)
|
||||
->andReturn($applicationContext);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -1079,7 +1025,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -1122,7 +1067,7 @@ class OrderEndpointTest extends TestCase
|
|||
$payer = Mockery::mock(Payer::class);
|
||||
$payer->expects('email_address')->andReturn('email@email.com');
|
||||
$payer->expects('to_array')->andReturn(['payer']);
|
||||
$testee->create([$purchaseUnit], ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING, $payer);
|
||||
$testee->create([$purchaseUnit], ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING, $payer);
|
||||
}
|
||||
|
||||
public function testCreateForPurchaseUnitsIsNot201()
|
||||
|
@ -1149,15 +1094,6 @@ class OrderEndpointTest extends TestCase
|
|||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('debug');
|
||||
$logger->shouldReceive('warning');
|
||||
$applicationContext = Mockery::mock(ApplicationContext::class);
|
||||
$applicationContext
|
||||
->expects('to_array')
|
||||
->andReturn(['applicationContext']);
|
||||
$applicationContextRepository = Mockery::mock(ApplicationContextRepository::class);
|
||||
$applicationContextRepository
|
||||
->expects('current_context')
|
||||
->with(ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE, ApplicationContext::USER_ACTION_CONTINUE)
|
||||
->andReturn($applicationContext);
|
||||
$subscription_helper = Mockery::mock(SubscriptionHelper::class);
|
||||
$subscription_helper->shouldReceive('cart_contains_subscription')->andReturn(true);
|
||||
|
||||
|
@ -1170,7 +1106,6 @@ class OrderEndpointTest extends TestCase
|
|||
$patchCollectionFactory,
|
||||
$intent,
|
||||
$logger,
|
||||
$applicationContextRepository,
|
||||
$subscription_helper,
|
||||
false,
|
||||
$fraudnet
|
||||
|
@ -1213,7 +1148,7 @@ class OrderEndpointTest extends TestCase
|
|||
$payer = Mockery::mock(Payer::class);
|
||||
$payer->expects('email_address')->andReturn('email@email.com');
|
||||
$payer->expects('to_array')->andReturn(['payer']);
|
||||
$testee->create([$purchaseUnit], ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE, $payer);
|
||||
$testee->create([$purchaseUnit], ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE, $payer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Endpoint;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
||||
|
@ -29,17 +28,12 @@ class OrderTest extends TestCase
|
|||
$payer
|
||||
->expects('to_array')->andReturn(['payer']);
|
||||
$intent = 'AUTHORIZE';
|
||||
$applicationContext = Mockery::mock(ApplicationContext::class);
|
||||
$applicationContext
|
||||
->expects('to_array')
|
||||
->andReturn(['applicationContext']);
|
||||
$paymentSource = Mockery::mock(PaymentSource::class);
|
||||
|
||||
$testee = new Order(
|
||||
$id,
|
||||
[$unit],
|
||||
$status,
|
||||
$applicationContext,
|
||||
$paymentSource,
|
||||
$payer,
|
||||
$intent,
|
||||
|
@ -65,7 +59,6 @@ class OrderTest extends TestCase
|
|||
'create_time' => $createTime->format($this->dateFormat),
|
||||
'update_time' => $updateTime->format($this->dateFormat),
|
||||
'payer' => ['payer'],
|
||||
'application_context' => ['applicationContext']
|
||||
];
|
||||
$this->assertEquals($expected, $testee->to_array());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
use Mockery;
|
||||
|
||||
|
@ -28,7 +27,6 @@ class OrderFactoryTest extends TestCase
|
|||
$order->expects('intent')->andReturn('intent');
|
||||
$order->expects('create_time')->andReturn($createTime);
|
||||
$order->expects('update_time')->andReturn($updateTime);
|
||||
$order->expects('application_context')->andReturnNull();
|
||||
$order->expects('payment_source')->andReturnNull();
|
||||
$wcOrder = Mockery::mock(\WC_Order::class);
|
||||
$purchaseUnitFactory = Mockery::mock(PurchaseUnitFactory::class);
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
|
|||
|
||||
use Mockery;
|
||||
use WC_Cart;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ExperienceContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Shipping;
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
|
@ -43,63 +43,63 @@ class ShippingPreferenceFactoryTest extends TestCase
|
|||
'checkout',
|
||||
$this->createCart(true),
|
||||
'',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(false, Mockery::mock(Shipping::class)),
|
||||
'checkout',
|
||||
$this->createCart(false),
|
||||
'',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(true, null),
|
||||
'checkout',
|
||||
$this->createCart(true),
|
||||
'',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(true, Mockery::mock(Shipping::class)),
|
||||
'checkout',
|
||||
$this->createCart(true),
|
||||
'card',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(true, null),
|
||||
'product',
|
||||
null,
|
||||
'',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(true, null),
|
||||
'pay-now',
|
||||
null,
|
||||
'venmo',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(true, Mockery::mock(Shipping::class)),
|
||||
'pay-now',
|
||||
null,
|
||||
'venmo',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_GET_FROM_FILE,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_GET_FROM_FILE,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(true, Mockery::mock(Shipping::class)),
|
||||
'pay-now',
|
||||
null,
|
||||
'card',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_SET_PROVIDED_ADDRESS,
|
||||
];
|
||||
yield [
|
||||
$this->createPurchaseUnit(true, null),
|
||||
'pay-now',
|
||||
null,
|
||||
'card',
|
||||
ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
ExperienceContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\ApiClient\Repository;
|
||||
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
use function Brain\Monkey\Functions\when;
|
||||
|
||||
class ApplicationContextRepositoryTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*/
|
||||
public function test_valid_bcp47_code($input, $output)
|
||||
{
|
||||
$testee = $this->getMockBuilder(ApplicationContextRepository::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$method = new \ReflectionMethod($testee, 'valid_bcp47_code');
|
||||
$method->setAccessible(true);
|
||||
|
||||
when('get_user_locale')->justReturn($input);
|
||||
|
||||
$this->assertSame($output, $method->invoke($testee));
|
||||
}
|
||||
|
||||
public function provider()
|
||||
{
|
||||
return [
|
||||
'de-DE' => ['de-DE', 'de-DE'],
|
||||
'de-DE-formal' => ['de-DE-formal', 'de-DE'],
|
||||
'de' => ['de', 'de'],
|
||||
'ceb' => ['ceb', 'en'],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -125,7 +125,7 @@ class VaultedCreditCardHandlerTest extends TestCase
|
|||
$purchaseUnit->shouldReceive('payments')->andReturn($payments);
|
||||
|
||||
$this->orderEndpoint->shouldReceive('create')
|
||||
->with([$purchaseUnit], 'some_preference', $payer, 'CONTINUE', '', array(), $requestPaymentSource)
|
||||
->with([$purchaseUnit], 'some_preference', $payer, '', array(), $requestPaymentSource)
|
||||
->andReturn($order);
|
||||
|
||||
$this->environment->shouldReceive('current_environment_is')->andReturn(true);
|
||||
|
|
|
@ -114,7 +114,7 @@ private $testee;
|
|||
|
||||
$this->orderEndpoint
|
||||
->shouldReceive('create')
|
||||
->with([$purchaseUnit], $shippingPreference, null, 'CONTINUE', '', [], Mockery::any())
|
||||
->with([$purchaseUnit], $shippingPreference, null, '', [], Mockery::any())
|
||||
->andReturn($order);
|
||||
|
||||
$this->wcOrder
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\WcGateway\Repository;
|
||||
|
||||
use Hamcrest\Matchers;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\ApplicationContextRepository;
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
use Mockery\MockInterface;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use function Brain\Monkey\Functions\expect;
|
||||
|
||||
class ApplicationContextRepositoryTest extends TestCase
|
||||
{
|
||||
private static $mocks = [];
|
||||
|
||||
/**
|
||||
* @dataProvider currentContextData
|
||||
*/
|
||||
public function testCurrentContext(
|
||||
array $container,
|
||||
string $userLocale,
|
||||
string $shippingPreference,
|
||||
array $expected
|
||||
): void
|
||||
{
|
||||
// Config
|
||||
foreach ($container as $key => $value) {
|
||||
$this->buildTestee()[0]->shouldReceive('has')
|
||||
->with(Matchers::identicalTo($key))
|
||||
->andReturn(true);
|
||||
$this->buildTestee()[0]->shouldReceive('get')
|
||||
->with(Matchers::identicalTo($key))
|
||||
->andReturn($value);
|
||||
}
|
||||
|
||||
expect('home_url')
|
||||
->andReturn('https://example.com/');
|
||||
expect('wc_get_checkout_url')
|
||||
->andReturn('https://example.com/checkout/');
|
||||
|
||||
expect('get_user_locale')
|
||||
->andReturn($userLocale);
|
||||
|
||||
/* @var ApplicationContextRepository $testee */
|
||||
$testee = $this->buildTestee()[1];
|
||||
|
||||
$context = $testee->current_context($shippingPreference);
|
||||
|
||||
self::assertInstanceOf(
|
||||
ApplicationContext::class,
|
||||
$context
|
||||
);
|
||||
|
||||
foreach ($expected as $method => $value) {
|
||||
self::assertSame(
|
||||
$value,
|
||||
$context->{$method}(),
|
||||
"Test failed for method {$method}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see testCurrentContext
|
||||
*/
|
||||
public function currentContextData(): array
|
||||
{
|
||||
return [
|
||||
'default test' => [
|
||||
'container' => [
|
||||
'brand_name' => 'Acme corp.',
|
||||
'landing_page' => ApplicationContext::LANDING_PAGE_BILLING,
|
||||
'payee_preferred' => '',
|
||||
],
|
||||
'user_locale' => 'de_DE',
|
||||
'shippingPreference' => ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
'expected' => [
|
||||
'locale' => 'de-DE',
|
||||
'brand_name' => 'Acme corp.',
|
||||
'landing_page' => ApplicationContext::LANDING_PAGE_BILLING,
|
||||
'shipping_preference' => ApplicationContext::SHIPPING_PREFERENCE_NO_SHIPPING,
|
||||
'payment_method_preference' => ApplicationContext::PAYMENT_METHOD_UNRESTRICTED,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
self::$mocks = [];
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MockInterface[]
|
||||
*/
|
||||
private function buildTestee(): array
|
||||
{
|
||||
if (! self::$mocks) {
|
||||
$config = \Mockery::mock(ContainerInterface::class);
|
||||
$testee = new ApplicationContextRepository($config);
|
||||
|
||||
self::$mocks = [
|
||||
$config,
|
||||
$testee,
|
||||
];
|
||||
}
|
||||
|
||||
return self::$mocks;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue