-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.php
41 lines (37 loc) · 1.43 KB
/
request.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
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$contact_no = $_POST['phn_no'];
$amount = $_POST['amount'];
session_start();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://test.instamojo.com/api/1.1/payment-requests/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("X-Api-Key:PUT_API_KEY",
"X-Auth-Token:PUT_AUTH_TOKEN"));
$payload = Array(
'purpose' => 'Donation for ABC Orphanage',
'amount' => $amount,
'phone' => $contact_no,
'buyer_name' => $name,
'redirect_url' => 'https://tsf-task2.herokuapp.com/redirect.php',
'send_email' => true,
'send_sms' => true,
'email' => $email,
'allow_repeated_payments' => false
);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response);
$_SESSION['TID'] = $response->payment_request->longurl;
header('location:'.$response->payment_request->longurl);
die();
}
?>