diff --git a/doc/get-payment.md b/doc/get-payment.md deleted file mode 100644 index 1e4fbb1..0000000 --- a/doc/get-payment.md +++ /dev/null @@ -1,11 +0,0 @@ -# Get Information about payment - -To get information about payment just simply call: - -```php -$payment = $thePayClient->getPayment('49096fe3-872d-3cbe-b908-2806ae2d7c79'); -``` - -The only parameter of method **getPayment** is a payment UID and the payment has to belong to the project which is configured in TheConfig. - -You will get object describing the payment. diff --git a/doc/get-payments.md b/doc/get-payments.md deleted file mode 100644 index c0e5ae4..0000000 --- a/doc/get-payments.md +++ /dev/null @@ -1,32 +0,0 @@ -# Get Payments - -To get payments just simply call: - -```php -/** @var \ThePay\ApiClient\TheClient $thePayClient */ -$filters = new \ThePay\ApiClient\Filter\PaymentsFilter(); -$paymentPaginatedCollection = $thePayClient->getPayments($filters); -``` - -The first parameter of method **getPayments** is filter object `\ThePay\ApiClient\Filter\PaymentsFilter()`. All filter parameters are described in Apiary. - -Second and third parameter is used for pagination, where first is page number and third is number of records per page. Parameters are not required. - -You will get object `ThePay\ApiClient\Model\Collection\PaymentCollection`, which contains collection of payments, current page number, number of records per page and helper methods. - -You can print all records by this call: - -```php -/** @var \ThePay\ApiClient\TheClient $thePayClient */ -$filters = new \ThePay\ApiClient\Filter\PaymentsFilter(); -$page = 1; -do { - $collection = $thePayClient->getPayments($filters, $page); - - foreach ($collection->all() as $payment) { - // print logic - } - - $page = $collection->getPage() + 1; -} while($collection->hasNextPage()); -``` diff --git a/doc/index.md b/doc/index.md index 5f6c730..6402665 100644 --- a/doc/index.md +++ b/doc/index.md @@ -28,11 +28,9 @@ [Creating payment](create-payment.md) -[Preauth payment](preauth-payments.md) - -[Get Information about payment](get-payment.md) +[Retrieving payments](retrieve-payments.md) -[Get payments](get-payments.md) +[Preauth payment](preauth-payments.md) [Payment events](payment-events.md) diff --git a/doc/retrieve-payments.md b/doc/retrieve-payments.md new file mode 100644 index 0000000..0991f8e --- /dev/null +++ b/doc/retrieve-payments.md @@ -0,0 +1,61 @@ +# Retrieving payments + +Use these methods to retrieve payment details from ThePay API — either a single payment by UID or multiple payments using filters and pagination. + +## Get a Single Payment + +To retrieve information about a single payment, call: + +```php +$payment = $thePayClient->getPayment('49096fe3-872d-3cbe-b908-2806ae2d7c79'); +``` + +**Parameters:** +- string `$uid` — Unique identifier (UID) of the payment. + +The payment must belong to the project configured in TheConfig. + +**Returns:** + +An object describing the payment. + +## Get Multiple Payments + +To retrieve multiple payments, you can use filters and pagination: + +```php +/** @var \ThePay\ApiClient\TheClient $thePayClient */ +$filters = new \ThePay\ApiClient\Filter\PaymentsFilter(); +$paymentPaginatedCollection = $thePayClient->getPayments($filters); +``` + +**Parameters:** +- `$filters` — An instance of `\ThePay\ApiClient\Filter\PaymentsFilter()`. (See online API documentation for all available filter options.) +- `$page` *(optional)* — Page number. +- `$limit` *(optional)* — Number of records per page. + +**Returns:** + +A `PaymentCollection` object containing: +- A collection of payments +- Current page number +- Number of records per page +- Includes helper methods such as `hasNextPage()` and `getPage()` + +**Example: Iterate through all pages** + +```php +/** @var \ThePay\ApiClient\TheClient $thePayClient */ +$filters = new \ThePay\ApiClient\Filter\PaymentsFilter(); +$page = 1; + +do { + $collection = $thePayClient->getPayments($filters, $page); + + foreach ($collection->all() as $payment) { + // print logic + } + + $page = $collection->getPage() + 1; +} while($collection->hasNextPage()); +```