Skip to main content

Advanced features

Using order numbers in requests

If the orderId parameter is not passed during payment widget initialization, each new widget session is created with an automatically generated order number. To use your own order number in the widget initialization request, pass the required value in the orderId parameter. This also allows you to display an existing payment if a widget session with the same orderId was already created.

Example of widget initialization with an order number:

<script>
const widget = PaymentWidget.init({
apiKey: 'YOUR_API_KEY',
mode: 'popup',
payment: {
type: 'hold',
orderId: '1002289582',
description: 'Payment #1002289582',
amount: 1.99,
currency: 'EUR',
serverUrl: 'https://myshop.pl/payment/notify'
}
});
</script>

Event handling

To handle payment widget events, register a callback function. To do this, add the on(eventName, callback) method call to the widget initialization code and pass the event name and callback function.

Example of widget initialization with event handling callbacks:

<script>
PaymentWidget.init({
apiKey: 'YOUR_API_KEY',
mode: 'popup',
payment: {
type: 'hold',
amount: 1.99,
currency: 'EUR'
}
}).on('widget.ready', function(data){
// ready
}).on('widget.error', function(data){
// error
}).on('payment.success', function(data){
// success
}).on('payment.failed', function(data){
// failed
});
</script>

The payment widget can send the following events:

Event NameDescription
widget.readyPayment widget has been successfully initiated
widget.errorAn error occurred during the initialization of the payment widget
payment.successPayment has been successfully completed
payment.failedPayment has failed

Passing product information

You can also pass a list of products in the payment widget initialization request. These products will be included in the payment creation request. At the moment, the product list is not displayed in the payment widget itself.

caution

When payments are fiscalized through a software cash register, product information must be passed in the request.

Passing payer information

Some payment gateways may require additional payer information. You can also add this information to the payment widget initialization request.

Example of payment widget initialization with product information, payer data, and all events:

<script>
const widget = PaymentWidget.init({
apiKey: 'YOUR_API_KEY',
mode: 'embedded',
selector: '#widget',
payment: {
type: 'hold',
orderId: '1002289582',
description: 'Payment #1002289582',
amount: 399.98,
currency: 'EUR',
serverUrl: 'https://myshop.pl/payment/notify',
products: [
{
name: "Xiaomi fan",
price: 199.99,
quantity: 2
}
],
payer: {
id: '10000123',
firstName: 'John',
middleName: '',
lastName: 'Doe',
phone: '+123456789',
email: 'john.doe@mail.com',
birthDate: '1990-01-01',
billingAddress: {
line1: '',
line2: '',
city: 'LA',
country: 'US',
state: 'CA',
postalCode: '90001'
}
}
}
});
widget
.on('widget.ready', function(data){})
.on('widget.error', function(data){})
.on('payment.success', function(data){})
.on('payment.failed', function(data){});
</script>

Closing the payment widget

If needed, the payment widget can be closed when a specific event occurs and a callback is received, or at your own initiative.

Usage example: receiving a callback about a failed transaction closes the widget.

</script>
const widget = PaymentWidget.init({
apiKey: 'YOUR_API_KEY',
mode: 'popup',
payment: {
type: 'hold',
amount: 1.99,
currency: 'EUR'
}
})
widget.on('payment.failed', function(data){
// failed
widget.close()
});
</script>

Supported languages

The payment widget can be displayed in different languages, and you can set custom values for any parameter shown to the payer.

The payment widget language is managed through the locale parameter.

Supported locales:

Parameter valueLanguage
enEnglish

If the widget initialization request does not include a language value, the widget is displayed in English by default.

Request example:

PaymentWidget.init({
apiKey: "test_E3PALDNAQ11OV9D0141MKB3I9RJRJDR2MJPP",
mode: "embedded",
selector: '#widget',
locale: 'en',
payment: {
type: "pay",
amount: 2.99,
currency: "EUR",
}
})

Use the localization block to set custom values for payment widget parameters.

Request example:

PaymentWidget.init({
apiKey: "test_E3PALDNAQ11OV9D0141MKB3I9RJRJDR2MJPP",
mode: "embedded",
selector: '#widget',
locale: 'en',
localization: {
"en": {
"submit": "Donate",
},
"fr": {
...
},
},
payment: {
type: "pay",
amount: 2.99,
currency: "EUR",
}
})

List of payment widget UI components that can be customized:

ParameterDescriptionDefault value
chooseAnotherSection to pay using a cardor enter card details
orderNumOrder numberOrder No.
optionalOptional field indicatorOptional
cardNumberInput field for the card numberCard number
cardExpDateInput field for the card expiration dateCard expiry
cvvInput field for card verification value/codeCVV2/CVC2
submitPayment button for the card optionPay
errorCardNumberFieldError message for the card number fieldCard number is not valid
errorExpDateFieldError message for the card expiration date fieldExpiration date is not valid
errorCvvFieldError message for the card verification value/code fieldCVV is not valid
errorRequiredFieldError message for a mandatory fieldRequired field
successPaymentNotification of successful paymentYour payment is successful!
failedPaymentNotification of failed paymentYour payment is unsuccessful!
paymentIsNotCompletedNotification when payment is in processProcessing payment
pendingExpiredNotification for transactions lacking a confirmed final statusIf funds have already been withdrawn from your card, please wait up to 5 minutes for payment confirmation.
waitButton to request the current status of transactionsWait
redirectRequiredTitleNotification in the embedded payment widget advising customers to undergo 3DS verificationClick to Open 3DS Verification Window
redirectRequiredButtonButton in the embedded payment widget to initiate 3DS verificationProceed with 3DS Verification
entityNameLabelRecipient nameName:
businessRegLabelBusiness registration number/Entrepreneur tax IDBusiness ID/Tax ID:
ibanLabelIBANIBAN:
merchantInfoBtnInformation about the payment recipientInformation about the recipients
temporaryUnavailableIssue with displaying recipient dataTemporary unavailable