PluginProbe
PayPlug for WooCommerce (Official) / 2.18.0
PayPlug for WooCommerce (Official) v2.18.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 1.2.6 All 101 releases
payplug / src / Front / Layout / OneyIT.php

OneyIT.php in PayPlug for WooCommerce (Official) 2.18.0, at src/Front/Layout/OneyIT.php

225 lines 8.7 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\Front\Layout;
4
5 use function is_cart;
6 use Payplug\PayplugWoocommerce\Front\PayplugOney\Requests\OneyWithFees;
7 use Payplug\PayplugWoocommerce\Front\PayplugOney\Requests\OneyWithoutFees;
8 use Payplug\PayplugWoocommerce\Gateway\PayplugGatewayOney3x;
9
10 class OneyIT extends OneyBase implements InterfaceOneyLayout
11 {
12 public function __construct()
13 {
14 parent::__construct();
15 }
16
17 /**
18 * @param OneyWithoutFees $oney
19 *
20 * @return string
21 */
22 public static function simulationPopupContentWithoutFees($oney)
23 {
24 $simulationResponse = $oney->getSimulation();
25
26 $x4 = $simulationResponse['x4_without_fees'];
27 $x3 = $simulationResponse['x3_without_fees'];
28
29 $financing_cost_3x = intval($x3['total_cost']) / 100;
30 $financing_cost_4x = intval($x4['total_cost']) / 100;
31
32 $f = function ($fn) {
33 return $fn;
34 };
35
36 return <<<HTML
37 <div id='oney-popup-close'>
38 <div class='oney-popup-close-mdiv'>
39 <div class='oney-popup-close-md'></div>
40 </div>
41 </div>
42 <div class='oney-img oney-logo no-margin'></div>
43 <div class='oney-title'>
44 <p class='no-margin oney-color'>{$f(__('payplug_oneyIT_popup-withoutfees-title', 'payplug'))} </p>
45 <p class='no-margin bold oney-color'>{$f(__('BY CREDIT CARD', 'payplug'))}</p>
46 </div>
47 <div class='oney-content oney-3x-content'>
48 <div class='oney-img oney-3x no-margin'></div>
49 <div class='oney-details'>
50 <p class='bold no-margin'> {$f(__('Bring', 'payplug'))}: {$x3['down_payment_amount']}</p>
51 <p class='bold no-margin'>{$f(sprintf(__('IT monthly payment of', 'payplug'), 2))}: {$x3['installments'][0]['amount']}</p>
52 <p class='no-margin'> {$f(__('Of which financing cost', 'payplug'))}: {$financing_cost_3x}</p>
53 <p class='no-margin'> {$f(__('TAEG', 'payplug'))}: {$x3['effective_annual_percentage_rate']} % </p>
54 </div>
55 </div>
56 <div class='oney-separator'></div>
57 <div class='oney-content oney-4x-content'>
58 <div class='oney-img oney-4x no-margin'></div>
59 <div class='oney-details'>
60 <p class='bold no-margin'> {$f(__('Bring', 'payplug'))}: {$x4['down_payment_amount']}</p>
61 <p class='bold no-margin'>{$f(sprintf(__('IT monthly payment of', 'payplug'), 3))}: {$x4['installments'][0]['amount']}</p>
62 <p class='no-margin'> {$f(__('Of which financing cost', 'payplug'))}: {$financing_cost_4x}</p>
63 <p class='no-margin'> {$f(__('TAEG', 'payplug'))}: {$x4['effective_annual_percentage_rate']} % </p>
64 </div>
65 </div>
66 HTML;
67 }
68
69 /**
70 * @param OneyWithFees $oney
71 *
72 * @return string
73 */
74 public static function simulationPopupContent($oney)
75 {
76 $simulationResponse = $oney->getSimulation();
77
78 $x4 = $simulationResponse['x4_with_fees'];
79 $x3 = $simulationResponse['x3_with_fees'];
80
81 $financing_cost_3x = intval($x3['total_cost']) / 100;
82 $financing_cost_4x = intval($x4['total_cost']) / 100;
83
84 $f = function ($fn) {
85 return $fn;
86 };
87
88 return <<<HTML
89 <div id='oney-popup-close'>
90 <div class='oney-popup-close-mdiv'>
91 <div class='oney-popup-close-md'></div>
92 </div>
93 </div>
94 <div class='oney-img oney-logo no-margin'></div>
95 <div class='oney-title'>
96 <p class='no-margin oney-color'>{$f(__('payplug_oneyIT_popup-title', 'payplug'))} </p>
97 <p class='no-margin bold oney-color'>{$f(__('BY CREDIT CARD', 'payplug'))}</p>
98 </div>
99 <div class='oney-content oney-3x-content'>
100 <div class='oney-img oney-3x no-margin'></div>
101 <div class='oney-details'>
102 <p class='bold no-margin'> {$f(__('Bring', 'payplug'))}: {$x3['down_payment_amount']}</p>
103 <p class='bold no-margin'>{$f(sprintf(__('IT monthly payment of', 'payplug'), 2))}: {$x3['installments'][0]['amount']}</p>
104 <p class='no-margin'> {$f(__('Of which financing cost', 'payplug'))}: {$financing_cost_3x}</p>
105 <p class='no-margin'> {$f(__('TAEG', 'payplug'))}: {$x3['effective_annual_percentage_rate']} % </p>
106 </div>
107 </div>
108 <div class='oney-separator'></div>
109 <div class='oney-content oney-4x-content'>
110 <div class='oney-img oney-4x no-margin'></div>
111 <div class='oney-details'>
112 <p class='bold no-margin'> {$f(__('Bring', 'payplug'))}: {$x4['down_payment_amount']}</p>
113 <p class='bold no-margin'>{$f(sprintf(__('IT monthly payment of', 'payplug'), 3))}: {$x4['installments'][0]['amount']}</p>
114 <p class='no-margin'> {$f(__('Of which financing cost', 'payplug'))}: {$financing_cost_4x}</p>
115 <p class='no-margin'> {$f(__('TAEG', 'payplug'))}: {$x4['effective_annual_percentage_rate']} % </p>
116 </div>
117 </div>
118 HTML;
119 }
120
121 /**
122 * @param $min
123 * @param $max
124 *
125 * @return string
126 */
127 public static function footerOneyWithoutFees($min, $max)
128 {
129 $f = function ($fn) {
130 return $fn;
131 };
132
133 $footer = <<<HTML
134 <div class='oney-cgv-content oney-cgv-footer'>
135 {$f(sprintf(
136 esc_html__('payplug_oneyIT_popup-footer', 'payplug'),
137 $min,
138 $max,
139 __('payplug_oneyIT_popup-url', 'payplug'),
140 __('payplug_oneyIT-without-fees_popup-footer_pdf', 'payplug')
141 ))}
142 </div>
143 HTML;
144
145 return $footer;
146 }
147
148 /**
149 * @param $min
150 * @param $max
151 *
152 * @return string
153 */
154 public static function footerOneyWithFees($min, $max)
155 {
156 $f = function ($fn) {
157 return $fn;
158 };
159
160 $footer = <<<HTML
161 <div class='oney-cgv-content oney-cgv-footer'>
162 {$f(sprintf(
163 esc_html__('payplug_oneyIT_popup-footer', 'payplug'),
164 $min,
165 $max,
166 __('payplug_oneyIT_popup-url', 'payplug'),
167 __('payplug_oneyIT_popup-footer_pdf', 'payplug')
168 ))}
169 </div>
170 HTML;
171
172 return $footer;
173 }
174
175 /**
176 * disabled oney popup
177 *
178 * @param \Payplug\PayplugWoocommerce\Front\PayplugOney\Country\Oney $oney
179 *
180 * @return string
181 */
182 public static function disabledOneyPopup($oney)
183 {
184 return '<div class="payplug-oney ' . $oney->isDisable() . '" id="oney-popup">
185 <div class="payplug-lds-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
186 <div id="oney-popup-error">
187 <div class="oney-error range"> ' . sprintf(__('The total amount of your order should be between %s€ and %s€ to pay with Oney.', 'payplug'), $oney->get_min_amount(), $oney->get_max_amount()) . '</div>
188 <div class="oney-error qty">' . sprintf(__('The payment with Oney is unavailable because you have more than %s items in your cart.', 'payplug'), PayplugGatewayOney3x::ONEY_PRODUCT_QUANTITY_MAXIMUM) . '</div>
189 </div>
190 </div>';
191 }
192
193 /**
194 * header for cart oney
195 *
196 * @return string
197 */
198 public static function payWithOney($oney)
199 {
200 $variations = $oney->getVariations();
201
202 $html = '
203 <div class="payplug-oney ' . $oney->isDisable() . '"
204 data-is-cart="' . (is_cart() ? 1 : 0) . '"
205 data-total-products="' . $oney->getTotalProducts() . '"
206 data-price="' . $oney->getTotalPrice() . '"
207 data-max-oney-qty="' . PayplugGatewayOney3x::ONEY_PRODUCT_QUANTITY_MAXIMUM . '"
208 data-min-oney="' . $oney->get_min_amount() . '"
209 data-max-oney="' . $oney->get_max_amount() . '" >';
210 $html .= __('OR PAY IN', 'payplug');
211 if (!empty($variations)) {
212 foreach ($variations as $id => $price) {
213 $html .= '<input type="hidden" name="variation_' . $id . '" value = "' . $price . '" />';
214 }
215 }
216 $html .= '<div class="payplug-oney-popup">
217 <div class="oney-img ' . $oney->getIcon() . '"></div>
218 <div id="oney-show-popup" class="bold oney-color">?</div>
219 </div>
220 </div>';
221
222 return $html;
223 }
224 }
225