ok

Mini Shell

Direktori : /home2/selectio/www/myclassicfit.com/resources/views/web-views/
Upload File :
Current File : /home2/selectio/www/myclassicfit.com/resources/views/web-views/phonepe-checkout-payment.blade.php

<?php
    $amount = 1; 
    $merchantKey ='14fa5465-f8a7-443f-8477-f986b8fcfde9';  
  $data = array(
      "merchantId" => "PGTESTPAYUAT77",  
      "merchantTransactionId" => bin2hex(random_bytes(6)),
      "merchantUserId" => "MU125",
      "amount" => $amount*100,
      "redirectUrl" => route('phonepe-checkout-complete'),
      "redirectMode" => "GET",
      "callbackUrl" => route('phonepe-checkout-complete'),
      "mobileNumber" => "9487202215",
      "paymentInstrument" => array(
          "type" => "PAY_PAGE"
      )
  );
  // Convert the Payload to JSON and encode as Base64
  $payloadMain = base64_encode(json_encode($data));

  $payload = $payloadMain."/pg/v1/pay".$merchantKey;
  $Checksum = hash('sha256', $payload);
  $Checksum = $Checksum.'###1';
//https://api.phonepe.com/apis/hermes/pg/v1/pay
//https://api-preprod.phonepe.com/apis/pg-sandbox/pg/v1/pay
  $curl = curl_init();
  curl_setopt_array($curl, [
    CURLOPT_URL => "https://api-preprod.phonepe.com/apis/pg-sandbox/pg/v1/pay",
    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