ответ на запрос curl не приходит - PullRequest
0 голосов
/ 09 января 2019

Я выполняю запрос curl. В документации PayTM они пишут, чтобы ударить запрос curl. Они предоставили этот формат ниже: -

Curl Request

curl -X POST https://securegw-stage.paytm.in/theia/processTransaction \
    -H 'cache-control: no-cache' \ 
    -H 'content-type: application/x-www-form-urlencoded' \ 
    -d 'REQUEST_TYPE=RENEW_SUBSCRIPTION&MID=xxxxPG01851465523919&ORDER_ID=OrderRenewTest00000000001&TXN_AMOUNT=40&CHECKSUMHASH=gf+dH5bINiwcVF8ZH8Nbmo4pcrC2lroHSl+h2n+2h7fo3nCAatHqKo2++30UFE0QD4uUuqHWMVrrcdqCKTP"WluqsB+4SlufcSJ1C1QxdQc=&SUBS_ID=1002410'

Я искал и добавил следующий код в php: -

<?php
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
// following files need to be included
require_once("./lib/config_paytm.php");
require_once("./lib/encdec_paytm.php");
$data["MID"] = PAYTM_MERCHANT_MID;
$data["ORDER_ID"] = rand(10000,99999999);
$data["SUBS_ID"] = 12473;
$data["TXN_AMOUNT"] = 1;
$checkSum = getChecksumFromArray($data,PAYTM_MERCHANT_KEY);
$data['CHECKSUMHASH'] = $checkSum;
$url="https://securegw-stage.paytm.in/theia/processTransaction/";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('content-type: application/x-www-form-urlencoded'));

// execute!
$response = curl_exec($ch);

// close the connection, release resources used
curl_close($ch);
// do anpreything you want with your response
var_dump($response);
?>

Вывод будет следующим: -

string(0) ""

Исключенный outpiyt, упомянутый в документе, как показано ниже: -

{ "TXNID":70000965271, "ORDERID":"P0000Ak42KK765456", "TXNAMOUNT":"1.00", "STATUS":"TXN_ACCEPTED", "RESPCODE":"900", "RESPMSG":"Subscription Txn accepted.", "MID":"SPOAJD86027921886450", "SUBS_ID":3001 }
...