-
Notifications
You must be signed in to change notification settings - Fork 0
/
pay.php
84 lines (63 loc) · 2.45 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require('config.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
//
$orderData = [
'receipt' => 'SI_1',
'amount' => 0 * 100, // 2000 rupees in paise
'currency' => 'INR',
'method' => 'emandate',
'payment_capture' => 1 // auto capture
];
$razorpayOrder = $api->order->create($orderData);
$razorpayOrderId = $razorpayOrder['id'];
$_SESSION['razorpay_order_id'] = $razorpayOrderId;
//We create a customer using customer API: https://razorpay.com/docs/getting-started/customers/#creating-a-customer for eMandate
$customerData = [
'name' => $_POST['name-field'],
'email' => $_POST['email-field'],
'contact' => $_POST['contact-field'],
'fail_existing' => 0
];
$customer = $api->customer->create($customerData);
$razorpayCustomerId = $customer['id'];
$_SESSION['razorpay_customer_id'] = $razorpayCustomerId;
$amount = $orderData['amount'];
$data = [
"key" => $keyId,
"amount" => $amount,
"name" => "Mutual Fund",
"description" => "SIP",
"recurring" => 1,
"prefill" => [
"name" => $_POST['name-field'],
"email" => $_POST['email-field'],
"contact" => $_POST['contact-field'],
"method" => "emandate",
//"bank" => "UTIB",
"bank_account[name]" => $_POST['name-field'],
"bank_account[account_number]" => $_POST['account-field'],
"bank_account[ifsc]" => $_POST['ifsc-field'],
"aadhaar[number]" => $_POST['aadhaar-field'],
//"auth_type" => "aadhaar"
],
"notes" => [
"merchant_order_id" => "12312321",
],
"theme" => [
"color" => "brown",
"hide_topbar" => "true",
"image_frame" => "false"
],
"order_id" => $razorpayOrderId,
"customer_id" => $razorpayCustomerId
];
$json = json_encode($data);
require("checkout/manual.php");