| 1 |
<?php |
| 2 |
|
| 3 |
namespace Payplug\PayplugWoocommerce\Gateway; |
| 4 |
|
| 5 |
// Exit if accessed directly |
| 6 |
if (!defined('ABSPATH')) { |
| 7 |
exit; |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* PayPlug WooCommerce Gateway. |
| 12 |
* |
| 13 |
* @package Payplug\PayplugWoocommerce\Gateway |
| 14 |
*/ |
| 15 |
class PayplugGatewayOney4x extends PayplugGatewayOney3x |
| 16 |
{ |
| 17 |
|
| 18 |
public function __construct() |
| 19 |
{ |
| 20 |
parent::__construct(); |
| 21 |
$this->id = 'oney_x4_with_fees'; |
| 22 |
$this->method_title = _x('PayPlug Oney 4x', 'Gateway method title', 'payplug'); |
| 23 |
$this->method_description = __('Enable PayPlug Oney 4x for your customers.', 'payplug'); |
| 24 |
$this->title = __('Pay by card in 4x with Oney', 'payplug'); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Get payment icons. |
| 29 |
* |
| 30 |
* @return string |
| 31 |
*/ |
| 32 |
public function get_icon() |
| 33 |
{ |
| 34 |
parent::get_icon(); |
| 35 |
if ($this->check_oney_is_available() === true) { |
| 36 |
$currency = get_woocommerce_currency_symbol(get_option('woocommerce_currency')); |
| 37 |
$f = function ($fn) { |
| 38 |
return $fn; |
| 39 |
}; |
| 40 |
if(is_array($this->oney_response)) { |
| 41 |
$this->description = <<<HTML |
| 42 |
<p> |
| 43 |
<div class="payplug-oney-flex"> |
| 44 |
<div>{$f(__('Bring', 'payplug'))} :</div> |
| 45 |
<div>{$this->oney_response['x4_with_fees']['down_payment_amount']} {$currency}</div> |
| 46 |
</div> |
| 47 |
<div class="payplug-oney-flex"> |
| 48 |
<div>{$f(__('1st monthly payment', 'payplug'))} :</div> |
| 49 |
<div>{$this->oney_response['x4_with_fees']['installments'][0]['amount']} {$currency}</div> |
| 50 |
</div> |
| 51 |
<div class="payplug-oney-flex"> |
| 52 |
<div>{$f(__('2nd monthly payment', 'payplug'))} :</div> |
| 53 |
<div>{$this->oney_response['x4_with_fees']['installments'][1]['amount']} {$currency}</div> |
| 54 |
</div> |
| 55 |
<div class="payplug-oney-flex"> |
| 56 |
<div>{$f(__('3rd monthly payment', 'payplug'))} :</div> |
| 57 |
<div>{$this->oney_response['x4_with_fees']['installments'][2]['amount']} {$currency}</div> |
| 58 |
</div> |
| 59 |
</p> |
| 60 |
HTML; |
| 61 |
} else { |
| 62 |
$this->description = $this->oney_response; |
| 63 |
} |
| 64 |
} |
| 65 |
$available_img = ($this->check_oney_is_available() === true) ? 'lg-4xoney-checkout.png' : 'lg-4xoney-checkout-disabled.png'; |
| 66 |
$icons = apply_filters('payplug_payment_icons', [ |
| 67 |
'payplug' => sprintf('<img src="%s" alt="Oney 3x" class="payplug-payment-icon" />', esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/' . $available_img)), |
| 68 |
]); |
| 69 |
$icons_str = ''; |
| 70 |
foreach ($icons as $icon) { |
| 71 |
$icons_str .= $icon; |
| 72 |
} |
| 73 |
return $icons_str; |
| 74 |
} |
| 75 |
} |
| 76 |
|