rename WcGateway to PayPalGateway

This commit is contained in:
David Remer 2020-08-18 08:46:18 +03:00
parent 781760a82c
commit 03d2ed9897
14 changed files with 52 additions and 52 deletions

View file

@ -11,7 +11,7 @@ use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
use Inpsyde\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
use Inpsyde\PayPalCommerce\WcGateway\Checkout\CheckoutPayPalAddressPreset;
use Inpsyde\PayPalCommerce\WcGateway\Checkout\DisableGateways;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use Inpsyde\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
use Inpsyde\PayPalCommerce\WcGateway\Notice\ConnectAdminNotice;
use Inpsyde\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
@ -22,14 +22,14 @@ use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
use WpOop\TransientCache\CachePoolFactory;
return [
'wcgateway.gateway' => static function (ContainerInterface $container): WcGateway {
'wcgateway.paypal-gateway' => static function (ContainerInterface $container): PayPalGateway {
$orderProcessor = $container->get('wcgateway.order-processor');
$settingsRenderer = $container->get('wcgateway.settings.render');
$authorizedPayments = $container->get('wcgateway.processor.authorized-payments');
$notice = $container->get('wcgateway.notice.authorize-order-action');
$settings = $container->get('wcgateway.settings');
return new WcGateway(
return new PayPalGateway(
$settingsRenderer,
$orderProcessor,
$authorizedPayments,

View file

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Admin;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
class OrderTablePaymentStatusColumn
@ -65,12 +65,12 @@ class OrderTablePaymentStatusColumn
private function renderForOrder(\WC_Order $order): bool
{
return !empty($order->get_meta(WcGateway::CAPTURED_META_KEY));
return !empty($order->get_meta(PayPalGateway::CAPTURED_META_KEY));
}
private function isCaptured(\WC_Order $wcOrder): bool
{
$captured = $wcOrder->get_meta(WcGateway::CAPTURED_META_KEY);
$captured = $wcOrder->get_meta(PayPalGateway::CAPTURED_META_KEY);
return wc_string_to_bool($captured);
}

View file

@ -4,15 +4,15 @@ declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Admin;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
class PaymentStatusOrderDetail
{
public function render(int $wcOrderId)
{
$wcOrder = new \WC_Order($wcOrderId);
$intent = $wcOrder->get_meta(WcGateway::INTENT_META_KEY);
$captured = $wcOrder->get_meta(WcGateway::CAPTURED_META_KEY);
$intent = $wcOrder->get_meta(PayPalGateway::INTENT_META_KEY);
$captured = $wcOrder->get_meta(PayPalGateway::CAPTURED_META_KEY);
if (strcasecmp($intent, 'AUTHORIZE') !== 0) {
return;

View file

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Checkout;
use Inpsyde\PayPalCommerce\Session\SessionHandler;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use Psr\Container\ContainerInterface;
class DisableGateways
@ -24,14 +24,14 @@ class DisableGateways
public function handler(array $methods): array
{
if (! isset($methods[WcGateway::ID])) {
if (! isset($methods[PayPalGateway::ID])) {
return $methods;
}
if (
! $this->settings->has('merchant_email')
|| ! is_email($this->settings->get('merchant_email'))
) {
unset($methods[WcGateway::ID]);
unset($methods[PayPalGateway::ID]);
return $methods;
}
@ -39,7 +39,7 @@ class DisableGateways
return $methods;
}
return [WcGateway::ID => $methods[WcGateway::ID]];
return [PayPalGateway::ID => $methods[PayPalGateway::ID]];
}
private function needsToDisableGateways(): bool

View file

@ -22,7 +22,7 @@ use Psr\Container\ContainerInterface;
//phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
//phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration.NoArgumentType
class WcGateway extends \WC_Payment_Gateway
class PayPalGateway extends \WC_Payment_Gateway
{
public const ID = 'ppcp-gateway';

View file

@ -10,7 +10,7 @@ use Inpsyde\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
use Inpsyde\PayPalCommerce\ApiClient\Entity\Authorization;
use Inpsyde\PayPalCommerce\ApiClient\Entity\AuthorizationStatus;
use Inpsyde\PayPalCommerce\ApiClient\Entity\Order;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
class AuthorizedPaymentsProcessor
{
@ -71,7 +71,7 @@ class AuthorizedPaymentsProcessor
private function payPalOrderFromWcOrder(\WC_Order $wcOrder): Order
{
$orderId = $wcOrder->get_meta(WcGateway::ORDER_ID_META_KEY);
$orderId = $wcOrder->get_meta(PayPalGateway::ORDER_ID_META_KEY);
return $this->orderEndpoint->order($orderId);
}

View file

@ -12,7 +12,7 @@ use Inpsyde\PayPalCommerce\ApiClient\Factory\OrderFactory;
use Inpsyde\PayPalCommerce\ApiClient\Repository\CartRepository;
use Inpsyde\PayPalCommerce\Button\Helper\ThreeDSecure;
use Inpsyde\PayPalCommerce\Session\SessionHandler;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
class OrderProcessor
{
@ -45,8 +45,8 @@ class OrderProcessor
public function process(\WC_Order $wcOrder, \WooCommerce $woocommerce): bool
{
$order = $this->sessionHandler->order();
$wcOrder->update_meta_data(WcGateway::ORDER_ID_META_KEY, $order->id());
$wcOrder->update_meta_data(WcGateway::INTENT_META_KEY, $order->intent());
$wcOrder->update_meta_data(PayPalGateway::ORDER_ID_META_KEY, $order->id());
$wcOrder->update_meta_data(PayPalGateway::INTENT_META_KEY, $order->intent());
$errorMessage = null;
if (!$order || ! $this->orderIsApproved($order)) {
@ -71,7 +71,7 @@ class OrderProcessor
if ($order->intent() === 'AUTHORIZE') {
$order = $this->orderEndpoint->authorize($order);
$wcOrder->update_meta_data(WcGateway::CAPTURED_META_KEY, 'false');
$wcOrder->update_meta_data(PayPalGateway::CAPTURED_META_KEY, 'false');
}
$wcOrder->update_status(

View file

@ -12,7 +12,7 @@ use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderTablePaymentStatusColumn;
use Inpsyde\PayPalCommerce\WcGateway\Admin\PaymentStatusOrderDetail;
use Inpsyde\PayPalCommerce\WcGateway\Checkout\CheckoutPayPalAddressPreset;
use Inpsyde\PayPalCommerce\WcGateway\Checkout\DisableGateways;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use Inpsyde\PayPalCommerce\WcGateway\Notice\ConnectAdminNotice;
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
use Inpsyde\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
@ -98,7 +98,7 @@ class WcGatewayModule implements ModuleInterface
add_filter(
'woocommerce_payment_gateways',
static function ($methods) use ($container): array {
$methods[] = $container->get('wcgateway.gateway');
$methods[] = $container->get('wcgateway.paypal-gateway');
return (array)$methods;
}
);
@ -168,9 +168,9 @@ class WcGatewayModule implements ModuleInterface
'woocommerce_order_action_ppcp_authorize_order',
static function (\WC_Order $wcOrder) use ($container) {
/**
* @var WcGateway $gateway
* @var PayPalGateway $gateway
*/
$gateway = $container->get('wcgateway.gateway');
$gateway = $container->get('wcgateway.paypal-gateway');
$gateway->captureAuthorizedPayment($wcOrder);
}
);