-
Notifications
You must be signed in to change notification settings - Fork 0
/
pay.php
64 lines (58 loc) · 1.85 KB
/
pay.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php include('include/header.php'); ?>
<title>Razorpay Payment Gateway Integration in PHP</title>
<?php include('include/container.php');?>
<div class="container">
<div class="row">
<h2>Example: Razorpay Payment Gateway Integration in PHP</h2>
<br><br><br>
<?php
require('config.php');
require('razorpay-php/Razorpay.php');
session_start();
use Razorpay\Api\Api;
$api = new Api($keyId, $keySecret);
$orderData = [
'receipt' => 3456,
'amount' => $_POST['amount'] * 100,
'currency' => $_POST['currency'],
'payment_capture' => 1
];
$razorpayOrder = $api->order->create($orderData);
$razorpayOrderId = $razorpayOrder['id'];
$_SESSION['razorpay_order_id'] = $razorpayOrderId;
$displayAmount = $amount = $orderData['amount'];
if ($displayCurrency !== 'INR') {
$url = "https://api.fixer.io/latest?symbols=$displayCurrency&base=INR";
$exchange = json_decode(file_get_contents($url), true);
$displayAmount = $exchange['rates'][$displayCurrency] * $amount / 100;
}
$data = [
"key" => $keyId,
"amount" => $amount,
"name" => $_POST['item_name'],
"description" => $_POST['item_description'],
"image" => "",
"prefill" => [
"name" => $_POST['cust_name'],
"email" => $_POST['email'],
"contact" => $_POST['contact'],
],
"notes" => [
"address" => $_POST['address'],
"merchant_order_id" => "12312321",
],
"theme" => [
"color" => "#F37254"
],
"order_id" => $razorpayOrderId,
];
if ($displayCurrency !== 'INR')
{
$data['display_currency'] = $displayCurrency;
$data['display_amount'] = $displayAmount;
}
$json = json_encode($data);
require("checkout/manual.php");
?>
</div>
<?php include('include/footer.php');?>