For any question, we are one click away

Contact us

Payment Widget

Overview

Payment Widget is a low-code script that adds Apple Pay and Google Pay buttons directly to the merchant's store – on product pages and/or in the cart – enabling one-tap checkout on supported devices without leaving your domain.

The problem we propose to solve

Long, multi-step checkouts and low-converting card forms hurt revenue. Reducing steps and keeping buyers on-page improves completion rates and trust.

About our solution

Embed payment widget where intention is highest (e.g., the product page) to skip the cart and complete payment in a secure native wallet sheet. No external redirects. Typical setup takes less than a day.

Key Benefits

Script connection

Adding file

On the merchant's page, in the <head> tag, it is necessary to add a link to the pay-buttons.js file.

The pay-buttons.js file must be located in the pay-buttons folder, on the same level with merchants folder (with payment pages).

Script declaration must contain id="pay-buttons".

<head>
  ...
  <script
    src="https://dev.bpcbt.com/payment/pay-buttons/pay-buttons.js"
    id="pay-buttons">
  </script>
  ...
</head>

Initialization

<script>
  document.addEventListener("DOMContentLoaded", function () {
    var widget = payButtonsWidget("containerId"); // where `containerId` is and id of the DOM-element where the buttons should be added
 
    widget.init({
      gatewayInfo: { // Information for Payment gateway
        token: "i29v9o5hkmuv2590l7661p9vcu", // Merchant's token
        amount: 852300, // Order amount in minor units
        returnUrl: "http\:\/\/yourwebsite.com\/success.html", // Target address after payment
        merchantLogin: "buttonApple",
      },
 
      applePay: { // Information for ApplePay session
        merchantId: "yourwebsite.com", // id of the merchant in Apple
      },
 
      googlePay: {
        environment: "TEST",
      },
    });
  });
</script>

Initialization parameters

Below is the complete list of the parameters used for the script initialization.

RequiredNameTypeDescription
OptionalcartItemsArray of objectsArray of objects for description of the cart items. See nested parameters.
OptionalappleButtonClassStringClass name that will be assigned to applePay button, in order to stylize the button separately or to address it. Default value: pay-button_applepay.
MandatoryapplePayObjectObject containing information about Apple session. See nested parameters.
OptionaldebugBooleanIf true - debug mode is enabled, all service information will be shown under the button. Default value: false.
MandatorygatewayInfoObjectObject containing information for the order in Payment gateway. See nested parameters.
MandatorygooglePayObjectObject containing information about Google Pay session. See nested parameters.

Parameters of cartItems block

RequiredNameTypeDescription
MandatorynameString [1..255]Name or the description of an item in any format.
OptionalitemDetailsObjectObject containing the parameters describing an item. The description of the nested elements is given below.
MandatoryquantityObjectElement describing the total of items of one positionId and its unit of measurement. The description of the nested elements is given below.
OptionalitemAmountInteger [1..12]The total cost of all instances of one positionId specified in minor denomination of the currency. itemAmount must be passed only if the itemPrice parameter has not been passed. Otherwise passing of itemAmount is not required. If both parameters itemPrice and itemAmount are passed in the request, then itemAmount shall be equal itemPrice * quantity, otherwise the request will return an error.
OptionalitemPriceInteger [1..18]Total cost of instance of one positionId specified in minor currency units.
OptionalitemCurrencyInteger [3]ISO 4217 currency code. If the parameter is not specified, it is considered to be equal to the Order currency.
MandatoryitemCodeString [1..100]Number (identifier) of an item in the store system.

Example of cartItems block:

[
  {
    name: 'Ball pen',
    quantity: {
        value: 1,
        measure: "pcs"
    },
    itemAmount: (totalAmount * 100) / 2,
    itemCurrency: "978",
    itemCode: 'number_1'
  },
  {
    name: 'Cheese',
    quantity: {
        value: 1.4,
        measure: "kg"
    },
    itemAmount: (totalAmount * 100) / 2,
    itemCurrency: "978",
    itemCode: 'number_2'
  }
]

Parameters of gatewayInfo object

