# Actions

The types given in the parameters are specified on the input page.

Below are examples of actions in codebase. However, if you want to run code in an actions process. There will be a usage as in the example.

```php
Hook::addAction('payment_started', function (PaymentDataType $data) {
    // your code here
});
```

### RestAPI & Verifier

There is always a "before" filter before the following hooks, as data can be updated before the payment process starts and ends.

#### Payment started

There are two hooks in the payment started process. One of them is general and the other one is only used for specific add-ons.

```php
Hook::callAction('payment_started', PaymentDataType $data);
Hook::callAction('payment_started_{addon}', PaymentDataType $data);
```

These are typically used in the payment process of an integration. For example, you've done an integration for a WordPress plugin and when the user pays, these hooks work first. So you can start the processes for the related plugin.

#### Payment finished

There are two hooks in the payment finished. One of them is general and the other one is only used for specific add-ons.

```php
Hook::callAction('payment_finished', PaymentDataType $data);
Hook::callAction('payment_finished_{addon}', PaymentDataType $data);
```

These are typically used in the payment process of an integration. For example, you've done an integration for a WordPress plugin and when the user makes the payment, the payment\_started hooks run first. Then these hooks will be triggered when the payment is completed. Unlike payment\_started hooks, these hooks are called in Verifier and RestAPI processes because they will also work in back-end validation.

#### Custom endpoint

This is the hook you can use if you want to add an external process to the CryptoPay RestAPI. This way you will have an endpoint in the following format and your hook will work when you make a request.

```url
https://example.com/wp-json/cryptopay/custom-endpoints?endpoint={endpoint}
```

```php
Hook::callAction(
    'custom_endpoint_{endpoint},
    Request $request,
    PaymentDataType $data
);
```

### Transaction page

Transaction page is the page that can be created for all addons and pulls and lists the transaction records in the model according to the "addon" definition. A hook we will use here will work on the transaction list pages of all add-ons.

The parameters here are respectively

* $params => parameters to be selected to retrieve data from the transaction table.
* $code => the network code for which blockchain network the data will be listed.
* $status => one of the values defined in TransactionStatus in the enums.

```php
Hook::callAction('transaction_page', array $params, string $code, string $status);
```

### Settings

As you can see in the examples, it is the hook where you can add additional menus in CryptoPay settings.

```php
Hook::callAction("settings");
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://beycanpress.gitbook.io/cryptopay-docs/for-developers/hooks/actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
