-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_invoice.php
More file actions
56 lines (51 loc) · 1.64 KB
/
Copy pathgenerate_invoice.php
File metadata and controls
56 lines (51 loc) · 1.64 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
<?php
// Rubrol PHP Client Example
$url = 'http://localhost:8080/v1/render';
$payload = [
'template' => 'b2b_invoice',
'format' => 'pdf',
'pdf_standard' => 'a-2b',
'data' => [
'invoice_number' => 'INV-2026-PHP01',
'issued_date' => '2026-09-17',
'due_date' => '2026-10-17',
'currency' => 'EUR',
'currency_symbol' => '€',
'vendor' => [
'name' => 'Rubrol Europe SAS',
'tax_id' => 'FR82982391820',
'address' => '10 Rue de la Paix',
'city' => '75002 Paris',
'email' => 'billing@rubrol.com'
],
'customer' => [
'name' => 'Laravel Cloud Enterprise',
'tax_id' => 'NL89201948',
'address' => 'Keizersgracht 421',
'city' => '1016 EK Amsterdam',
'email' => 'billing@laravel.com'
],
'line_items' => [
[
'description' => 'Rubrol Sidecar Cluster License',
'qty' => 1,
'unit_price' => 490.00
]
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_HEADER, true);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($response, 0, $header_size);
$body = substr($response, $header_size);
curl_close($ch);
file_put_contents('php_invoice.pdf', $body);
echo "Generated php_invoice.pdf (" . strlen($body) . " bytes)
";
?>