Filters

First, we will talk about the filters that should work separately for each add-on during the add-on development process.

1 - With this filter, you can change the address of receiving payment, that is, the wallet address, which is received during the installation of the payment process. It returns string as value.

What are the parameters sent?
  • $receiver => string is a value. and gives the wallet address from the current settings.
  • $order => is an object and gives information about the ID, Price and currency of the relevant order.
  • $network => It is the object and contains selected network information for payment.
Hook::callFilter(
'receiver_{addon}',
string $receiver, object $data
);

2 - With this filter, you can set the status value during the insertion of the Transaction record into the database. What is this for? For example, in the Donation plugin, we did not need to verify transactions. Thus, as the user performs the transfer himself, we have set this process as "completed". It returns string as value.

What are the parameters sent?
  • $status => string is a value and is 'pending' by default.
Hook::callFilter('transaction_status_{addon}', string $status = 'pending');

3 - This hook is mandatory if a payment process integration is being performed. Because after the payment is completed, it provides links that indicate where the payment will be directed according to the success status. It returns array as value.

Hook::callFilter('payment_redirect_urls_{addon}', object $data);
What are the required values in the array?
return [
'success' => 'Address to be forwarded when payment is successful',
'failed' => 'Address to be forwarded when payment is failed'
];
What are the parameters sent?
  • $data => It contains data that is generally used in the payment process, which you will also see in many other hooks.
What is in the data parameter?
  • $addon => Plugin that processes the payment process.
  • $userId => The ID of the current user.
  • $order => is an object and gives information about the ID, Price and currency of the relevant order.
  • $hash => It is the hash, or ID, of the Blockchain transaction in the current payment process.
  • $network => It is the object and contains selected network information for payment.
  • $model => It is the model in which Transaction records in the payment process are kept.
  • $status => It is the value that indicates the status of the payment process.
  • $params => Extra dynamic parameters sent
Since we mentioned the $data parameter here, we will not mention the $data parameter in the next sections.
$data = (object) [
'addon' => $this->addon,
'userId' => $this->userId,
'order' => $this->order,
'hash' => $this->hash,
'network' => $this->network,
'model' => $this->model,
'status' => 'pending',
'params' => $this->request->getParam('params')
];

4 - The following hooks allow you to update the message to the user based on the result of the payment process.

What are the parameters sent?
  • $message => Default message
Hook::callFilter('payment_success_message_{addon}', string $message);
Hook::callFilter('payment_failed_message_{addon}', string $message);
Yes, now that the filters that should work separately for each add-on are finished, we can now move on to filters with general use.

5 - It is the filter we use to develop a custom currency converter API. The default value is as follows.

What are the parameters sent?
  • $converters => Returns an array and includes CryptoCompare as the default value.
Hook::callFilter("converters", []);

6 - The filter through which the currency conversion process will occur during the development of a custom currency converter API.

If the custom converter API returns no response, it tries again via the default Crypto Compare.
What are the parameters sent?
  • $paymentAmount => null
  • $orderCurrency=> The string returns the symbol (ISO code) of the currency used by the market as a value.
  • $paymentCurrency=> It provides the user-selected cryptocurrency information during the payment process.
  • $amount => Returns the value of the order in FIAT currency before converting it to the crypto price.
  • $network => It gives the network information that the user chooses during the checkout process.
Hook::callFilter(
"currency_converter",
?float null,
string $orderCurrency,
object $paymentCurrency,
float $amount,
object $network
);

7 - CryptoPay - It is used to add custom settings fields to API's field in Settings.

Hook::callFilter("api_options", []);

8 - Language data sent to CryptoPay JavaScript. It can be used to make an update.

What are the parameters sent?
  • $lang => Retrieves the default language values. You can call the "get()" method from the class below to see the default language values.
BeycanPress\CryptoPay\Constants::getLangParams();
Hook::callFilter('lang', []));

9 - With this filter, when adding a new network support to CryptoPay, you can include the PHP package that manages the payment and approval process of the relevant network.

Hook::callFilter('php_providers', []);

10 - With this filter, when adding a new network support to CryptoPay, you can include the JavaScript package that manages the payment and approval process of the relevant network.

Hook::callFilter('js_providers', []);

11 - It is used to provide the CryptoPay application with pictures of wallets in that network in a new network integration process. It proceeds as "Wallet key => link".

Hook::callFilter('wallet_images', array $walletImages);

12 - It allows you to introduce network information to CryptoPay in a new network integration process.

Hook::callFilter('networks', []);

13 - In another plugin integration process, you add the database model that will be used to keep the transaction records of the related plugin in the payment process.

Hook::callFilter('models', []);
Yes, that's it for all filters. But remember, these are not the commands you will use, but the commands in the plugin that will work according to the hooks you have added.

14 - This hook works in 3 sections. These are init, createTransaction and paymentFinished, respectively, as follows. You can update $order parameters with this filter.

$this->data->order = Hook::callAction('check_order_{addon}', $order);

15 - The createTransaction process is actually the process where the payment process, that is, the money transfer, begins. This hook works in this process i.e. at the beginning of the createTransaction process. You can update the parameters in the data variable.

$this->data = Hook::callAction('before_payment_started_{addon}', $data);

16 - The PaymentFinished process is the process where the payment process is completed and the results will be known. This hook works in this process, i.e. at the beginning of the paymentFinished process. You can update the parameters in the data variable.

$this->data = Hook::callAction('before_payment_finished_{addon}', $data);

17 - Hooks that allow you to update the theme in general terms and only in the addons you develop.

$theme = Hook::callFilter('theme', Settings::get('theme'));
Hook::callFilter('theme_'. $this->addon, $theme);

18 - Here are the dynamic parameters sent to the "Provider" (Payment processor) on the JavaScript side.

Hook::callFilter('provider_config_' . {networkCode}, []);