@@ -22,6 +22,10 @@ class PurchaseRequest extends AbstractRequest
2222 /** @var string */
2323 protected $ testEndpoint = 'https://payment.preprod.direct.worldline-solutions.com ' ;
2424
25+ /** @var string Can be "FINAL_AUTHORIZATION" "PRE_AUTHORIZATION" or "SALE" */
26+ protected $ authorizationMode = 'SALE ' ;
27+ protected $ requestMethod = 'POST ' ;
28+
2529 public function getApiKey ()
2630 {
2731 return $ this ->getParameter ('apiKey ' );
@@ -135,6 +139,10 @@ public function getData()
135139 }
136140
137141 $ data = [
142+ 'cardPaymentMethodSpecificInput ' => [
143+ 'authorizationMode ' => 'SALE ' ,
144+ 'transactionChannel ' => 'ECOMMERCE ' ,
145+ ],
138146 'hostedCheckoutSpecificInput ' => [
139147 // if adding locale, validate locale against known formats
140148 // @see https://docs.direct.worldline-solutions.com/en/integration/basic-integration-methods/hosted-checkout-page#chooselanguageversion
@@ -198,13 +206,12 @@ public function getEndpoint()
198206
199207 public function sendData ($ data )
200208 {
201- $ requestMethod = $ this ->getRequestMethod ();
202- $ contentType = $ this ->getRequestMethod () == 'POST ' ? 'application/json; charset=utf-8 ' : '' ;
209+ $ contentType = $ this ->requestMethod == 'POST ' ? 'application/json; charset=utf-8 ' : '' ;
203210 $ now = new DateTime ('now ' , new DateTimeZone ('GMT ' ));
204211 $ dateTime = $ now ->format ("D, d M Y H:i:s T " );
205212 $ endpointAction = $ this ->getAction ();
206213
207- $ message = $ requestMethod ."\n" .$ contentType ."\n" .$ dateTime ."\n" .$ endpointAction ."\n" ;
214+ $ message = $ this -> requestMethod ."\n" .$ contentType ."\n" .$ dateTime ."\n" .$ endpointAction ."\n" ;
208215 $ signature = $ this ->createSignature ($ message , $ this ->getApiSecret ());
209216
210217 $ headers = [
@@ -216,7 +223,7 @@ public function sendData($data)
216223 $ body = json_encode ($ data );
217224
218225 $ httpResponse = $ this ->httpClient ->request (
219- $ requestMethod ,
226+ $ this -> requestMethod ,
220227 $ this ->getEndpoint (),
221228 $ headers ,
222229 $ body
@@ -271,9 +278,4 @@ protected function getItemPriceInteger($item)
271278
272279 return (int ) $ money ->getAmount ();
273280 }
274-
275- protected function getRequestMethod ()
276- {
277- return 'POST ' ;
278- }
279281}
0 commit comments