Backups Created:
/home/japatmex/public_html/wp-content/edit-wolf.php
Savvy
W
olf -
MANAGER
Edit File: Paytm.php
<?php require_once APPPATH . "/libraries/paytm/PaytmChecksum.php"; /** * Generate checksum by parameters we have * Find your Merchant ID, Merchant Key and Website in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys */ /* *define('PAYTM_MID', 'PAYTM_MID_HERE'); *define('PAYTM_MERCHANT_KEY', 'PAYTM_MERCHANT_KEY_HERE'); *define('PAYTM_WEBSITE', 'DEFAULT'); *define('PAYTM_ENVIRONMENT', 'https://securegw-stage.paytm.in'); */ class Paytm { private $AMOUNT; private $ORDER_ID; private $PAYTM_MID; private $PAYTM_MERCHANT_KEY; private $PAYTM_WEBSITE; private $PAYTM_ENVIRONMENT; private $CALL_BACK_URL; function __construct($params) { $this->PAYTM_WEBSITE = "DEFAULT"; $this->PAYTM_ENVIRONMENT = "https://securegw.paytm.in"; $this->ORDER_ID = $params['invId'];//.'-'.time(); // "PYTM_BLINK_".time(); // $this->PAYTM_MID = $params['m_id']; $this->AMOUNT = $params['credits']; $this->PAYTM_MERCHANT_KEY = $params['m_key']; $this->CALL_BACK_URL = $params['urlWebhook']; } function getTransactionToken($currency){ $amount = $this->AMOUNT; $callbackUrl = $this->CALL_BACK_URL; $domainName = $_SERVER['HTTP_HOST']; $pieces = explode('.', $domainName); $paytmParams["body"] = array( "requestType" => "Payment", "mid" => $this->PAYTM_MID, "websiteName" => $pieces[1], "orderId" => $this->ORDER_ID, "callbackUrl" => $callbackUrl, "txnAmount" => array( "value" => $amount, "currency" => $currency, ), "userInfo" => array( "custId" => "CUST_".time(), ), "channelId" => "WEB", ); $generateSignature = PaytmChecksum::generateSignature(json_encode($paytmParams['body'], JSON_UNESCAPED_SLASHES), $this->PAYTM_MERCHANT_KEY); //d($generateSignature); $paytmParams["head"] = array( "signature" => $generateSignature ); $url = $this->PAYTM_ENVIRONMENT."/theia/api/v1/initiateTransaction?mid=". $this->PAYTM_MID ."&orderId=". $this->ORDER_ID; //var_dump($url); $getcURLResponse = $this->getcURLRequest($url, $paytmParams); //echo "<pre>"; print_r($getcURLResponse); if(!empty($getcURLResponse['body']['resultInfo']['resultStatus']) && $getcURLResponse['body']['resultInfo']['resultStatus'] == 'S'){ $result = array('success' => true, 'orderId' => $this->ORDER_ID, 'txnToken' => $getcURLResponse['body']['txnToken'], 'amount' => $amount, 'message' => $getcURLResponse['body']['resultInfo']['resultMsg']); }else{ $result = array('success' => false, 'orderId' => $this->ORDER_ID, 'txnToken' => '', 'amount' => $amount, 'message' => $getcURLResponse['body']['resultInfo']['resultMsg']); } //echo "<pre>"; print_r($result); die; return $result; } function getcURLRequest($url , $postData = array(), $headers = array("Content-Type: application/json")){ $post_data_string = json_encode($postData, JSON_UNESCAPED_SLASHES); $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); $response = curl_exec($ch); return json_decode($response,true); } function getSiteURL(){ $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; return str_replace(' ', '', $actual_link); } //$result = getTransactionToken(); function transactionStatus($transactionToken) { //$result = getTransactionToken(); /* initialize an array */ $paytmParams = array(); /* body parameters */ $paytmParams["body"] = array( "mid" => $this->PAYTM_MID, /* Enter your order id which needs to be check status for */ "orderId" => $this->ORDER_ID, ); $checksum = PaytmChecksum::generateSignature(json_encode($paytmParams["body"], JSON_UNESCAPED_SLASHES), $this->PAYTM_MERCHANT_KEY); /* head parameters */ $paytmParams["head"] = array( "signature" => $checksum ); /* prepare JSON string for request */ $post_data = json_encode($paytmParams, JSON_UNESCAPED_SLASHES); $url = PAYTM_ENVIRONMENT."/v3/order/status"; $getcURLResponse = getcURLRequest($url, $paytmParams); return $getcURLResponse; } } //error_reporting(E_ALL); //ini_set('display_errors', 'on'); //$wompi = new wompiGSMTool(); //$wompi->process_payment(1);