-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpay.php
105 lines (88 loc) · 3.43 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
//echo '<pre>';
//print_r($_POST);
//echo '</pre>';
$amount = $_POST['amount'];
$pres_id = $_POST['prescription_id'];
/* PHP */
$post_data = array();
$post_data['store_id'] = "mlee5f74aac36ddbf";
$post_data['store_passwd'] = "mlee5f74aac36ddbf@ssl";
$post_data['total_amount'] = "$amount";
$post_data['currency'] = "BDT";
$post_data['tran_id'] = "SSLCZ_TEST_".uniqid();
// need to change this url in sandbox account and here both links
$post_data['success_url'] = "http://localhost/hms/success.php";
$post_data['fail_url'] = "http://localhost/new_sslcz_gw/fail.php";
$post_data['cancel_url'] = "http://localhost/new_sslcz_gw/cancel.php";
# $post_data['multi_card_name'] = "mastercard,visacard,amexcard"; # DISABLE TO DISPLAY ALL AVAILABLE
# EMI INFO
$post_data['emi_option'] = "1";
$post_data['emi_max_inst_option'] = "9";
$post_data['emi_selected_inst'] = "9";
# CUSTOMER INFORMATION
$post_data['cus_name'] = "Mottasin Leemon";
$post_data['cus_email'] = "lmottasin@gmail.com";
$post_data['cus_add1'] = "Dhaka";
$post_data['cus_add2'] = "Dhaka";
$post_data['cus_city'] = "Dhaka";
$post_data['cus_state'] = "Dhaka";
$post_data['cus_postcode'] = "1000";
$post_data['cus_country'] = "Bangladesh";
$post_data['cus_phone'] = "01780976220";
$post_data['cus_fax'] = "01711111111";
# SHIPMENT INFORMATION
$post_data['ship_name'] = "testmlee3biu";
$post_data['ship_add1 '] = "Dhaka";
$post_data['ship_add2'] = "Dhaka";
$post_data['ship_city'] = "Dhaka";
$post_data['ship_state'] = "Dhaka";
$post_data['ship_postcode'] = "1000";
$post_data['ship_country'] = "Bangladesh";
# OPTIONAL PARAMETERS
$post_data['value_a'] = "$pres_id";
$post_data['value_b '] = "ref002";
$post_data['value_c'] = "ref003";
$post_data['value_d'] = "ref004";
# CART PARAMETERS
$post_data['cart'] = json_encode(array(
array("product"=>"DHK TO BRS AC A1","amount"=>"200.00"),
array("product"=>"DHK TO BRS AC A2","amount"=>"200.00"),
array("product"=>"DHK TO BRS AC A3","amount"=>"200.00"),
array("product"=>"DHK TO BRS AC A4","amount"=>"200.00")
));
$post_data['product_amount'] = "100";
$post_data['vat'] = "5";
$post_data['discount_amount'] = "5";
$post_data['convenience_fee'] = "3";
# REQUEST SEND TO SSLCOMMERZ
$direct_api_url = "https://sandbox.sslcommerz.com/gwprocess/v3/api.php";
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $direct_api_url );
curl_setopt($handle, CURLOPT_TIMEOUT, 30);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($handle, CURLOPT_POST, 1 );
curl_setopt($handle, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE); # KEEP IT FALSE IF YOU RUN FROM LOCAL PC
$content = curl_exec($handle );
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($code == 200 && !( curl_errno($handle))) {
curl_close( $handle);
$sslcommerzResponse = $content;
} else {
curl_close( $handle);
echo "FAILED TO CONNECT WITH SSLCOMMERZ API";
exit;
}
# PARSE THE JSON RESPONSE
$sslcz = json_decode($sslcommerzResponse, true );
if(isset($sslcz['GatewayPageURL']) && $sslcz['GatewayPageURL']!="" ) {
# THERE ARE MANY WAYS TO REDIRECT - Javascript, Meta Tag or Php Header Redirect or Other
# echo "<script>window.location.href = '". $sslcz['GatewayPageURL'] ."';</script>";
echo "<meta http-equiv='refresh' content='0;url=".$sslcz['GatewayPageURL']."'>";
# header("Location: ". $sslcz['GatewayPageURL']);
exit;
} else {
echo "JSON Data parsing error!";
}