-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpayment.php
71 lines (63 loc) · 1.98 KB
/
payment.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
<?php
session_start();
if (!isset($_POST['submit'])) {
header('location: e404.php');
}
$purpose = "Payment";
$amount = $_POST["price"];
$name = $_POST["name"];
$phone = 9825183134;
$email = $_POST["email"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
if (!empty($_POST["address"]) && !empty($_POST["city"]) && !empty($_POST["address"]) && !empty($_POST["zip"]) && !empty($_POST["state"])) {
$_SESSION['amount'] = $amount;
$_SESSION['name'] = $name;
$_SESSION['phone'] = $phone;
$_SESSION['email'] = $email;
$_SESSION['address'] = $address;
$_SESSION['city'] = $city;
$_SESSION['state'] = $state;
$_SESSION['zip'] = $zip;
$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:test_b3da34ea51a924f0bef6db2cedf",
"X-Auth-Token:test_9e75e6828e45244a7637cf101ee"
)
);
$payload = array(
'purpose' => $purpose,
'amount' => $amount,
'phone' => $phone,
'buyer_name' => $name,
'redirect_url' => 'http://localhost/addiction/thankyou.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);
echo "<pre>";
print_r($response);
header('location:' . $response->payment_request->longurl);
} else {
$error = true;
$_SESSION['error'] = "All Field Cannot be Empty";
echo '<script>
window.location.href = "pay.php?error=true"
</script>';
exit();
}