Creating a payment (widget)

A widget is a pop-up window with a payment form. To use the widget, you just need to add its code to the site page, configure the transfer of parameters and create an event for its call (for example, clicking on a button). The example code and description of the used widget parameters are located in the Unitpay personal account in the project settings on the "Payment widget" tab (at the screenshot below).

Example code:

<script src="https://widget.unitpay.money/unitpay.js"></script>
<script type="text/javascript">
this.pay = function() {
var payment = new UnitPay();
payment.createWidget({
publicKey: "PUBLIC KEY",
sum: 1,
account: "demo",
domainName: "unitpay.money",
signature: "2c38bb3114b2f02222ee35f6b60c6bbe628ad31bed59633787204ae59659a02e",
desc: "Описание платежа",
locale: "ru",
});
payment.success(function (params) {
console.log('Успешный платеж');
});
payment.error(function (message, params) {
console.log(message);
});
return false;
};
</script>

Required parameters:

Value

Description

publicKey

string

Public key. You can find it under the Settings Tab of your project

sum

number

Payment amount (for example, 10.00)

account

string

Customer ID in your system (e-mail or order number, for example)

domainName

string

unitpay.money

signature

string

Digital signature. It is formed as sha256 (account + "{up}" + currency + "{up}" + desc + "{up}" + sum + "{up}" + secretKey), where sha256 is the hashing method; {up} is the parameter separator in the hash function; account, sum, currency, desc are the payment initialization parameters described above; secretKey is the secret key of the project (available in your personal account);

Important Note. If you do not transmit currency to the payment form, this parameter should not be used in signature generation.

desc

string

The order's description for customer

Additional parameters:

Value

Description

locale

ru, en

Forcing the language of the widget.

currency

string

The order currency according to ISO 4217 (RUB, UAH, BYN, EUR, USD etc. Currency codes). If the payment system does not support the required currency, the amount will be converted to the payment system currency.

paymentType

string

Code of the payment system, through which the payment will be made.

hideMenu

true, false

It hides the menu with the payment method options.

If you'll have any additional questions during the integration, you can ask them to our customer support - in Unit.Help or send your questions to manager@unitpay.money

Last updated