-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefund.php
72 lines (63 loc) · 1.93 KB
/
refund.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
<?php
use Sadiq\BkashMerchantAPI\BkashMerchantAPI;
require_once __DIR__ . '/config.php';
session_start();
// token genarate & refresh
require_once __DIR__. '/token.php';
// refund form submit
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$requires = [
'paymentID', 'amount', 'trxID', 'sku', 'reason'
];
foreach ($requires as $req) {
if (empty($_POST[$req])) {
exit(json_encode(['message' => $req.' is missing']));
}
}
$bkash = new BkashMerchantAPI;
$bkash->setGrantToken($_SESSION['token']);
if ($refund = $bkash->refundPayment(
$_POST['paymentID'],
$_POST['amount'],
$_POST['trxID'],
$_POST['sku'],
$_POST['reason']
)
) {
// log refund
prependFileLog(log_file, "\n\n- Refund Payment\n{$refund->getResponse()}\n\n");
header('Content-type: application/json');
die($refund->getResponse());
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Refund</title>
<style>
input, button {
min-width: 300px;
margin: 3px;
padding: 5px;
}
</style>
</head>
<body>
<br><br>
<center>
<h2>Bkash Payment Refund</h2>
<form action="./refund.php" method="post">
<input type="text" name="paymentID" placeholder="Payment ID" required><br>
<input type="number" name="amount" id="amountInput" step="0.01" placeholder="Amount" required><br>
<input type="text" name="trxID" placeholder="Transaction ID" required><br>
<input type="text" name="sku" placeholder="SKU" required><br>
<input type="text" name="reason" placeholder="Reason" required><br>
<button type="submit">Refund</button>
</form>
</center>
</body>
</html>