Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
676 lars 1
<?php
2
 
3
namespace Srmklive\PayPal\Traits\PayPalAPI;
4
 
5
trait InvoicesTemplates
6
{
7
    /**
8
     * Create a new invoice template.
9
     *
10
     * @param array $data
11
     *
12
     * @throws \Throwable
13
     *
14
     * @return array|\Psr\Http\Message\StreamInterface|string
15
     *
16
     * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_create
17
     */
18
    public function createInvoiceTemplate(array $data)
19
    {
20
        $this->apiEndPoint = 'v2/invoicing/templates';
21
 
22
        $this->options['json'] = $data;
23
 
24
        $this->verb = 'post';
25
 
26
        return $this->doPayPalRequest();
27
    }
28
 
29
    /**
30
     * Get list of invoice templates.
31
     *
32
     * @param int    $page
33
     * @param int    $size
34
     * @param string $fields
35
     *
36
     * @throws \Throwable
37
     *
38
     * @return array|\Psr\Http\Message\StreamInterface|string
39
     *
40
     * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_list
41
     */
42
    public function listInvoiceTemplates(int $page = 1, int $size = 20, string $fields = 'all')
43
    {
44
        $this->apiEndPoint = "v2/invoicing/templates?page={$page}&page_size={$size}&fields={$fields}";
45
 
46
        $this->verb = 'get';
47
 
48
        return $this->doPayPalRequest();
49
    }
50
 
51
    /**
52
     * Delete an invoice template.
53
     *
54
     * @param string $template_id
55
     *
56
     * @throws \Throwable
57
     *
58
     * @return array|\Psr\Http\Message\StreamInterface|string
59
     *
60
     * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_delete
61
     */
62
    public function deleteInvoiceTemplate(string $template_id)
63
    {
64
        $this->apiEndPoint = "v2/invoicing/templates/{$template_id}";
65
 
66
        $this->verb = 'delete';
67
 
68
        return $this->doPayPalRequest(false);
69
    }
70
 
71
    /**
72
     * Update an existing invoice template.
73
     *
74
     * @param string $template_id
75
     * @param array  $data
76
     *
77
     * @throws \Throwable
78
     *
79
     * @return array|\Psr\Http\Message\StreamInterface|string
80
     *
81
     * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_update
82
     */
83
    public function updateInvoiceTemplate(string $template_id, array $data)
84
    {
85
        $this->apiEndPoint = "v2/invoicing/templates/{$template_id}";
86
 
87
        $this->options['json'] = $data;
88
 
89
        $this->verb = 'put';
90
 
91
        return $this->doPayPalRequest();
92
    }
93
 
94
    /**
95
     * Show details for an existing invoice.
96
     *
97
     * @param string $template_id
98
     *
99
     * @throws \Throwable
100
     *
101
     * @return array|\Psr\Http\Message\StreamInterface|string
102
     *
103
     * @see https://developer.paypal.com/docs/api/invoicing/v2/#templates_get
104
     */
105
    public function showInvoiceTemplateDetails(string $template_id)
106
    {
107
        $this->apiEndPoint = "v2/invoicing/templates/{$template_id}";
108
 
109
        $this->verb = 'get';
110
 
111
        return $this->doPayPalRequest();
112
    }
113
}