ok

Mini Shell

Direktori : /home2/selectio/www/ramali.in/
Upload File :
Current File : /home2/selectio/www/ramali.in/payment-redirect.php

<?php
ob_start();
$amount = $_GET['amount'];
$order_id = $_GET['order_id'];
/*$amount = 1;*/
$merchantKey = 'a6fa8700-fb7a-4d2b-9bc1-b2b04b6f4457';  // Live - TNTRANSCONNECT
/*$merchantKey ='14fa5465-f8a7-443f-8477-f986b8fcfde9'; */  // Testing : 14fa5465-f8a7-443f-8477-f986b8fcfde9

/*$url = $booking_id;
$encryptionKey = 'TTC';
$encryptedUrl = openssl_encrypt($url, 'aes-256-cbc', $encryptionKey, 0, $encryptionKey);
$code = urlencode($encryptedUrl);*/


$encryptionKey = 'RAMALI';

// Generate a random IV (Initialization Vector) of 16 bytes
$iv = openssl_random_pseudo_bytes(16);

// URL to encrypt
$url = $order_id;

// Encrypt the URL
$encryptedUrl = openssl_encrypt($url, 'aes-256-cbc', $encryptionKey, 0, $iv);

// To pass both the IV and the encrypted URL, you can concatenate them
$ivAndEncryptedUrl = $iv . $encryptedUrl;

// Encode the combined string for safe URL use
$code = urlencode(base64_encode($ivAndEncryptedUrl));



  
  $data = array(
      "merchantId" => "M14IIOAXCPGS",  // Live - Ramli
     /* "merchantId" => "PGTESTPAYUAT77",*/ // Testing - Ramli : PGTESTPAYUAT77
      "merchantTransactionId" => bin2hex(random_bytes(6)),
      "merchantUserId" => "MU125",
      "amount" => $amount*100,
      "redirectUrl" => "https://ramali.in/order-complete.php?code=$order_id&amount=$amount",
      "redirectMode" => "POST",
      "callbackUrl" => "https://ramali.in/order-complete.php?code=$order_id&amount=$amount",
      "mobileNumber" => "9345854079",
      "paymentInstrument" => array(
      "type" => "PAY_PAGE"
      )
  );
  $payloadMain = base64_encode(json_encode($data));

  $payload = $payloadMain."/pg/v1/pay".$merchantKey;
  $Checksum = hash('sha256', $payload);
  $Checksum = $Checksum.'###1';
  
  $curl = curl_init();
  curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.phonepe.com/apis/hermes/pg/v1/pay", // Live - Ramli
   /* CURLOPT_URL => "https://api-preprod.phonepe.com/apis/pg-sandbox/pg/v1/pay",*/ // Testing - Ramali
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => json_encode([
      'request' => $payloadMain
    ]),
    CURLOPT_HTTPHEADER => [
      "Content-Type: application/json",
      "X-VERIFY: ".$Checksum,
      "accept: application/json"
    ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
     header('Location: paymentfailed.php?cURLError='.$err);
  } else {
      $responseData = json_decode($response, true);
      $url = $responseData['data']['instrumentResponse']['redirectInfo']['url'];
      header('Location: '.$url);
  }
  
?>

Zerion Mini Shell 1.0