0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.143.7.112


Current Path : /var/www/oasis/src/
Upload File :
Current File : /var/www/oasis/src/payPhi.php

<?php

// PayPhi Payment Gateway Integration Example

// Configuration
$appno = '1000023723';
$regno = 'Jssstu00001';
$merchantId = 'T_21225';
$secretKey = 'abc';
$endpointUrl = 'https://qa.phicommerce.com/pg/api/v2/initiateSale';
$returnURL = 'https://qa.phicommerce.com/pg/api/merchant';

// HMAC Digest Function
function hmacDigest($msg, $keyString) {
    return hash_hmac('sha256', $msg, $keyString);
}

$date = date('YmdHis');
// var_dump($date);die();
// Payment Details
$data = [
    'merchantId' => 'T_21225',
    'merchantTxnNo' => 'Txn'.$date,
    'amount' => '1.00',
    'currencyCode' => '356',
    'payType' => '0',
    'customerEmailID' => 'shailaja.kashid@phicommerce.com',
    'transactionType' => 'SALE',
    'returnURL' => $returnURL,
    'txnDate' => $date,
    'addParam1' => $appno,
    'addParam2' => $regno,
];

// Generate Secure Hash
$hashText = $data['amount'] . $data['currencyCode'] . $data['customerEmailID'] . $data['merchantId'] . $data['merchantTxnNo'] . $data['payType'] . $data['returnURL'] . $data['transactionType'] . $data['txnDate'];
$data['secureHash'] = hmacDigest($hashText, $secretKey, $appno, $regno);

// Initialize cURL
$ch = curl_init($endpointUrl);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

// Execute cURL and Get Response
$response = curl_exec($ch);
curl_close($ch);

// Process Response
$responseData = json_decode($response, true);

if (isset($responseData['responseCode']) && $responseData['responseCode'] == 'R1000') {
    $redirectUrl = $responseData['redirectURI'] . '?tranCtx=' . $responseData['tranCtx'];
    header('Location: ' . $redirectUrl);
    exit;
} else {
    echo 'Error: ' . $responseData['responseCode'];
}

?>