-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkomfortkasse_receive.php
69 lines (51 loc) · 1.6 KB
/
komfortkasse_receive.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
<?php
// Komfortkasse Generic Example
// This file will receive read requests and payment status updates from Komfortkasse
include_once ('komfortkasse_settings.php');
include_once ('komfortkasse_buildorder.php');
// ----- get URL parameters -----
if ($_POST ['action'])
$action = urldecode($_POST ['action']);
else
$action = urldecode($_GET ['action']);
if ($_POST ['o'])
$request = base64_decode(urldecode($_POST ['o']));
else
$request = base64_decode(urldecode($_GET ['o']));
$o = ''; // in $o, we store our output
// ------ read orders ------
if ($action == 'readorders') {
if ($request == 'all') {
// step 1: return order numbers only (as CSV - sorry)
$order_numbers = file('order_numbers.txt', FILE_IGNORE_NEW_LINES);
foreach ( $order_numbers as $order_number ) {
$o = $o . csv($order_number);
}
} else {
// step 2: return order details (url encoded, one per line)
$ex = explode(';', $request);
foreach ( $ex as $id ) {
getorder($id);
$query_raw = http_build_query($order);
$query_enc = base64_encode($query_raw);
$o = $o . "\n";
}
}
}
// ------ update payment order status ------
if ($action == 'updateorders') {
$lines = explode("\n", $request);
foreach ( $lines as $line ) {
$col = explode(';', $line);
$id = trim($col [0]);
if ($id) {
$status = trim($col [1]);
$callbackid = (count($col) > 2) ? trim($col [2]) : null;
file_put_contents('received_updates.txt', date('d.M.Y H:i:s') . ' ' . $id . ' ' . $status . ' ' . $callbackid . "\n", FILE_APPEND);
$o = $o . csv($id);
}
}
}
// ----- output -----
echo base64_encode($o);
?>