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 / PayplugGatewayOney3xWithoutFees.php

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

80 lines 3.1 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 PayplugGatewayOney3xWithoutFees extends PayplugGatewayOney3x
18 {
19
20 public function __construct()
21 {
22 parent::__construct();
23 $this->id = 'oney_x3_without_fees';
24 $this->method_title = _x('PayPlug Oney 3x', 'Gateway method title', 'payplug');
25 $this->method_description = __('Enable PayPlug Oney 3x for your customers.', 'payplug');
26 $this->title = __('Pay by credit card in 3x 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['x3_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['x3_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['x3_without_fees']['installments'][1]['amount']} {$currency}</div>
57 </div>
58 </p>
59 HTML;
60 } else {
61 $this->description = $this->oney_response;
62 }
63 }
64
65 $country = PayplugWoocommerceHelper::getISOCountryCode();
66 $available_img = file_exists(PAYPLUG_GATEWAY_PLUGIN_DIR . 'assets/images/Oney3x-' . $country . '.png') ? 'Oney3x-' . $country . '.png' : 'Oney3x.png';
67 $disable_img = file_exists(PAYPLUG_GATEWAY_PLUGIN_DIR . 'assets/images/Oney3x_grey-' . $country . '.png') ? 'Oney3x_grey-' . $country . '.png' : 'Oney3x_grey.png';
68 $image = ($this->check_oney_is_available() === true) ? $available_img : $disable_img;
69
70 $icons = apply_filters('payplug_payment_icons', [
71 'payplug' => sprintf('<img src="%s" alt="Oney 3x" class="payplug-payment-icon" />', esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/' . $image)),
72 ]);
73 $icons_str = '';
74 foreach ($icons as $icon) {
75 $icons_str .= $icon;
76 }
77 return $icons_str;
78 }
79 }
80