RequiredNameTypeDescription
MandatorytokenStringToken of the customer in administration console. It is necessary for customer identification.
OptionalregisterPreAuthBooleanRegistraion of two-stage payment. Default value: false.
ConditionalorderNumberString [1..36]Number of the order in the store system. Optional, if a setting to generate order number is enabled.
OptionalamountInteger [0..12]Payment amount in minor currency units (e.g. in cents).
OptionalcurrencyString [3]ISO 4217 encoded currency key. If not specified, the default value is used. Only digits are allowed.
MandatoryreturnUrlString [1..512]The address to which the user will be redirected if the payment is successful. The address must be specified in full including the protocol used (for example, https://mybestmerchantreturnurl.com instead of mybestmerchantreturnurl.com). Otherwise, the user will be redirected to the address of the following type https://dev.bpcbt.com/payment/<merchant_address>.
OptionalfailUrlString [1..512]The address to which the user is to be redirected in case of a failed payment. The address must be specified in full including the protocol used (for example, https://mybestmerchantreturnurl.com instead of mybestmerchantreturnurl.com). Otherwise, the user will be redirected to the address of the following type https://dev.bpcbt.com/payment/<merchant_address>.
OptionaldescriptionString [1..598]Order description in any format.
To enable sending this field to the processing system, contact the technical support service.
It is not allowed to fill this parameter with personal data or payment data (card numbers, etc.). This requirement is due to the fact that the order description is not masked in Merchant Portal and log files.
OptionalclientIdString [0..255]Customer number (ID) in the merchant's system — up to 255 characters. Used to implement the functionality of stored-credential transactions. Can be returned in the response if the merchant is allowed to store credentials.
Specifying this parameter in stored-credential transactions is mandatory. Otherwise, a payment will be unsuccessful.
OptionalsessionTimeoutSecsInteger [1..9]Order lifetime in seconds. If the parameter is not specified, the value specified in the merchant settings or the default value (1200 seconds = 20 minutes) will be used. If the request contains expirationDate, the value of sessionTimeoutSecs is not taken into account.
OptionaljsonParamsObjectA set of additional free-form attributes, structure:
jsonParams={"param_1_name":"param_1_value",...,"param_n_name":"param_n_value"}
Can be passed to the Processing Center for further processing (additional configuration required - contact support).
Some predefined jsonParams attributes:
  • backToShopUrl - adds a button to the payment page that will return the cardholder to the URL passed in this parameter
  • backToShopName - configures the text label of the Return to Shop button by default, if used together with backToShopUrl
  • installments - maximum number of allowed authorizations for installment payments. Required for creating an installment stored credential
  • totalInstallmentAmount - total amount of all installment payments. The value is necessary for saving payment data for conducting installments
  • recurringFrequency - minimum number of days between authorizations. Required for creating recurring stored credential, recommended for creating installment stored credential (if 3DS2 is used, the parameter is mandatory).
  • recurringExpiry - date after which authorizations are not allowed, in YYYYMMDD format. Required for creating recurring stored credential, recommended for creating installment stored credential (if 3DS2 is used, the parameter is mandatory).
  • paymentWay - payment method. To force MOTO payment, pass the value CARD_MOTO.
OptionalorderBundleObjectObject containing cart of items. The description of the nested elements is given below.
OptionalmerchantLoginString [1..255]To register an order on behalf of another merchant, specify the merchant's API account login in this parameter.
Can be used only if you have the permission to see the transactions of other merchants or if the specified merchant is your child merchant.
OptionalmerchantNameStringmerchantFullName in Payment gateway. Is necessary to display merchant's name in payment request api window.
OptionaldynamicCallbackUrlString [1..512]This parameter allows you to use the functionality of sending callback notifications dynamically. Here you can pass the address to which all "payment" callback notifications activated for the merchant will be sent. "Payment" notifications are callback notifications related to the following events: successful hold, payment declined by timeout, cardpresent payment is declined, successful debit, refund, cancellation. At the same time, callback notifications activated for the merchant that are not related to payments (enabling/disabling a stored credential, storing a credential) will be sent to a static address for callbacks. Whether the parameter is mandatory or not depends on the merchant configuration on Payment Gateway side.
OptionalipString [1..39]Buyer's IP address. IPv6 is supported in all requests. (up to 39 characters).
OptionalexpirationDateString [19]Date and time of the order expiry. Format used: yyyy-MM-ddTHH:mm:ss.
If this parameter is not passed in the request, sessionTimeoutSecs is used to define the expiry of the order.
OptionalpostAddressString [1..255]Delivery address.
OptionalfeeInputInteger [0..8]Fee amount in minimum currency units. Must be enabled by respective Merchant-level permission in the Gateway.
ConditionalemailString [1..40]Email to be displayed on the payment page. Customer's email must be passed if client notification is configured for the merchant. Example: client_mail@email.com.
The email will not be validated on registration. It will be later validated on payment.
OptionalbillingPayerDataObjectA block with the client's registration data (address, postal code) necessary for passing the address verification within the AVS/AVV services. Mandatory if the feature is enabled for the merchant on Payment Gateway side. See nested parameters.
OptionalshippingPayerDataObjectObject containing customer delivery data. It is used for further 3DS authentication of the client. See nested parameters.
OptionalpreOrderPayerDataObjectObject containing pre-order data. It is used for further 3DS authentication of the client. See nested parameters.
OptionalorderPayerDataObjectObject containing data about the order payer. It is used for further 3DS authentication of the client. See nested parameters.
OptionalbillingAndShippingAddressMatchIndicatorString [1]Indicator for matching the cardholder's billing address and shipping address. This parameter is used for further 3DS authentication of the customer.
Possible values:
  • Y - the cardholder's billing address and shipping address match;
  • N - cardholder billing address and shipping address do not match.

A block with the client's registration data (address, postal code).

RequiredNameTypeDescription
OptionalbillingCityString [0..50]The city registered on a specific card of the Issuing Bank.
OptionalbillingCountryString [0..50]The country registered on a specific card of the Issuing Bank. Format: ISO 3166-1 (Alpha 2 / Alpha 3 / Number-3) or the country name. We recommend to pass a two/three-letter ISO country code.
OptionalbillingAddressLine1String [0..50]The address registered on a specific card of the Issuing Bank (A payer’s address). Line 1. Mandatory to be passed in order AVS verification works.
OptionalbillingAddressLine2String [0..50]The address registered on a specific card of the Issuing Bank. Line 2.
OptionalbillingAddressLine3String [0..50]The address registered on a specific card of the Issuing Bank. Line 3.
OptionalbillingPostalCodeString [0..9]Postal code registered on a specific card of the Issuing Bank. Mandatory to be passed in order AVS verification works.
OptionalbillingStateString [0..50]The state registered on a specific card of the Issuing Bank. Format: full ISO 3166-2 code, its part, or the state/region name. Can contain Latin characters only. We recommend to pass a two-letter ISO state code.
MandatorypayerAccountString [1..32]Payer's account number.
OptionalpayerLastNameString [1..64]Payer's last name.
OptionalpayerFirstNameString [1..35]Payer's first name.
OptionalpayerMiddleNameString [1..35]Payer's middle name.
OptionalpayerCombinedNameString [1..99]Payer's full name.
OptionalpayerIdTypeString [1..8]Type of the payer's identifying document provided.
Allowed values:
  • IDTP1 - Passport
  • IDTP2 - Driving license
  • IDTP3 - Social card
  • IDTP4 - Citizen ID card
  • IDTP5 - Certificate of Business
  • IDTP6 - Refugee certificate
  • IDTP7 - Residence permit
  • IDTP8 - Foreign passport
  • IDTP9 - Official passport
  • IDTP10 - Temporary passport
  • IDTP11 - Sailor's passport
OptionalpayerIdNumberString [1..100]Number of the payer's identifying document (e.g. passport) provided.
OptionalpayerBirthdayString [1..20]Payer's birth date in the YYYYMMDD format.

Description of parameters in shippingPayerData object:

RequiredNameTypeDescription
OptionalshippingCityString [1..50]The customer's city (from the delivery address)
OptionalshippingCountryString [1..50]The customer's country
OptionalshippingAddressLine1String [1..50]The customer's primary address (from the shipping address)
OptionalshippingAddressLine2String [1..50]The customer's primary address (from the shipping address)
OptionalshippingAddressLine3String [1..50]The customer's primary address (from the shipping address)
OptionalshippingPostalCodeString [1..16]The customer's zip code for delivery
OptionalshippingStateString [1..50]Customer's state/region (from delivery address)
OptionalshippingMethodIndicatorInteger [2]Shipping Method Indicator.
Possible values:
  • 01 - delivery to the cardholder's billing address
  • 02 - delivery to another address verified by Merchant
  • 03 - delivery to an address other than the cardholder's primary (settlement) address
  • 04 - shipment to the store/self-collection (the store address should be specified in the relevant delivery parameters)
  • 05 - Digital distribution (includes online services and e-gift cards)
  • 06 - travel and event tickets that are not deliverable
  • 07 - Other (e.g. games, non-deliverable digital goods, digital subscriptions, etc.)
OptionaldeliveryTimeframeInteger [2]Product delivery timeframe.
Possible values:
  • 01 - digital distribution
  • 02 - same-day delivery
  • 03 - overnight delivery
  • 04 - delivery within 2 days after payment and later
OptionaldeliveryEmail String [1..254]Target email address for delivery of digital distribution. Note that it is preferrable to pass the email in a separate email parameter of the request. The deliveryEmail parameter specified in this block is only used to fill MerchantRiskIndicator during 3DS authorization.

Description of parameters in preOrderPayerData object:

RequiredNameTypeDescription
OptionalpreOrderDateString [10]Expected date when delivery will be available (for pre-ordered purchases), in the format YYYYYYMMDD.
OptionalpreOrderPurchaseIndInteger [2]Indicator of a customer placing an order for available or future delivery.
Possible values:
  • 01 - delivery available;
  • 02 - future delivery
OptionalreorderItemsIndInteger [2]An indicator that the customer is rebooking a previously paid delivery as part of a new order.
Possible values:
  • 01 - order placed for the first time;
  • 02 - repeated order

Description of parameters in orderPayerData object:

RequiredNameTypeDescription
OptionalhomePhoneString [7..15]Customer's phone number. It is always necessary to specify the country code, but you can specify or omit the + sign or 00 at the beginning. The number must be 7 to 15 digits long. Thus, the following options are valid:
  • +35799988877;
  • 0035799988877;
  • 35799988877.
OptionalworkPhoneString [7..15]Customer's phone number. It is always necessary to specify the country code, but you can specify or omit the + sign or 00 at the beginning. The number must be 7 to 15 digits long. Thus, the following options are valid:
  • +35799988877;
  • 0035799988877;
  • 35799988877.

ConditionalmobilePhoneString [7..15]Customer's phone number. It is always necessary to specify the country code, but you can specify or omit the + sign or 00 at the beginning. The number must be 7 to 15 digits long. Thus, the following options are valid:
  • +35799988877;
  • 0035799988877;
  • 35799988877.

For payment by VISA with 3DS authorization, it is necessary to specify either phone or email of the cardholder. If you have a setting to display phone number on the payment page and have specified an invalid number, the customer will have a possibility to correct it on the payment page.

Description of parameters in orderBundle object:

RequiredNameTypeDescription
OptionalorderCreationDateString [19]Order creation date in the following format: YYYY-MM-DDTHH:MM:SS.
OptionalcustomerDetailsObjectBlock containing customer attributes. The description of the tag attributes is given below.
MandatorycartItemsObjectObject containing cart items attributes. The description of nested elements is given below.

Description of parameters in customerDetails object:

RequiredNameTypeDescription
OptionalcontactString [0..40]Customer's preferred way of communication.
OptionalfullNameString [1..100]Payer's full name.
OptionalpassportString [1..100]Customer's passport serial number in the following format: 2222888888.
OptionaldeliveryInfoObjectObject containing delivery address attributes. The description of the nested elements is given below.

Description of parameters in deliveryInfo object.

RequiredNameTypeDescription
OptionaldeliveryTypeString [1..20]Delivery method.
MandatorycountryString [2]Two letter code of the country of delivery.
MandatorycityString [0..40]City of destination.
MandatorypostAddressString [1..255]Delivery address.

Description of parameters in cartItems object.

RequiredNameTypeDescription
MandatoryitemsObjectAn element of the array containing cart item attributes. The description of the nested elements is given below.

Description of parameters in items object.

RequiredNameTypeDescription
MandatorypositionIdInteger [1..12]Unique product identifier in the cart.
MandatorynameString [1..255]Name or the description of an item in any format.
OptionalitemDetailsObjectObject containing the parameters describing an item. The description of the nested elements is given below.
MandatoryquantityObjectElement describing the total of items of one positionId and its unit of measurement. The description of the nested elements is given below.
OptionalitemAmountInteger [1..12]The total cost of all instances of one positionId specified in minor denomination of the currency. itemAmount must be passed only if the itemPrice parameter has not been passed. Otherwise passing of itemAmount is not required. If both parameters itemPrice and itemAmount are passed in the request, then itemAmount shall be equal itemPrice * quantity, otherwise the request will return an error.
OptionalitemPriceInteger [1..18]Total cost of instance of one positionId specified in minor currency units.
OptionalitemCurrencyInteger [3]ISO 4217 currency code. If the parameter is not specified, it is considered to be equal to the Order currency.
OptionalitemCodeString [1..100]Number (identifier) of an item in the store system.

Description of parameters in quantity object.

RequiredNameTypeDescription
MandatoryvalueNumber [1..18]Number of items in one positionId. Use a decimal point as a separator in fractions. Maximal number of decimal places is 3.
MandatorymeasureString [1..20]The unit of measurement for the quantity of item instances.

Description of parameters in itemDetails object.

RequiredNameTypeDescription
OptionalitemDetailsParamsObjectParameter describing additional information regarding a line item. The description of the nested elements is given below.

Description of parameters in itemDetailsParams object.

RequiredNameTypeDescription
MandatoryvalueString [1..2000]Additional item info.
MandatorynameString [1..255]Name of the parameter describing the details of an item

Parameters of applePay block

See more details in the button constructor.

RequiredNameTypeDescription
OptionalbuttonStyleStringButton display style. Allowed values: black, white, white-outline. Default value: black.
OptionalpaymentRequestStringDescription of Apple Pay payment session. The detailed description can be found in the official documentation. See the example below.
OptionalpaymentTypeStringType of the payment button appearance. Allowed values: plain, buy, donate, set-up, book, subscribe. Default value: buy.
For donate, book, subscribe types, the button width must be at least 200 px.
MandatorymerchantIdStringmerchantId in Apple, for example, website.com. This site will be also used as label in Apple Pay window. As it is limited by length, it is easier to display site domain.
MandatorylanguageString [2]ISO 639-1 encoded key of the button language.

Example of paymentRequest:

{
  countryCode: 'BG',
  currencyCode: 'BGN',
  supportedNetworks: [
    'masterCard',
    'visa',
    'electron',
    'maestro'
  ],
  merchantCapabilities: [
    'supports3DS',
    'supportsCredit',
    'supportsDebit'
  ],
  total: {
    label: '',
    amount: 1.00 // major units
  },
  requiredShippingContactFields: [
    'postalAddress',
    'name',
    'phone',
    'email'
  ]
}

Parameters of googlePay block

RequiredNameTypeDescription
MandatoryenvironmentStringEnvironment. If not specified, the GPay button is not displayed. Allowed values:
  • PRODUCTION - used to show valid payment ways, if an active Google merchant ID is specified for the domain. Is used for production only.
  • TEST - test payment ways intended for testing (default value).
OptionalemailRequiredBooleanWhether email should be asked during payment via PaymentRequest API. Default value: true.
OptionalphoneNumberRequiredBooleanWhether phone number should be asked during payment via PaymentRequest API. Default value: true.
OptionalbillingAddressRequiredBooleanWhether billing address should be asked during payment via PaymentRequest API. Default value: true.
OptionalshippingAddressRequiredBooleanWhether shipping address should be asked during payment via PaymentRequest API. Default value: false.
OptionalpayerNameRequiredBooleanWhether payer name should be asked during payment via PaymentRequest API. Default value: false.
ConditionalallowedCountryCodesArray of StringList of country codes where shipping is available, in the ISO 3166-1 alpha-2 format. Mandatory, if shippingAddressRequired = true.
OptionalbuttonColorStringGoogle Pay button color. Allowed values:
  • default - selected value by default. Currently, black is used.
  • black - black button for placing on a white or another light background.
  • white - white button for placing on a colored background.
Default value: default.
OptionalbuttonTypeStringType of the label on the button. Allowed values:
  • long - button with the text "Pay via Google Pay" (by default). If one of available languages is selected in the browser settings, a localized version of the button will be displayed.
  • short - Google Pay payment button without text.
Default value: short.

Code generator

You can also quickly generate the code of Payment Widget script via Merchant Portal. To do so, go to Quick buttons -> Code generator tab in your Personal Area.

This page contains a constructor that looks like as follows:


Code generator 1
Code generator 2

The tab has the following sections that contain parameters for the script initialization:

Supporting by browsers

Environment / BrowsersApple PayGoogle Pay
iOS / iPadOS — SafariYesYes (web checkout)
iOS / iPadOS — Chrome / Edge / FirefoxYes (iOS 16+)Yes (web checkout)
macOS — SafariYesYes
macOS — Chrome / Edge / FirefoxYes, via QR (iOS 18+)Yes
Windows / Linux / ChromeOS — Chrome / Edge / FirefoxYes, via QR (iOS 18+)Yes
Android — Chrome / Edge / FirefoxYes, via QR (iOS 18+)Yes

Testing and deployment

Test environment (UAT)

Connect the script with https://dev.bpcbt.com/payment/ address.

<script
  src="https://dev.bpcbt.com/payment/pay-buttons/pay-buttons.js"
  id="pay-buttons">
</script>

Production environment (PROD)

Connect the script with https://dev.bpcbt.com/payment/ address.

<script
  src="https://dev.bpcbt.com/payment/pay-buttons/pay-buttons.js"
  id="pay-buttons">
</script>
Categories:
eCommerceAPI V1
Categories
Search results