| @@ -18,9 +18,9 @@ | ||
| 18 | 18 | $this->id = 'oney_x4_with_fees'; |
| 19 | 19 | $this->method_title = _x('PayPlug Oney 4x', 'Gateway method title', 'payplug'); |
| 20 | 20 | $this->method_description = __('Enable PayPlug Oney 4x for your customers.', 'payplug'); |
| 21 | 21 | $this->title = __('Pay by card in 4x with Oney', 'payplug'); |
| 22 | - $this->has_fields = false; | |
| 22 | + $this->has_fields = true; | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Get payment icons. |
| @@ -28,58 +28,11 @@ | ||
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | 30 | public function get_icon() |
| 31 | 31 | { |
| 32 | - if ($this->check_oney_is_available() === true) { | |
| 33 | - $total_price = floatval(WC()->cart->total); | |
| 34 | - $this->oney_response = $this->payplug_api->simulate_oney_payment($total_price, 'with_fees'); | |
| 35 | - $currency = get_woocommerce_currency_symbol(get_option('woocommerce_currency')); | |
| 36 | - $total_price_oney = floatval($this->oney_response['x4_with_fees']['down_payment_amount']); | |
| 37 | - foreach ($this->oney_response['x4_with_fees']['installments'] as $installment) { | |
| 38 | - $total_price_oney = $total_price_oney + floatval($installment['amount']); | |
| 39 | - } | |
| 32 | + $disable = $this->check_oney_is_available() === true ? '' : 'disable-checkout-icons'; | |
| 33 | + $available_img = 'x4_with_fees.svg'; | |
| 40 | 34 | |
| 41 | - $tax_cost = floatval($this->oney_response['x4_with_fees']['total_cost']) / 100; | |
| 42 | - $disable = ''; | |
| 43 | - $f = function ($fn) { | |
| 44 | - return $fn; | |
| 45 | - }; | |
| 46 | - if (is_array($this->oney_response)) { | |
| 47 | - $this->description = <<<HTML | |
| 48 | - <p> | |
| 49 | - <div class="payplug-oney-flex"> | |
| 50 | - <div>{$f(__('Bring', 'payplug'))}:</div> | |
| 51 | - <div>{$this->oney_response['x4_with_fees']['down_payment_amount']} {$currency}</div> | |
| 52 | - </div> | |
| 53 | - <div class="payplug-oney-flex"> | |
| 54 | - <small>( {$f(__('oney_financing_cost', 'payplug'))} <b>{$tax_cost} {$currency}</b> TAEG : <b>{$this->oney_response['x4_with_fees']['effective_annual_percentage_rate']} %</b> )</small> | |
| 55 | - </div> | |
| 56 | - <div class="payplug-oney-flex"> | |
| 57 | - <div>{$f(__('1st monthly payment', 'payplug'))}:</div> | |
| 58 | - <div>{$this->oney_response['x4_with_fees']['installments'][0]['amount']} {$currency}</div> | |
| 59 | - </div> | |
| 60 | - <div class="payplug-oney-flex"> | |
| 61 | - <div>{$f(__('2nd monthly payment', 'payplug'))}:</div> | |
| 62 | - <div>{$this->oney_response['x4_with_fees']['installments'][1]['amount']} {$currency}</div> | |
| 63 | - </div> | |
| 64 | - <div class="payplug-oney-flex"> | |
| 65 | - <div>{$f(__('3rd monthly payment', 'payplug'))}:</div> | |
| 66 | - <div>{$this->oney_response['x4_with_fees']['installments'][2]['amount']} {$currency}</div> | |
| 67 | - </div> | |
| 68 | - <div class="payplug-oney-flex"> | |
| 69 | - <div><b>{$f(__('oney_total', 'payplug'))}</b></div> | |
| 70 | - <div><b>{$total_price_oney} {$currency}</b></div> | |
| 71 | - </div> | |
| 72 | - </p> | |
| 73 | -HTML; | |
| 74 | - } else { | |
| 75 | - $this->description = $this->oney_response; | |
| 76 | - } | |
| 77 | - } else { | |
| 78 | - $disable = 'disable-checkout-icons'; | |
| 79 | - } | |
| 80 | - | |
| 81 | - $available_img = 'x4_with_fees.svg'; | |
| 82 | 35 | $icons = apply_filters('payplug_payment_icons', [ |
| 83 | 36 | 'payplug' => sprintf('<img src="%s" alt="Oney 4x" class="payplug-payment-icon ' . $disable . '" />', esc_url(PAYPLUG_GATEWAY_PLUGIN_URL . '/assets/images/checkout/' . $available_img)), |
| 84 | 37 | ]); |
| 85 | 38 | $icons_str = ''; |