-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheckout.php
57 lines (44 loc) · 1.54 KB
/
checkout.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
<?php
use Raziul\ShurjoPay\ShurjoPayException;
require __DIR__ . '/../vendor/autoload.php';
// load config
$config = require __DIR__ . '/config.php';
// Payload will be sent to ShurjoPay
$payload = [
'currency' => 'BDT',
'amount' => 1000, // amount to be paid
// Order information
'order_id' => '1',
'discsount_amount' => 0,
'disc_percent' => 0,
// Customer information
'client_ip' => '127.0.0.1',
'customer_name' => 'Raziul Islam',
'customer_phone' => '+8801234567890',
'customer_email' => '[email protected]',
'customer_address' => 'Full Address',
'customer_city' => 'City Name',
'customer_state' => 'State Name',
'customer_postcode' => 'Postcode',
'customer_country' => 'Country Name',
// Custom values
'value1' => 'value1',
'value2' => 'value2',
'value3' => 'value3',
'value4' => 'value4'
];
// callback url for success and cancel
$success_url = 'http://localhost/shurjopay/examples/verify.php';
$cancel_url = 'http://localhost/shurjopay/examples/verify.php';
try {
// create ShurjoPay instance
$shurjopay = new \Raziul\ShurjoPay\ShurjoPay($config);
// set callback url
$shurjopay->setCallbackUrl($success_url, $cancel_url);
// make payment
$shurjopay->makePayment($payload); // it will redirect the user to the payment page
// You can also chain methods like below 😎
// ShurjoPay::create($config)->setCallbackUrl($success_url, $cancel_url)->makePayment($payload);
} catch (ShurjoPayException $e) {
echo $e->getMessage();
}