Invoice::list()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Iamolayemi\Paystack\Endpoints;
4
5
class Invoice extends Endpoint
6
{
7
    protected const ENDPOINT = '/paymentrequest';
8
9
    /**
10
     * Create an invoice for payment on your integration.
11
     *
12
     * @param  array<string, mixed>  $payload
13
     *
14
     * @link https://paystack.com/docs/api/#payment-request-create
15
     */
16
    public function create(array $payload): self
17
    {
18
        $this->post($this->url(self::ENDPOINT), $payload);
19
20
        return $this;
21
    }
22
23
    /**
24
     * List payment requests available on your integration.
25
     *
26
     * @param  array<string, mixed>  $query
27
     *
28
     * @link https://paystack.com/docs/api/#payment-request-list
29
     */
30
    public function list(array $query = []): self
31
    {
32
        $this->get($this->url(self::ENDPOINT), $query);
33
34
        return $this;
35
    }
36
37
    /**
38
     * Get details of an invoice on your integration.
39
     *
40
     * @link https://paystack.com/docs/api/#invoice-fetch
41
     */
42
    public function fetch(string $invoice_id): self
43
    {
44
        $this->get($this->url(self::ENDPOINT).'/'.$invoice_id);
45
46
        return $this;
47
    }
48
49
    /**
50
     * Verify details of an invoice on your integration.
51
     *
52
     * @link https://paystack.com/docs/api/#invoice-verify
53
     */
54
    public function verify(string $invoice_code): self
55
    {
56
        $this->get($this->url(self::ENDPOINT).'/verify/'.$invoice_code);
57
58
        return $this;
59
    }
60
61
    /**
62
     * Send notification of an invoice to your customers.
63
     *
64
     * @link https://paystack.com/docs/api/#invoice-send-notification
65
     */
66
    public function notify(string $invoice_code): self
67
    {
68
        $this->post($this->url(self::ENDPOINT).'/notify/'.$invoice_code);
69
70
        return $this;
71
    }
72
73
    /**
74
     * Get invoice metrics for dashboard.
75
     *
76
     * @link https://paystack.com/docs/api/#invoice-total
77
     */
78
    public function totals(): self
79
    {
80
        $this->post($this->url(self::ENDPOINT).'/totals');
81
82
        return $this;
83
    }
84
85
    /**
86
     * Finalize a draft invoice.
87
     *
88
     * @link https://paystack.com/docs/api/#invoice-finalize
89
     */
90
    public function finalize(string $invoice_code): self
91
    {
92
        $this->post($this->url(self::ENDPOINT).'/finalize/'.$invoice_code);
93
94
        return $this;
95
    }
96
97
    /**
98
     * Update an invoice on your integration.
99
     *
100
     * @param  array<string, mixed>  $payload
101
     *
102
     * @link https://paystack.com/docs/api/#payment-request-update
103
     */
104
    public function update(string $invoice_id, array $payload = []): self
105
    {
106
        $this->put($this->url(self::ENDPOINT).'/'.$invoice_id, $payload);
107
108
        return $this;
109
    }
110
111
    /**
112
     * Update an invoice details on your integration.
113
     *
114
     * @link https://paystack.com/docs/api/#invoice-archive
115
     */
116
    public function archive(string $invoice_code): self
117
    {
118
        $this->post($this->url(self::ENDPOINT).'/archive/'.$invoice_code);
119
120
        return $this;
121
    }
122
}
123