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
use Srmklive\PayPal\Traits\PayPalAPI\InvoiceSearch\Filters;
6
 
7
trait InvoicesSearch
8
{
9
    use Filters;
10
 
11
    /**
12
     * Search and return existing invoices.
13
     *
14
     * @param int  $page
15
     * @param int  $size
16
     * @param bool $totals
17
     *
18
     * @throws \Throwable
19
     *
20
     * @return array|\Psr\Http\Message\StreamInterface|string
21
     *
22
     * @see https://developer.paypal.com/docs/api/invoicing/v2/#invoices_list
23
     */
24
    public function searchInvoices(int $page = 1, int $size = 20, bool $totals = true)
25
    {
26
        $totals = ($totals === true) ? 'true' : 'false';
27
 
28
        if (collect($this->invoice_search_filters)->count() < 1) {
29
            $this->invoice_search_filters = [
30
                'currency_code' => $this->getCurrency(),
31
            ];
32
        }
33
 
34
        $this->apiEndPoint = "v2/invoicing/search-invoices?page={$page}&page_size={$size}&total_required={$totals}";
35
 
36
        $this->options['json'] = $this->invoice_search_filters;
37
 
38
        $this->verb = 'post';
39
 
40
        return $this->doPayPalRequest();
41
    }
42
}