PluginProbe
PayPlug for WooCommerce (Official) / 1.10.1
PayPlug for WooCommerce (Official) v1.10.1
3.1.0 3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 All 102 releases
payplug / src / Gateway / PayplugGatewayOney4xWithoutFees.php

PayplugGatewayOney4xWithoutFees.php in PayPlug for WooCommerce (Official) 1.10.1, at src/Gateway/PayplugGatewayOney4xWithoutFees.php

84 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Payplug\PayplugWoocommerce\Gateway;
4
5 // Exit if accessed directly
6 use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper;
7
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * PayPlug WooCommerce Gateway.
14 *
15 * @package Payplug\PayplugWoocommerce\Gateway
16 */
17 class PayplugGatewayOney4xWithoutFees extends PayplugGatewayOney3x
18 {
19
20 public function __construct()
21 {
22 parent::__construct();
23 $this->id = 'oney_x4_without_fees';
24 $this->method_title = _x('PayPlug Oney 4x', 'Gateway method title', 'payplug');
25 $this->method_description = __('Enable PayPlug Oney 4x for your customers.', 'payplug');
26 $this->title = __('Pay by credit card in 4x installments without fees with Oney', 'payplug');
27 }
28
29 /**
30 * Get payment icons.
31 *
32 * @return string
33 */
34 public function get_icon()
35 {
36 if ($this->check_oney_is_available() === true) {
37 $total_price = floatval(WC()->cart->total);
38 $this->oney_response = $this->api->simulate_oney_payment($total_price, 'without_fees');
39 $currency = get_woocommerce_currency_symbol(get_option('woocommerce_currency'));
40 $f = function ($fn) {
41 return $fn;
42 };
43 if(is_array($this->oney_response)) {
44 $this->description = <<<HTML
45 <p>
46 <div class="payplug-oney-flex">
47 <div>{$f(__('Bring', 'payplug'))}:</div>
48 <div>{$this->oney_response['x4_without_fees']['down_payment_amount']} {$currency}</div>
49 </div>
50 <div class="payplug-oney-flex">
51 <div>{$f(__('1st monthly payment', 'payplug'))}:</div>
52 <div>{$this->oney_response['x4_without_fees']['installments'][0]['amount']} {$currency}</div>
53 </div>
54 <div class="payplug-oney-flex">
55 <div>{$f(__('2nd monthly payment', 'payplug'))}:</div>
56 <div>{$this->oney_response['x4_without_fees']['installments'][1]['amount']} {$currency}</div>
57 </div>
58 <div class="payplug-oney-flex">
59 <div>{$f(__('3rd monthly payment', 'payplug'))}:</div>
60 <div>{$this->oney_response['x4_without_fees']['installments'][2]['amount']} {$currency}</div>
61 </div>
62 </p>
63 HTML;
64 } else {
65 $this->description = $this->oney_response;
66 }
67 }
68
69 $country = PayplugWoocommerceHelper::getISOCountryCode();
70 $available_img = file_exists(PAYPLUG_GATEWAY_PLUGIN_DIR . 'assets/images/Oney4x-' . $country . '.png') ? 'Oney4x-' . $country . '.png' : 'Oney4x.png';
71 $disable_img = file_exists(PAYPLUG_GATEWAY_PLUGIN_DIR . 'assets/images/Oney4x_grey-' . $country . '.png') ? 'Oney4x_grey-' . $country . '.png' : 'Oney4x_grey.png';
72 $image = ($this->check_oney_is_available() === true) ? $available_img : $disable_img;
73
74 $icons = apply_filters('payplug_payment_icons', [
75 'payplug' => sprintf('<img src="%s" alt="Oney 4x" class="payplug-payment-icon" />', esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/' . $image)),
76 ]);
77 $icons_str = '';
78 foreach ($icons as $icon) {
79 $icons_str .= $icon;
80 }
81 return $icons_str;
82 }
83 }
84