pp_payflow_iframe_order.tpl
5.74 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<h2><?php echo $text_payment_info; ?></h2>
<table class="table table-striped table-bordered">
<tr>
<td><?php echo $entry_capture_status; ?>: </td>
<td id="capture-status"><?php if ($complete) { ?>
<?php echo $text_complete ?>
<?php } else { ?>
<?php echo $text_incomplete ?>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_capture ?></td>
<td id="complete-entry"><?php if ($complete) { ?>
-
<?php } else { ?>
<?php echo $entry_complete_capture ?>
<input type="checkbox" name="capture-complete" value="1" />
<br />
<input type="text" name="capture-amount" value="0.00" />
<a class="btn btn-primary" id="button-capture" onclick="capture()"><?php echo $button_capture ?></a>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_void ?></td>
<td id="reauthorise-entry"><?php if ($complete) { ?>
-
<?php } else { ?>
<a class="btn btn-primary" id="button-void" onclick="doVoid()"><?php echo $button_void ?></a>
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_transactions ?></td>
<td><table id="transaction-table" class="table table-striped table-bordered">
<thead>
<tr>
<td class="text-left"><?php echo $column_transaction_id ?></td>
<td class="text-left"><?php echo $column_transaction_type ?></td>
<td class="text-left"><?php echo $column_amount ?></td>
<td class="text-left"><?php echo $column_time ?></td>
<td class="text-left"><?php echo $column_actions ?></td>
</tr>
</thead>
<tbody>
<?php foreach ($transactions as $transaction) { ?>
<tr>
<td class="text-left"><?php echo $transaction['transaction_reference'] ?></td>
<td class="text-left"><?php echo $transaction['transaction_type'] ?></td>
<td class="text-left"><?php echo number_format($transaction['amount'], 2) ?></td>
<td class="text-left"><?php echo $transaction['time'] ?></td>
<td class="text-left"><?php foreach ($transaction['actions'] as $action) { ?>
[<a href="<?php echo $action['href'] ?>"><?php echo $action['title'] ?></a>]
<?php } ?></td>
</tr>
<?php } ?>
</tbody>
</table></td>
</tr>
</table>
<script type="text/javascript"><!--
function markAsComplete() {
$('#complete-entry, #reauthorise-entry, #reauthorise-entry').html('-');
$('#capture-status').html('<?php echo $text_complete ?>');
}
function doVoid() {
if (confirm('<?php echo $text_confirm_void; ?>')) {
$.ajax({
type:'POST',
dataType: 'json',
data: {'order_id':<?php echo (int)$order_id; ?>},
url: 'index.php?route=payment/pp_payflow_iframe/void&token=<?php echo $token; ?>',
beforeSend: function() {
$('#button-void').after('<span class="btn btn-primary loading"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i></span>');
$('#button-void').hide();
},
success: function(data) {
if (!data.error) {
$('#capture-status').text('<?php echo $text_complete; ?>');
var html = '';
html += '<tr>';
html += ' <td class="left">' + data.success.transaction_reference + '</td>';
html += ' <td class="left">' + data.success.transaction_type + '</td>';
html += ' <td class="left">' + data.success.amount + '</td>';
html += ' <td class="left">' + data.success.time + '</td>';
html += ' <td class="left"></td>';
html += '</tr>';
$('#transaction-table tbody').append(html);
markAsComplete();
}
if (data.error) {
alert(data.error);
$('#button-void').show();
}
$('.loading').remove();
}
});
}
}
function capture() {
var amount = $('input[name="capture-amount"]').val();
var complete = 0;
if ($('input[name="capture-complete"]').is(':checked')) {
complete = 1;
}
$.ajax({
type:'POST',
dataType: 'json',
data: {'order_id':<?php echo $order_id; ?>, 'amount':amount, 'complete':complete },
url: 'index.php?route=payment/pp_payflow_iframe/capture&token=<?php echo $token; ?>',
beforeSend: function() {
$('#button-capture').after('<span class="btn btn-primary loading"><i class="fa fa-circle-o-notch fa-spin fa-lg"></i></span>');
$('#button-capture').hide();
},
success: function(data) {
if (!data.error) {
var html = '';
html += '<tr>';
html += ' <td class="left">' + data.success.transaction_reference + '</td>';
html += ' <td class="left">' + data.success.transaction_type + '</td>';
html += ' <td class="left">' + data.success.amount + '</td>';
html += ' <td class="left">' + data.success.time + '</td>';
html += ' <td class="left">';
$.each(data.success.actions, function(index, value) {
html += ' [<a href="' + value.href + '">' + value.title + '</a>] ';
});
html += '</td>';
html += '</tr>';
$('#transaction-table tbody').append(html);
if (complete == 1) {
markAsComplete();
}
}
if (data.error) {
alert(data.error);
}
$('#button-capture').show();
$('.loading').remove();
}
});
}
//--></script>