-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpay.php
More file actions
139 lines (115 loc) · 4.1 KB
/
Copy pathpay.php
File metadata and controls
139 lines (115 loc) · 4.1 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
require('config.php');
require('includes/dbconnect.php');
require('razorpay-php/Razorpay.php');
session_start();
// Create the Razorpay Order
use Razorpay\Api\Api;
$api = new Api($keyId, $keySecret);
//
// We create an razorpay order using orders api
// Docs: https://docs.razorpay.com/docs/orders
//
$customer_name = $_POST['CUSTOMER_NAME'];
$customer_email = $_POST['CUSTOMER_EMAIL'];
$customer_mobile = $_POST['CUSTOMER_MOBILE'];
$actual_cust_email = $_SESSION['email'];
$v = $_GET['v'];
$_SESSION['v'] = $v;
if(in_array($v, array('ceo','swades'), true) ){
$orderData = [
'receipt' => 3456,
'amount' => 100 * 100, // rupees to paise
'currency' => 'INR',
'payment_capture' => 1 // auto capture
];
}elseif(in_array($v, array('war_of_worlds','bizquiz','adventure','operation_research','pitch_mantra'), true) ){
$orderData = [
'receipt' => 3456,
'amount' => 50 * 100, // rupees to paise
'currency' => 'INR',
'payment_capture' => 1 // auto capture
];
}elseif($v == 'wallstreet'){
if(isset($_POST['paybasic'])) {
$_SESSION['tier'] = 'basic';
$orderData = [
'receipt' => 3456,
'amount' => 75 * 100, // rupees to paise
'currency' => 'INR',
'payment_capture' => 1 // auto capture
];
}elseif(isset($_POST['payadvanced'])) {
$_SESSION['tier'] = 'advanced';
$orderData = [
'receipt' => 3456,
'amount' => 205.64 * 100, // rupees to paise
'currency' => 'INR',
'payment_capture' => 1 // auto capture
];
}
}
$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" => "E-Cell VNIT, Nagpur",
"description" => $v." Enrollment Fee",
"image" => "https://i.imgur.com/byxLZHm.png",
"prefill" => [
"name" => $customer_name,
"email" => $customer_email,
"contact" => $customer_mobile,
],
"notes" => [
"address" => "Hello World",
"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);
?>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
<form action="verify-pay.php?e=<?php echo $v ?> method="POST">
<script
src="https://checkout.razorpay.com/v1/checkout.js"
data-key="<?php echo $data['key']?>"
data-amount="<?php echo $data['amount']?>"
data-currency="INR"
data-name="<?php echo $data['name']?>"
data-image="<?php echo $data['image']?>"
data-description="<?php echo $data['description']?>"
data-prefill.name="<?php echo $data['prefill']['name']?>"
data-prefill.email="<?php echo $data['prefill']['email']?>"
data-prefill.contact="<?php echo $data['prefill']['contact']?>"
data-notes.shopping_order_id="3456"
data-order_id="<?php echo $data['order_id']?>"
<?php if ($displayCurrency !== 'INR') { ?> data-display_amount="<?php echo $data['display_amount']?>" <?php } ?>
<?php if ($displayCurrency !== 'INR') { ?> data-display_currency="<?php echo $data['display_currency']?>" <?php } ?>
>
</script>
<!-- Any extra fields to be submitted with the form but not sent to Razorpay -->
<input type="hidden" name="shopping_order_id" value="3456">
</form>
<script type="text/javascript">
$(document).ready(function(){
$('.razorpay-payment-button').click();
});
</script>