@@ -50,6 +50,7 @@ public function startSolicitation($order)
50
50
$ this ->success = true ;
51
51
$ this ->log ("Start " . $ this ->status . ": Ok! " );
52
52
} elseif ($ this ->status >= 200 && $ this ->status <= 299 || $ this ->status == 409 ) {
53
+ $ this ->success = false ;
53
54
$ this ->json = json_decode ($ this ->curl_result , true ); // return array, not object
54
55
$ this ->log ("Start " . $ this ->status . ": " . $ this ->curl_result );
55
56
}
@@ -124,16 +125,16 @@ public function getIdentificationForm($uri, $options = array())
124
125
$ options ["product " ] = array_key_exists ('product ' , $ options ) ? $ options ["product " ] : "i1 " ;
125
126
$ options ["ajax " ] = (isset ($ options ["ajax " ]) && $ options ["ajax " ]) ? "true " : "false " ;
126
127
$ this ->initCurl ($ uri . '/form_v2 ' . '? ' . http_build_query ($ options ));
127
- curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , " GET " );
128
+ curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , ' GET ' );
128
129
curl_setopt ($ this ->ch , CURLOPT_HTTPHEADER , array ('Accept: text/html ' ));
129
130
$ this ->sendRequest ();
130
131
131
132
if ($ this ->status >= 200 && $ this ->status <= 299 ) {
132
133
curl_close ($ this ->ch );
133
134
$ this ->success = true ;
134
-
135
135
return $ this ->curl_result ;
136
136
} else {
137
+ $ this ->success = false ;
137
138
$ this ->log ("Error " . $ this ->status . ": " . print_r ($ this ->curl_result , true ));
138
139
}
139
140
curl_close ($ this ->ch );
@@ -150,9 +151,9 @@ public function sendIdentificationForm($uri, $options = array())
150
151
if ($ this ->status >= 200 && $ this ->status <= 299 ) {
151
152
curl_close ($ this ->ch );
152
153
$ this ->success = true ;
153
-
154
154
return $ this ->curl_result ;
155
155
} else {
156
+ $ this ->success = false ;
156
157
$ this ->log ("Error " . $ this ->status . ": " . print_r ($ this ->curl_result , true ));
157
158
}
158
159
curl_close ($ this ->ch );
@@ -170,6 +171,7 @@ public function startCards($order)
170
171
$ this ->success = true ;
171
172
$ this ->log ("Start " . $ this ->status . ": Ok! " );
172
173
} elseif ($ this ->status >= 200 && $ this ->status <= 299 || $ this ->status == 409 ) {
174
+ $ this ->success = false ;
173
175
$ this ->json = json_decode ($ this ->curl_result , true ); // return array, not object
174
176
$ this ->log ("Start " . $ this ->status . ": " . $ this ->curl_result );
175
177
}
@@ -179,10 +181,10 @@ public function startCards($order)
179
181
public function getCardsForm ($ uri , $ options = array ())
180
182
{
181
183
$ this ->initCurl ($ uri . '? ' . http_build_query ($ options ));
182
- curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , " GET " );
184
+ curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , ' GET ' );
183
185
curl_setopt ($ this ->ch , CURLOPT_HTTPHEADER , array ('Accept: text/html ' ));
184
186
$ this ->sendRequest ();
185
-
187
+ $ this -> success = false ;
186
188
if ($ this ->status >= 200 && $ this ->status <= 299 ) {
187
189
$ this ->success = true ;
188
190
$ this ->json = json_decode ($ this ->curl_result , true ); // return array, not object
@@ -205,19 +207,41 @@ public function qualifyForstartCards($order)
205
207
);
206
208
}
207
209
210
+ public function getMerchantPaymentMethods ($ merchant )
211
+ {
212
+ $ this ->getPaymentMethods ($ this ->_endpoint . '/merchants/ ' . $ merchant );
213
+ }
214
+
215
+ public function getPaymentMethods ($ uri , $ options = array ())
216
+ {
217
+ $ this ->initCurl ($ uri . '/payment_methods ' . (count ($ options )>0 ? '? ' . http_build_query ($ options ):'' ));
218
+ curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , 'GET ' );
219
+ curl_setopt ($ this ->ch , CURLOPT_HTTPHEADER , array ('Accept: text/html ' ));
220
+ $ this ->sendRequest ();
221
+ $ this ->success = false ;
222
+ if ($ this ->status >= 200 && $ this ->status <= 299 ) {
223
+ $ this ->success = true ;
224
+ $ this ->json = json_decode ($ this ->curl_result , true ); // return array, not object
225
+ } elseif ($ this ->status >= 400 && $ this ->status <= 499 ) {
226
+ $ this ->log ("Error " . $ this ->status . ": " . print_r ($ this ->curl_result , true ));
227
+ } else {
228
+ $ this ->log ("Error " . $ this ->status . ": " . print_r ($ this ->curl_result , true ));
229
+ }
230
+ curl_close ($ this ->ch );
231
+ }
232
+
208
233
public function getCreditAgreements ($ amount , $ merchant )
209
234
{
210
235
$ uri = $ this ->_endpoint . '/merchants/ ' . $ merchant . '/credit_agreements?total_with_tax= ' . $ amount . '¤cy=EUR&locale=es-ES&country=ES ' ;
211
236
$ this ->initCurl ($ uri );
212
- curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , " GET " );
237
+ curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , ' GET ' );
213
238
$ this ->sendRequest ();
214
-
215
239
if ($ this ->status >= 200 && $ this ->status <= 299 ) {
216
240
$ this ->success = true ;
217
241
curl_close ($ this ->ch );
218
-
219
242
return json_decode ($ this ->curl_result , true );
220
243
} else {
244
+ $ this ->success = false ;
221
245
$ this ->log ("Error " . $ this ->status . ": " . print_r ($ this ->curl_result , true ));
222
246
}
223
247
curl_close ($ this ->ch );
@@ -234,6 +258,7 @@ public function updateOrder($uri, $order)
234
258
if ($ this ->status >= 200 && $ this ->status <= 299 ) {
235
259
$ this ->success = true ;
236
260
} elseif ($ this ->status == 409 ) {
261
+ $ this ->success = false ;
237
262
$ this ->cart_has_changed = true ;
238
263
$ this ->json = json_decode ($ this ->curl_result , true );
239
264
}
@@ -249,6 +274,7 @@ public function sendDeliveryReport($delivery_report)
249
274
$ this ->success = true ;
250
275
$ this ->log ("Delivery " . $ this ->status . ": Ok! " );
251
276
} elseif ($ this ->status >= 200 && $ this ->status <= 299 || $ this ->status == 409 ) {
277
+ $ this ->success = false ;
252
278
$ this ->json = json_decode ($ this ->curl_result , true ); // return array, not object
253
279
$ this ->log ("Delivery " . $ this ->status . ": " . print_r ($ this ->json , true ));
254
280
}
@@ -266,12 +292,13 @@ public function orderUpdate($order)
266
292
if ($ this ->status >= 200 && $ this ->status <= 299 ) {
267
293
$ this ->success = true ;
268
294
} elseif ($ this ->status == 409 ) {
295
+ $ this ->success = false ;
269
296
$ this ->cart_has_changed = true ;
270
297
$ this ->json = json_decode ($ this ->curl_result , true );
271
298
}
272
299
curl_close ($ this ->ch );
273
300
}
274
-
301
+
275
302
public function callCron ($ cron_url )
276
303
{
277
304
$ this ->_user_agent = 'sequra-cron ' ;
@@ -303,6 +330,11 @@ public function cartHasChanged()
303
330
return $ this ->cart_has_changed ;
304
331
}
305
332
333
+ public function getRawResult ()
334
+ {
335
+ return $ this ->curl_result ;
336
+ }
337
+
306
338
public function getOrderUri ()
307
339
{
308
340
if (preg_match ('/^Location:\s+([^\n\r]+)/mi ' , $ this ->headers , $ m )) {
0 commit comments