I'm implementing a Drupal WebForm Handler for posting data to the PayU Web Checkout Integration after submission, after hours of trying I started to think there was a problem with the Guzzle Client, so I took off the code from Drupal to test separately. I used a simple Rest API GET request and worked fine, however this POST request still doesn't return anything and I've tried everything from working with streams to changing Guzzle versions as mentioned here. I've used Postman as well and things work fine there.
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
require_once './vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Psr7;
//use GuzzleHttp\Stream\Stream;
try {
$client = new Client();
//$post_url = $this->configuration['submission_url'];
$post_url = 'https://sandbox.gateway.payulatam.com/ppp-web-gateway';
//$response = $client->request('GET', $post_url);
$response = $client->request('POST', $post_url,[
'debug' => true,
'form_params' => [
'merchantId' => '508029',
'ApiKey' => '4Vj8eK4rloUd272L48hsrarnUA',
'referenceCode' => 'TestPayU',
'accountId' => '512326',
'description' => 'Test PAYU',
'amount' => '3',
'tax' => '0',
'taxReturnBase' => '0',
'currency' => 'USD',
'signature' => 'ba9ffa71559580175585e45ce70b6c37',
'test' => '1',
'buyerEmail' => 'test@test.com'
]
]);
//$response = Psr7\stream_for($response->getBody());
var_dump($response->getBody()->getContents());
}
catch(Exception $e) {
echo($e->getMessage());
}
This is the debug report. I'd appreciate any help. Thanks.
* Trying 69.20.41.99... * Connected to sandbox.gateway.payulatam.com
(69.20.41.99) port 443 (#0) * Cipher selection:
ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH *
successfully set certificate verify locations: * CAfile:
/Applications/DevDesktop/common/cert/cacert.pem CApath: none * SSL
connection using TLSv1.2 / AES256-SHA256 * Server certificate: *
subject: OU=Domain Control Validated; OU=COMODO SSL Unified
Communications; CN=payulatam.com * start date: 2017-06-07 00:00:00 GMT *
expire date: 2019-06-05 23:59:59 GMT * subjectAltName:
sandbox.gateway.payulatam.com matched * issuer: C=GB; ST=Greater
Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain
Validation Secure Server CA * SSL certificate verify ok. > POST /ppp-
web-gateway HTTP/1.1 Host: sandbox.gateway.payulatam.com User-Agent:
GuzzleHttp/6.2.1 curl/7.44.0 PHP/7.0.14 Content-Type: application/x-www-
form-urlencoded Content-Length: 234 * upload completely sent off: 234
out of 234 bytes < HTTP/1.1 302 Found < Set-Cookie:
JSESSIONID=79253C01031875A1B442649D8B824674.gateway-nodo1;
Path=/ppp-web-gateway/; Secure; HttpOnly < X-FRAME-OPTIONS:
SAMEORIGIN < Set-Cookie: cookie-pol-checkout-version_512326=V2;
Expires=Fri, 28-Sep-2018 22:54:23 GMT; Path=/ppp-web-gateway/;
Secure < Location: /ppp-web-gateway/page-redirect.zul < Content-
Length: 0 < Date: Tue, 03 Oct 2017 22:54:22 GMT < Server: PayU
server < * Connection #0 to host sandbox.gateway.payulatam.com left
intact * Found bundle for host sandbox.gateway.payulatam.com:
0x7918c650 * Re-using existing connection! (#0) with host
sandbox.gateway.payulatam.com * Connected to
sandbox.gateway.payulatam.com (69.20.41.99) port 443 (#0) > GET
/ppp-web-gateway/page-redirect.zul HTTP/1.1 Host:
sandbox.gateway.payulatam.com User-Agent: GuzzleHttp/6.2.1
curl/7.44.0 PHP/7.0.14 Content-Type: application/x-www-form-
urlencoded < HTTP/1.1 200 OK < Set-Cookie:
JSESSIONID=EF0110093412FCDF3E56DD15F1937F30.gateway-nodo1;
Path=/ppp-web-gateway/; Secure; HttpOnly < X-FRAME-OPTIONS:
SAMEORIGIN < Set-Cookie: cookie-
pol=pol_190_238_194_79_1507071263918; Domain=pagosonline.net;
Expires=Fri, 28-Sep-2018 22:54:23 GMT; Path=/; Secure < Content-
Language: en-US < Content-Length: 0 < Date: Tue, 03 Oct 2017
22:54:22 GMT < Server: PayU server < * Connection #0 to host
sandbox.gateway.payulatam.com left intact string(0) ""