Comment on page
Integration process
Below are the classes that we will use as a basis in the CryptoPay integration and development process and what they do.
use BeycanPress\CryptoPay\Loader;
use BeycanPress\CryptoPay\Settings;
How do we access the settings?
Settins::get($key);
How to create a new setting?
Settings::createSection($options = []);
We use CSF for our settings section. You can access all fields from the link below.
use BeycanPress\CryptoPay\PluginHero\Hook;
use BeycanPress\CryptoPay\PluginHero\Helpers;
Classes to be used in payment process integration.
use \BeycanPress\CryptoPay\Services;
Services::registerAddon(string $key);
This method actually just keeps records. That is, it verifies whether another plugin has received your plugin key before you do. Thus, it avoids software confusion.
Services::startPaymentProcess(
array $order, string $addon, bool $confirmation = true, array $params = []
) : string
The startPaymentProcess method runs the payment process directly and activates CryptoPay's JavaScript arm, so when the page loads, you are directly greeted by the network selection screen.
What are the parameters?
- $order => The parameter is an array and must contain 3 values. Order ID, order amount and currency. An example is given below.
- ['id' => int,'amount' => float,'currency' => string,]
- $addon => We will use our add-on key, which we registered with registerAddon, in the $addon parameters.
- $confirmation => You can specify whether to go through an approval process after the user transfers. It can be closed in processes such as donations, but it is important in payment processes.
- $params => Parameters to be sent by the front-end to the back-end.
Services::preparePaymentProcess(
string $addon, bool $confirmation = true, array $data = []
) : string
The preparePaymentProcess method is different from the startPaymentProcess method. It does not start the payment process directly, so when the page is loaded, it is loaded blank. So how does this work for us? For example, if your order is already ready, that is, if your order amount is certain. You can start the process directly. But if there will be an amount determination process beforehand, as with our Donation plugin. You suspend the JavaScript arm using the preparePaymentProcess method. And then you start the payment process using the JavaScrtip API.
What are the parameters?
- $addon => We will use our add-on key, which we registered with registerAddon, in the $addon parameters.
- $confirmation => You can specify whether to go through an approval process after the user transfers. It can be closed in processes such as donations, but it is important in payment processes.
- $data => Parameters to be sent to the JavaScript side. If you want to use parameters from front-end to back-end. You must add a value as params.
Initiating the payment process on the JavaScript API?
On the JavaScript side, you will have a variable called CryptoPay. All we have to do is start the startPayment method with an object as follows. If you do not have a confirmation process or an order ID, you can not add the i d parameter.
CryptoPay.startPayment({
id: null|int,
amount: float,
currency: string
});
If you have closed the confirmation process, that is, there will be no verification process after the transfer process. You can take action after the transfer of the user by using the callback function below. If there is a validation process, there will already be a redirection process with the result from PHP.
CryptoPay.callbacks.transactionSent = () => {
// code
}
use BeycanPress\CryptoPay\Pages\TransactionPage;
What are the parameters?
- $name => The name of the transaction page.
- $slug => The slug of the transaction page.
- $addon => We will use our add-on key, which we registered with registerAddon, in the $addon parameters.
- $hooks => Each row goes through a hook loop while creating the table. Here you can add hooks with callable functions to manipulate each column value in each row.
- $confirmation => You determine whether the transaction records on this page will enter the validation phase if there is a pending transaction while you load the page.
- $excludedColumns => To remove columns that you do not want to show in the table.
new TransactionPage(
string $name,
string $slug,
string $addon,
array $hooks = [],
bool $confirmation = true,
array $excludeColumns = []
);
use BeycanPress\CryptoPay\Models\AbstractTransaction;
The following example is sufficient. All you have to do is use it as follows.
class DonationTransaction extends AbstractTransaction
{
public static $addon = 'donation';
public function __construct()
{
// Table name = donation_transaction
parent::__construct('donation_transaction');
}
}
Last modified 2mo ago