-
Notifications
You must be signed in to change notification settings - Fork 87
/
RefundCreate.php
118 lines (105 loc) · 3.85 KB
/
RefundCreate.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* OpenPayU Examples
*
* @copyright Copyright (c) PayU
* http://www.payu.com
* http://developers.payu.com
*/
require_once realpath(dirname(__FILE__)) . '/../../../lib/openpayu.php';
require_once realpath(dirname(__FILE__)) . '/../../config.php';
if (isset($_POST['orderId']))
$orderId = trim($_POST['orderId']);
?>
<!doctype html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Order Refund</title>
<link rel="stylesheet" href="../../layout/css/bootstrap.min.css">
<link rel="stylesheet" href="../../layout/css/style.css">
<script type="text/javascript" src="../../layout/js/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
$('#amount').blur(function(){
if($('#amount').val()!= 0 && $('#amount').val()<200){
$('#msg').html('<div class="alert alert-danger">Kwota zwrotu częściowego nie może być mniejsza niż 200 ' +
'groszy!</div>')
}else{
$('#msg').html('')
}
})
})
</script>
<div class="container">
<div class="page-header">
<h1>Refund</h1>
</div>
<div id="message"></div>
<div id="unregisteredCardData">
<?php
if (isset($_POST['orderId'])) {
$orderId = trim($_POST['orderId']);
try {
$refund = OpenPayU_Refund::create(
$orderId,
$_POST['description'],
isset($_POST['amount']) ? (int)$_POST['amount'] : null
);
$status_desc = OpenPayU_Util::statusDesc($refund->getStatus());
if($refund->getStatus() == 'SUCCESS'){
echo '<div class="alert alert-success">SUCCESS: '.$status_desc;
echo '</div>';
}else{
echo '<div class="alert alert-warning">'.$refund->getStatus().': '.$status_desc;
echo '</div>';
}
echo '<pre>';
echo '<br>';
print_r($refund->getResponse());
echo '</pre>';
} catch (OpenPayU_Exception $e) {
echo '<pre>';
echo 'Error code: '.$e->getCode();
echo '<br>';
echo 'Error message: '.$e->getMessage();
echo '<br>';
echo '</pre>';
}
} else {
?>
<form action="" method="post" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="order">Order Id</label>
<div class="controls">
<input class="span3" name="orderId" id="order" type="text" value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="amount">Amount</label>
<div class="controls">
<input class="span1" name="amount" id="amount" type="text" value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="description">Description</label>
<div class="controls">
<input class="span3" name="description" id="description" type="text" value=""/>
</div>
</div>
<div class="control-group">
<label class="control-label" for="pay-button"></label>
<div id="msg"></div>
<div class="controls">
<button class="btn btn-success" id="pay-button" type="submit">Make refund</button>
</div>
</div>
</form>
<?php
}
?>
</div>
</div>
</html>