This commit is contained in:
David Remer 2020-07-10 12:56:01 +03:00
parent 563488e727
commit c04187338a
4 changed files with 25 additions and 8 deletions

View file

@ -48,6 +48,7 @@ class SmartButton implements SmartButtonInterface
}
// phpcs:disable Inpsyde.CodeQuality.FunctionLength.TooLong
// phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
/**
* ToDo: Refactor
* @return bool
@ -184,6 +185,7 @@ class SmartButton implements SmartButtonInterface
return true;
}
// phpcs:enable Inpsyde.CodeQuality.FunctionLength.TooLong
// phpcs:enable Generic.Metrics.CyclomaticComplexity.TooHigh
public function enqueue(): bool
{
@ -232,9 +234,12 @@ class SmartButton implements SmartButtonInterface
'url' => $this->url(),
'style' => [
'layout' => 'vertical',
'color' => ($this->settings->has('button_color')) ? $this->settings->get('button_color') : null,
'shape' => ($this->settings->has('button_shape')) ? $this->settings->get('button_shape') : null,
'label' => ($this->settings->has('button_label')) ? $this->settings->get('button_label') : 'paypal',
'color' => ($this->settings->has('button_color')) ?
$this->settings->get('button_color') : null,
'shape' => ($this->settings->has('button_shape')) ?
$this->settings->get('button_shape') : null,
'label' => ($this->settings->has('button_label')) ?
$this->settings->get('button_label') : 'paypal',
],
],
'hosted_fields' => [

View file

@ -72,7 +72,7 @@ class WcGateway extends \WC_Payment_Gateway
);
}
public function needs_setup()
public function needs_setup(): bool
{
return true;

View file

@ -46,7 +46,10 @@ class OrderProcessor
$errorMessage = null;
if (!$order || !$order->status()->is(OrderStatus::APPROVED)) {
$errorMessage = __('The payment has not been approved yet.', 'woocommerce-paypal-commerce-gateway');
$errorMessage = __(
'The payment has not been approved yet.',
'woocommerce-paypal-commerce-gateway'
);
}
if ($errorMessage) {
$this->lastError = sprintf(
@ -67,9 +70,15 @@ class OrderProcessor
$wcOrder->update_meta_data(WcGateway::CAPTURED_META_KEY, 'false');
}
$wcOrder->update_status('on-hold', __('Awaiting payment.', 'woocommerce-paypal-commerce-gateway'));
$wcOrder->update_status(
'on-hold',
__('Awaiting payment.', 'woocommerce-paypal-commerce-gateway')
);
if ($order->status()->is(OrderStatus::COMPLETED) && $order->intent() === 'CAPTURE') {
$wcOrder->update_status('processing', __('Payment received.', 'woocommerce-paypal-commerce-gateway'));
$wcOrder->update_status(
'processing',
__('Payment received.', 'woocommerce-paypal-commerce-gateway')
);
}
$woocommerce->cart->empty_cart();
$this->sessionHandler->destroySessionData();

View file

@ -72,7 +72,10 @@ class Settings implements ContainerInterface
$defaults = [
'title' => __('PayPal', 'woocommerce-paypal-commerce-gateway'),
'description' => __('Pay via PayPal; you can pay with your credit card if you don\'t have a PayPal account.', 'woocommerce-paypal-commerce-gateway'),
'description' => __(
'Pay via PayPal; you can pay with your credit card if you don\'t have a PayPal account.',
'woocommerce-paypal-commerce-gateway'
),
'button_single_product_enabled' => true,
'button_mini_cart_enabled' => true,
'button_cart_enabled' => true,