👷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.

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.

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.

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.

https://example.com/wp-json/cryptopay/custom-endpoints?endpoint={endpoint}
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.

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.

Hook::callAction("settings");

Last updated