@@ -74,7 +74,7 @@ public function getInstallmentOptions($isGatewayType = false)
74
74
$ installments = [];
75
75
$ installmentsAmount = $ this ->getInstallmentsMaximumQuantity ($ isGatewayType );
76
76
77
- for ($ i = 1 ; $ i <= $ installmentsAmount ; ++$ i ) {
77
+ for ($ i = 0 ; $ i <= $ installmentsAmount ; ++$ i ) {
78
78
$ installments [$ i ] = $ i ;
79
79
}
80
80
@@ -95,112 +95,6 @@ public function getSoftDescriptorMaxLength($isGatewayType)
95
95
return $ isGatewayType ? 22 : 13 ;
96
96
}
97
97
98
- public function get_installments_by_type ($ total , $ flag = false )
99
- {
100
- $ flags = $ this ->settings ->flags ;
101
- $ type = $ this ->settings ->cc_installment_type ;
102
- $ max_installments = intval ($ this ->settings ->cc_installments_maximum );
103
- $ min_amount = Utils::str_to_float ($ this ->settings ->cc_installments_min_amount );
104
- $ no_interest = intval ($ this ->settings ->cc_installments_without_interest );
105
- $ interest = Utils::str_to_float ($ this ->settings ->cc_installments_interest );
106
- $ interest_increase = Utils::str_to_float ($ this ->settings ->cc_installments_interest_increase );
107
-
108
- $ method = '_calc_installments_ ' . $ type ;
109
-
110
- return $ this ->{$ method }(
111
- compact ('max_installments ' , 'min_amount ' , 'no_interest ' , 'interest ' , 'interest_increase ' , 'total ' , 'flag ' )
112
- );
113
- }
114
-
115
- /** phpcs:disable */
116
- public function render_installments_options ($ total , $ max_installments , $ min_amount , $ interest , $ interest_increase , $ no_interest )
117
- {
118
- $ output = sprintf (
119
- '<option value="1">%1$s</option> ' ,
120
- __ ('1x ' , 'woo-pagarme-payments ' ) . ' ( ' . wc_price ($ total ) . ') '
121
- );
122
-
123
- $ interestBase = $ interest ;
124
-
125
- for ($ times = 2 ; $ times <= $ max_installments ; $ times ++) {
126
- $ interest = $ interestBase ;
127
- $ amount = $ total ;
128
-
129
- if ($ interest || $ interest_increase ) {
130
-
131
- if ($ interest_increase && $ times > $ no_interest + 1 ) {
132
- $ interest += ($ interest_increase * ($ times - ($ no_interest + 1 )));
133
- }
134
-
135
- $ amount += Utils::calc_percentage ($ interest , $ total );
136
- }
137
-
138
- $ value = $ amount ;
139
-
140
- if ($ times <= $ no_interest ) {
141
- $ value = $ total ;
142
- }
143
-
144
- $ price = ceil ($ value / $ times * 100 ) / 100 ;
145
- if ($ price < $ min_amount ) {
146
- break ;
147
- }
148
- $ text = sprintf (
149
- __ ('%dx of %s (%s) ' , 'woo-pagarme-payments ' ),
150
- $ times ,
151
- wc_price ($ price ),
152
- wc_price ($ value )
153
- );
154
-
155
- $ text .= $ this ->verifyInterest ($ times , $ no_interest , $ interest );
156
-
157
- $ output .= sprintf ('<option value="%1$s">%2$s</option> ' , $ times , $ text );
158
- }
159
-
160
- return $ output ;
161
- }
162
-
163
- /**
164
- * @param int $times
165
- * @param mixed $no_interest
166
- * @param mixed $interest
167
- * @return string
168
- */
169
- public function verifyInterest (int $ times , $ no_interest , $ interest ): string
170
- {
171
- if ($ times > $ no_interest && $ interest ) {
172
- return " c/juros " ;
173
- }
174
-
175
- return " s/juros " ;
176
- }
177
-
178
- private function _calc_installments_1 (array $ params )
179
- {
180
- extract ($ params , EXTR_SKIP );
181
-
182
- return $ this ->render_installments_options ($ total , $ max_installments , $ min_amount , $ interest , $ interest_increase , $ no_interest );
183
- }
184
-
185
- private function _calc_installments_2 (array $ params )
186
- {
187
- $ settings_by_flag = $ this ->settings ->cc_installments_by_flag ;
188
-
189
- extract ($ params , EXTR_SKIP );
190
-
191
- if (!$ flag || !isset ($ settings_by_flag ['max_installment ' ][$ flag ])) {
192
- return sprintf ('<option value="">%s</option> ' , __ ('This card brand not is allowed on checkout. ' , Core::SLUG ));
193
- }
194
-
195
- $ max_installments = intval ($ settings_by_flag ['max_installment ' ][$ flag ]);
196
- $ min_amount = Utils::str_to_float ($ settings_by_flag ['installment_min_amount ' ][$ flag ]);
197
- $ no_interest = intval ($ settings_by_flag ['no_interest ' ][$ flag ]);
198
- $ interest = Utils::str_to_float ($ settings_by_flag ['interest ' ][$ flag ]);
199
- $ interest_increase = Utils::str_to_float ($ settings_by_flag ['interest_increase ' ][$ flag ]);
200
-
201
- return $ this ->render_installments_options ($ total , $ max_installments , $ min_amount , $ interest , $ interest_increase , $ no_interest );
202
- }
203
-
204
98
public function get_hub_button_text ($ hub_install_id )
205
99
{
206
100
return !empty ($ hub_install_id )
@@ -271,7 +165,7 @@ public function is_sandbox_mode(): bool
271
165
* @return PaymentInterface
272
166
* @throws Exception
273
167
*/
274
- public function getPaymentInstace ($ paymentCode )
168
+ public function getPaymentInstance ($ paymentCode )
275
169
{
276
170
foreach ($ this ->getPayments () as $ class ) {
277
171
/** @var PaymentInterface $payment */
0 commit comments