I’m integrating a payment gateway using gateway command pool.
This is di.xml
<virtualType name="AuthorizeCommand" type="MagentoPaymentGatewayCommandGatewayCommand">
<arguments>
<argument name="requestBuilder" xsi:type="object">AuthorizationRequest</argument>
<argument name="transferFactory" xsi:type="object">InternationalSampleGatewayHttpTransferFactory</argument>
<argument name="client" xsi:type="object">InternationalSampleGatewayHttpClientClientMock</argument>
</arguments>
</virtualType>
This is TransferFactory.php
public function create(array $request) {
return $this->transferBuilder
->setBody($request)
->setMethod('Curl::POST')
->setHeaders(['Content-Type' => 'application/json'])
->setUri('https://api-gateway-sample-payments.com/transactions')
->build();
}
This is ClientMock.php
public function placeRequest(TransferInterface $transferObject)
{
//response
}
How to get CURL response in placeRequest
?
How can we redirect to payment gateway page after this CURL operation?
Do we need to write separate CURL operations under placeRequest
?
Please advise, I have been in a circle for days, less sleep and its catching the dateline..
Thanks
2
Answers
We should perform CURL action in ClientMock – placeRequest().
The flow of the payment gateway command pool is:
To use curl, use dependency injection to get an instance of the Magento Curl Client. This is easily done by
1: importing curl with the following line at the top of your MockClient.php file:
For more details on the Magento Curl Client check this link