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

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