Add option to display the payment status

This commit is contained in:
Mészáros Róbert 2020-04-22 16:07:02 +03:00
parent 708efab5e4
commit 24dd72142b
3 changed files with 45 additions and 1 deletions

View file

@ -5,6 +5,8 @@ declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway;
use Dhii\Data\Container\ContainerInterface;
use Inpsyde\PayPalCommerce\WcGateway\Admin\AuthorizedPaymentStatus;
use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderDetail;
use Inpsyde\PayPalCommerce\WcGateway\Checkout\DisableGateways;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGatewayBase;
@ -67,4 +69,7 @@ return [
$paymentsEndpoint = $container->get('api.endpoint.payments');
return new AuthorizedPaymentsProcessor($orderEndpoint, $paymentsEndpoint);
},
'wcgateway.admin.authorized-payment-status' => function(ContainerInterface $container): AuthorizedPaymentStatus {
return new AuthorizedPaymentStatus();
}
];

View file

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Admin;
class AuthorizedPaymentStatus
{
public function render(int $wcOrderId)
{
$wcOrder = new \WC_Order($wcOrderId);
$intent = $wcOrder->get_meta('_ppcp_paypal_intent');
if ($intent !== 'AUTHORIZE') {
return;
}
//TODO add status check
printf(
// @phpcs:ignore Inpsyde.CodeQuality.LineLength.TooLong
'<li class="wide"><p><mark class="order-status status-on-hold"><span>%1$s</span></mark></p><p>%2$s</p></li>',
esc_html__('Not captured', 'woocommerce-paypal-gateway'),
esc_html__('To capture the payment select capture action from the list below.', 'woocommerce-paypal-gateway'),
);
}
}

View file

@ -6,6 +6,8 @@ namespace Inpsyde\PayPalCommerce\WcGateway;
use Dhii\Container\ServiceProvider;
use Dhii\Modular\Module\ModuleInterface;
use Inpsyde\PayPalCommerce\WcGateway\Admin\AuthorizedPaymentStatus;
use Inpsyde\PayPalCommerce\WcGateway\Admin\OrderDetail;
use Inpsyde\PayPalCommerce\WcGateway\Checkout\DisableGateways;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway;
use Inpsyde\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
@ -15,7 +17,6 @@ use Psr\Container\ContainerInterface;
class WcGatewayModule implements ModuleInterface
{
public function setup(): ServiceProviderInterface
{
return new ServiceProvider(
@ -89,5 +90,16 @@ class WcGatewayModule implements ModuleInterface
},
20
);
add_action(
'woocommerce_order_actions_start',
function ($wcOrderId) use ($container) {
/**
* @var AuthorizedPaymentStatus $orderDetail
*/
$orderDetail = $container->get('wcgateway.admin.authorized-payment-status');
$orderDetail->render(intval($wcOrderId));
}
);
}
}