-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListOrdersExample.php
More file actions
53 lines (42 loc) · 1.9 KB
/
Copy pathListOrdersExample.php
File metadata and controls
53 lines (42 loc) · 1.9 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
<?php
#-------------------------------------------------------------------------------
# INCLUDE THE CONFIGURATION FILE
#
# This file contains some default environment configuration which are used to
# ensure your examples will run.
#-------------------------------------------------------------------------------
require 'config.php';
#-------------------------------------------------------------------------------
# SETUP CLIENT
#
# Edit your credentials in config.php to use the examples.
#-------------------------------------------------------------------------------
$client = new Vleks\SDK\Client(
VLEKS_API_PUBLIC_KEY, VLEKS_API_PRIVATE_KEY,
VLEKS_MERCHANT_ID, VLEKS_API_CLUSTER
);
#-------------------------------------------------------------------------------
# LIST ORDERS
#-------------------------------------------------------------------------------
try {
$request = new Vleks\SDK\Requests\ListOrders();
$result = $client->listOrders($request);
if ($result->hasOrders()) {
foreach ($result->getOrders() as $order) {
echo 'Order ID: ' . $order->getOrderID() . "\n";
echo 'Status: ' . $order->getStatus() . "\n";
if ($order->hasOrderLines()) {
echo "\n" . 'Orderline(s):' . "\n";
$orderLines = $order->getOrderLines();
foreach ($orderLines->getOrderLine() as $orderLine) {
echo '#' . $orderLine->getOrderLineID() . ' (' . $orderLine->getQuantityOrdered() . 'x - ' . $orderLine->getTitle() . ')' . "\n";
}
}
echo "\n----------------------------\n\n";
}
}
} catch (Vleks\SDK\Exceptions\ClientException $clientException) {
var_dump($clientException->getMessage());
} catch (Vleks\SDK\Exceptions\ServiceException $serviceException) {
var_dump($serviceException->getMessage());
}