-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
34 lines (26 loc) · 979 Bytes
/
example.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
<?php
/**
* Yepster SDK example
*/
// require_once 'Yepster/autoload.php'; // Uncomment if autoloading doesn't work
$invoice = Yepster\CreateInvoice::model()
->setApiKey ('6ba19adb0af1c3ec31220072d73080df04b1ef271ac031ca508ef045bccec357')
->addDetail ('name', 'Yellow Melon B.V.')
->addDetail ('street', 'Kleine koppel')
->addDetail ('housenumber', '52')
->addDetail ('postcode', '3812PH')
->addDetail ('city', 'Amersfoort')
->addDetail ('email', '[email protected]');
// Add invoice line
$invoice->addInvoiceLine ('First product', 2.0, 100, 21);
$invoice->addInvoiceLine ('Second product', 2.0, 250, 21);
// Execute
try {
$result = $invoice->exec();
}
catch (Exception $e) {
if ($e instanceof Yepster\Exception) echo "Yepster returned an error: ".$e->getMessage();
}
if ($result['status'] == 'success')
echo 'Yepster created the invoice: #' . $result['externalid']; else
echo 'Could not create invoice: ' . $result['error'];