Skip to content

Commit 13f6489

Browse files
committed
Documentation 3.0 - Transaction history and invalidate payments
1 parent 3ea3a36 commit 13f6489

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

doc/get-transactions-history.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Get transaction history
22

3-
To get transaction just simply call:
3+
Use the `getAccountTransactionHistory` method to retrieve the transaction history for a specific account within a given date range.
4+
5+
## Example: Retrieve Transactions
46

57
```php
68
/** @var \ThePay\ApiClient\TheClient $thePayClient */
@@ -10,20 +12,28 @@ $filter = new \ThePay\ApiClient\Filter\TransactionFilter('TP32111146804895511653
1012
$transactionPaginatedCollection = $thePayClient->getAccountTransactionHistory($filter);
1113
```
1214

13-
The first parameter of method **getAccountTransactionHistory** is filter object `\ThePay\ApiClient\Filter\TransactionFilter()`. All filter parameters are described in [Apiary](https://thepay.docs.apiary.io/#reference/0/merchant-level-resources/get-account-transaction-history).
15+
**Parameters:**
16+
- `$filter` - An instance of `\ThePay\ApiClient\Filter\TransactionFilter()`. (See online API documentation for all available filter options.)
17+
- `$page` *(optional)* — Page number.
18+
- `$limit` *(optional)* — Number of records per page.
1419

15-
Second and third parameter are used for pagination, where second is page number and third is number of records per page. Parameters are not required.
20+
**Returns:**
1621

17-
You will get object `ThePay\ApiClient\Model\Collection\TransactionCollection`, which contains collection of transactions, current page number, number of records per page and helper methods.
22+
A `ThePay\ApiClient\Model\Collection\TransactionCollection` object containing:
23+
- A collection of transactions
24+
- Current page number
25+
- Number of records per page
26+
- Includes helper methods such as `hasNextPage()` and `getPage()`
1827

19-
You can print all records by this call:
28+
**Example: Iterate through all transactions**
2029

2130
```php
2231
/** @var \ThePay\ApiClient\TheClient $thePayClient */
2332
$from = new DateTime('2021-03-01');
2433
$to = new DateTime('2021-03-31');
2534
$filter = new \ThePay\ApiClient\Filter\TransactionFilter('TP3211114680489551165349', $from, $to);
2635
$page = 1;
36+
2737
do {
2838
$collection = $thePayClient->getAccountTransactionHistory($filter, $page);
2939

doc/invalidate-payment.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
# Invalidate payment
22

3-
To cancel (invalidate) already created payment.
3+
Use the `invalidatePayment` method to cancel an already created payment.
4+
5+
A payment can only be invalidated if it has not yet been completed.
6+
7+
## Example: Invalidate a Payment
48

59
```php
610
$thePayClient->invalidatePayment('49096fe3-872d-3cbe-b908-2806ae2d7c79');
711
```
812

9-
The only parameter of method **invalidatePayment** is a payment UID and the payment has to belong to the project which is configured in TheConfig.
13+
**Parameters:**
14+
- `$uid` - The unique identifier (UID) of the payment.
1015

11-
Method will return void if request was successful, otherwise it throws exception (For example if you are trying to invalidate payment that was already paid). Before invalidating payment is better to check its state:
16+
The payment must belong to the project configured in `TheConfig`
1217

18+
**Returns:**
19+
- `void` if the request was successful.
20+
- Throws an exception if the payment cannot be invalidated (for example, if it was already paid).
21+
22+
**Best Practice: Check Payment State Before Invalidating**
1323

1424
```php
15-
$payment = $thePayClient->getPayment('49096fe3-872d-3cbe-b908-2806ae2d7c79');
25+
$paymentUid = '49096fe3-872d-3cbe-b908-2806ae2d7c79';
26+
$payment = $thePayClient->getPayment($paymentUid);
27+
1628
if ($payment->getState() === PaymentState::WAITING_FOR_PAYMENT) {
17-
$thePayClient->invalidatePayment('49096fe3-872d-3cbe-b908-2806ae2d7c79');
29+
$thePayClient->invalidatePayment($paymentUid);
1830
} else {
1931
// payment can not be invalidated
2032
}

0 commit comments

Comments
 (0)