@@ -50,8 +50,8 @@ private function setRequestHeader($name, $value)
50
50
if (!is_array ($ this ->request_headers )) {
51
51
$ this ->resetRequestHeaders ();
52
52
}
53
- $ name = trim ($ name );
54
- $ value = trim ($ value );
53
+ $ name = trim (( string ) $ name );
54
+ $ value = trim (( string ) $ value );
55
55
if ($ value === '' || $ name === '' ) {
56
56
return ;
57
57
}
@@ -119,6 +119,7 @@ public function startSolicitation($order)
119
119
}
120
120
121
121
$ this ->initCurl ($ this ->_endpoint . '/orders ' );
122
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ order ['merchant ' ]['id ' ] ?? '' );
122
123
$ this ->verbThePayload ('POST ' , array ('order ' => $ order ));
123
124
$ this ->dealWithResponse ();
124
125
curl_close ($ this ->ch );
@@ -136,16 +137,24 @@ public function qualifyForSolicitation($order)
136
137
return true ;
137
138
}
138
139
139
- public function getIdentificationForm ($ uri , $ options = array ())
140
+ /**
141
+ * Retrieves the identification form for a given URI and options.
142
+ *
143
+ * @param string $uri The URI to retrieve the identification form from.
144
+ * @param array $options An associative array of options for the form.
145
+ * @param string $merchant_id The merchant ID to be used in the request.
146
+ *
147
+ * @return string The HTML content of the identification form.
148
+ */
149
+ public function getIdentificationForm ($ uri , $ options = array (), $ merchant_id = '' )
140
150
{
141
151
$ options ["product " ] = array_key_exists ('product ' , $ options ) ? $ options ["product " ] : "i1 " ;
142
152
$ options ["ajax " ] = (isset ($ options ["ajax " ]) && $ options ["ajax " ]) ? "true " : "false " ;
143
153
$ this ->initCurl ($ uri . '/form_v2 ' . '? ' . http_build_query ($ options ));
144
154
curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , 'GET ' );
145
155
146
156
$ this ->setRequestHeader (self ::HEADER_ACCEPT , self ::TYPE_HTML );
147
- // TODO: Set merchant ID
148
- // $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
157
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ merchant_id );
149
158
150
159
$ this ->sendRequest ();
151
160
$ this ->dealWithResponse ();
@@ -159,6 +168,8 @@ public function sendIdentificationForm($uri, $options = array())
159
168
$ options ["product_code " ] = $ options ["product " ];
160
169
$ options ["channel " ] = array_key_exists ('channel ' , $ options ) ? $ options ["channel " ] : "sms " ;
161
170
$ this ->initCurl ($ uri . '/form_deliveries ' );
171
+ // TODO: Set merchant ID?
172
+ // $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
162
173
$ this ->verbThePayload ('POST ' , $ options );
163
174
$ this ->dealWithResponse ();
164
175
curl_close ($ this ->ch );
@@ -172,6 +183,8 @@ public function startCards($order)
172
183
}
173
184
174
185
$ this ->initCurl ($ this ->_endpoint . '/cards ' );
186
+ // TODO: Set merchant ID?
187
+ // $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
175
188
$ this ->verbThePayload ('POST ' , array ('order ' => $ order ));
176
189
$ this ->dealWithResponse ();
177
190
curl_close ($ this ->ch );
@@ -183,7 +196,7 @@ public function getCardsForm($uri, $options = array())
183
196
curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , 'GET ' );
184
197
185
198
$ this ->setRequestHeader (self ::HEADER_ACCEPT , self ::TYPE_HTML );
186
- // TODO: Set merchant ID
199
+ // TODO: Set merchant ID?
187
200
// $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
188
201
189
202
$ this ->sendRequest ();
@@ -204,21 +217,20 @@ public function qualifyForstartCards($order)
204
217
205
218
public function getMerchantPaymentMethods ($ merchant )
206
219
{
207
- $ this ->getPaymentMethods ($ this ->_endpoint . '/merchants/ ' . $ merchant );
220
+ $ this ->getPaymentMethods ($ this ->_endpoint . '/merchants/ ' . $ merchant, array (), $ merchant );
208
221
}
209
222
210
- public function getPaymentMethods ($ uri , $ options = array ())
223
+ public function getPaymentMethods ($ uri , $ options = array (), $ merchant_id = '' )
211
224
{
212
225
if (!preg_match ('!^https?://! ' , $ uri )) {
213
226
$ uri = $ this ->_endpoint . '/orders/ ' . $ uri ;
214
227
}
215
228
$ this ->initCurl ($ uri . '/payment_methods ' . (count ($ options ) > 0 ? '? ' . http_build_query ($ options ) : '' ));
216
- curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , 'GET ' );
217
229
218
230
$ this ->setRequestHeader (self ::HEADER_ACCEPT , self ::TYPE_JSON );
219
- // TODO: Set merchant ID
220
- // $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
231
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ merchant_id );
221
232
233
+ curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , 'GET ' );
222
234
$ this ->sendRequest ();
223
235
$ this ->dealWithResponse ();
224
236
curl_close ($ this ->ch );
@@ -230,8 +242,7 @@ public function getAvailableDisbursements($merchant)
230
242
curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , 'GET ' );
231
243
232
244
$ this ->setRequestHeader (self ::HEADER_ACCEPT , self ::TYPE_JSON );
233
- // TODO: Set merchant ID
234
- // $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
245
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ merchant );
235
246
236
247
$ this ->sendRequest ();
237
248
$ this ->dealWithResponse ();
@@ -244,8 +255,10 @@ public function getDisbursementDetails($path)
244
255
curl_setopt ($ this ->ch , CURLOPT_CUSTOMREQUEST , 'GET ' );
245
256
246
257
$ this ->setRequestHeader (self ::HEADER_ACCEPT , self ::TYPE_JSON );
247
- // TODO: Set merchant ID
248
- // $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
258
+
259
+ if (preg_match ('~merchants/([^/]+)/disbursements~ ' , $ path , $ matches )) {
260
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ matches [1 ]);
261
+ }
249
262
250
263
$ this ->sendRequest ();
251
264
$ this ->dealWithResponse ();
@@ -276,6 +289,7 @@ public function updateOrder($uri, $order, $verb = 'PUT')
276
289
$ uri = $ this ->_endpoint . '/orders/ ' . $ uri ;
277
290
}
278
291
$ this ->initCurl ($ uri );
292
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ order ['merchant ' ]['id ' ] ?? '' );
279
293
$ this ->verbThePayload ($ verb , array ('order ' => $ order ));
280
294
$ this ->dealWithResponse ();
281
295
if ($ this ->status == 409 ) {
@@ -287,6 +301,7 @@ public function updateOrder($uri, $order, $verb = 'PUT')
287
301
public function sendDeliveryReport ($ delivery_report )
288
302
{
289
303
$ this ->initCurl ($ this ->_endpoint . '/delivery_reports ' );
304
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ delivery_report ['merchant ' ]['id ' ] ?? '' );
290
305
$ this ->verbThePayload ('POST ' , array ('delivery_report ' => $ delivery_report ));
291
306
$ this ->dealWithResponse ();
292
307
curl_close ($ this ->ch );
@@ -298,6 +313,7 @@ public function orderUpdate($order)
298
313
'/merchants/ ' . urlencode ($ order ['merchant ' ]['id ' ]) .
299
314
'/orders/ ' . urlencode ($ order ['merchant_reference ' ]['order_ref_1 ' ]);
300
315
$ this ->initCurl ($ uri );
316
+ $ this ->setRequestHeader (self ::HEADER_SEQURA_MERCHANT_ID , $ order ['merchant ' ]['id ' ] ?? '' );
301
317
$ this ->verbThePayload ('PUT ' , array ('order ' => $ order ));
302
318
$ this ->dealWithResponse ();
303
319
if ($ this ->status == 409 ) {
@@ -392,8 +408,6 @@ private function verbThePayload($verb, $payload)
392
408
$ this ->setRequestHeader (self ::HEADER_ACCEPT , self ::TYPE_JSON );
393
409
$ this ->setRequestHeader (self ::HEADER_CONTENT_TYPE , self ::TYPE_JSON );
394
410
$ this ->setRequestHeader (self ::HEADER_CONTENT_LENGTH , (string ) strlen ($ data_string ));
395
- // TODO: Set merchant ID
396
- // $this->setRequestHeader(self::HEADER_SEQURA_MERCHANT_ID, '');
397
411
398
412
$ this ->sendRequest ();
399
413
}
0 commit comments