-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
82 lines (68 loc) · 1.82 KB
/
Copy pathtest.php
File metadata and controls
82 lines (68 loc) · 1.82 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
<?php
declare(strict_types=1);
require_once __DIR__ . '/vendor/autoload.php';
use BeycanPress\FreshBooks\Connection;
use BeycanPress\FreshBooks\Model\InvoiceLine;
$connection = new Connection(
'0b57a2d8d057385aeeed05f4af6413b4ca4cc0f48deb632b9e589bea792b8da5',
'56b5b2c24add470de3c8dcd9b3096724e9eb96efbad3244c4f0df16415fe6007',
'https://hosting.beycanpress.net/freshbooks'
);
$accounts = $connection->getAccounts();
$secondAccount = array_values($accounts)[1];
$connection->setAccount($secondAccount->account_id);
$email = "test@gmail.com";
$client = $connection->client()->searchByEmail($email);
if (!$client) {
$client = $connection->client()
->setEmail($email)
->setFirstName("Test")
->setLastName("Spec")
->setCurrencyCode('USD')
->create();
}
/**
* @return void
*/
function invoicePayment(): void
{
global $connection, $client;
$line = (new InvoiceLine())
->setName("Test Item")
->setAmount((object) [
'amount' => 100,
'currency_code' => 'USD'
])
->setQuantity(1);
$invoice = $connection->invoice()
->setStatus("draft")
->setCustomerId($client->getId())
->setCreateDate(date("Y-m-d"))
->setLines([$line])
->create();
$connection->payment()
->setInvoiceId($invoice->getId())
->setAmount((object) [
"amount" => $invoice->getOutstanding()->amount
])
->setDate(date("Y-m-d"))
->setType("2Checkout")
->create();
}
/**
* @return void
*/
function createExpense(): void
{
global $connection;
$connection->expense()
->setAmount((object) [
"amount" => "10",
"code" => "USD"
])
->setStaffId(1)
->setDate(date('Y-m-d'))
->setCategoryId(7397723)
->setVendor("PayPal Pte. Ltd.")
->create();
}