PluginProbe
PayPlug for WooCommerce (Official) / 3.0.0
PayPlug for WooCommerce (Official) v3.0.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) 3.0.0, at src/Front/Layout/OneyIT.php

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