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://uat.dskbank.bg/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.
ConditionalapplePayObjectObject containing information about Apple session. Mandatory to display the Apple Pay button: if the object is not passed, the Apple Pay button is not displayed. See nested parameters.
OptionaldebugBooleanIf true - debug mode is enabled, all service information will be shown under the button. Default value: false.
OptionaldeliveryOptionsArray of objectsShipping methods that the customer selects in the Apple Pay or Google Pay window. The cost of the selected method is added to the order amount. See nested parameters and the Shipping methods section.
MandatorygatewayInfoObjectObject containing information for the order in Payment gateway. See nested parameters.
ConditionalgooglePayObjectObject containing information about Google Pay session. Mandatory to display the Google Pay button: if the object is not passed, the Google Pay button is not displayed. See nested parameters.
OptionalonClickFunctionFunction that the widget calls before the order registration. It can change some of the gatewayInfo parameters. See the onClick handler section.

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.
MandatoryamountInteger [0..12]Order amount in minor currency units (for example, in cents). A number or a string of digits is accepted. If deliveryOptions is passed, specify the cost of goods without shipping: the widget adds the shipping cost itself.
OptionalcurrencyString [3]ISO 4217 numeric code of the payment currency. Default value: 978 (EUR).
OptionallanguageString [2]ISO 639-1 language code. Default value: en.
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://uat.dskbank.bg/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://uat.dskbank.bg/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
  • 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).
OptionalorderBundleObjectObject containing cart of items. The description of the nested elements is given below.
OptionalfeaturesString or Array of StringOrder features. The widget passes the value in the features parameter of the order registration request. The widget joins array elements with a comma. See also Saving the customer's card.
ConditionalmerchantLoginString [1..255]Merchant login in Payment gateway. Mandatory if the applePay or googlePay object is passed. The widget passes the login to Apple Pay for merchant validation and to Google Pay as gatewayMerchantId. If the login is not specified, widget.init() throws an error.
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: unset, black, white, white-outline. Default value: unset (the style is defined by Apple Pay SDK).
OptionalpaymentRequestObjectDescription of Apple Pay payment session. The detailed description can be found in the official documentation. See the example below.
The widget fills in the currencyCode, total, lineItems, and shippingMethods fields itself: values from paymentRequest are not applied to them.
OptionalpaymentTypeStringType of the payment button appearance. Allowed values: plain, buy, donate, set-up, check-out, 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.
OptionallanguageString [2]ISO 639-1 encoded key of the button language. Default value: en.

Example of paymentRequest:

{
  countryCode: 'DE',
  currencyCode: 'EUR',
  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. If deliveryOptions is passed, the shipping address is always requested.
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.
ConditionalcountryCodeString [2]ISO 3166-1 alpha-2 code of the acquiring bank country, for example DE. This is not the shipping country. Mandatory if deliveryOptions is passed. If the value does not match the format, widget.init() throws an error.
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". 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.

Shipping methods

The customer selects the shipping address and method right in the Apple Pay or Google Pay window. No separate shipping form on your site is needed: the address comes from the wallet, and the total amount with shipping is recalculated instantly.

How to enable

  1. Specify gatewayInfo.merchantLogin.
  2. Specify the cost of goods without shipping in gatewayInfo.amount — the widget adds the shipping cost itself.
  3. List the shipping methods in the deliveryOptions parameter. The first method in the list is offered to the customer by default.
  4. For Google Pay, specify googlePay.countryCode — the country code of the acquiring bank.
widget.init({
  gatewayInfo: {
    token: "i29v9o5hkmuv2590l7661p9vcu",
    amount: 10000, // Cost of goods without shipping, in minor units
    returnUrl: "http\:\/\/yourwebsite.com\/success.html",
    merchantLogin: "buttonApple",
  },

  applePay: {
    merchantId: "yourwebsite.com",
  },

  googlePay: {
    environment: "TEST",
    countryCode: "DE", // Acquiring bank country, not the shipping country
  },

  deliveryOptions: [
    {
      id: "courier",
      label: "Courier",
      description: "1-2 days",
      amount: 500, // Shipping cost in minor units
      countries: ["DE"],
      regions: ["DE-BE"],
    },
    {
      id: "pickup",
      label: "Pickup",
      amount: 0,
      countries: ["DE"],
      postalPrefixes: ["10"],
    },
  ],
});

Parameters of a deliveryOptions array element

RequiredNameTypeDescription
MandatoryidString [1..50]Shipping method identifier: Latin letters, digits, and punctuation marks. It is saved in the order in the shippingPayerData.shippingType parameter.
MandatorylabelStringShipping method name that the customer sees.
OptionaldescriptionStringShipping method description, for example, the delivery time.
MandatoryamountIntegerShipping cost in minor currency units. For free shipping, specify 0.
OptionalcountriesArray of StringCountries where shipping is available, in the ISO 3166-1 alpha-2 format. Example: ["DE"]. If not specified — any country.
OptionalregionsArray of StringRegions where shipping is available, in the ISO 3166-2 format. Example: ["DE-BE"]. If not specified — any region.
OptionalpostalPrefixesArray of StringBeginning of the postal code for which shipping is available. Example: ["10", "11"]. If not specified — any postal code.

What the customer sees

  1. The customer clicks the Apple Pay or Google Pay button and selects a shipping address from the wallet.
  2. The wallet shows the shipping methods available for this address. If you do not ship to this address, the wallet notifies the customer about this before payment.
  3. The customer selects a shipping method and sees the total amount.
  4. The customer confirms the payment. The order is created for the total amount, and the address and the shipping method are saved in the order.

onClick handler

Create an order in your system only when the customer actually pays. The widget calls onClick right after the payment is confirmed in Apple Pay or Google Pay — before the order is created in Payment gateway. In the handler, you can get the order number from your accounting system, set the return page or the notification address for a specific order.

The handler receives the gatewayInfo object, can be asynchronous, and returns the changed object. The customer waits in the wallet window meanwhile, so the handler must run quickly.

widget.init({
  gatewayInfo: {
    token: "i29v9o5hkmuv2590l7661p9vcu",
    amount: 852300,
    returnUrl: "http\:\/\/yourwebsite.com\/success.html",
    merchantLogin: "buttonApple",
  },
  applePay: {
    merchantId: "yourwebsite.com",
  },
  googlePay: {
    environment: "TEST",
  },
  onClick: async function (gatewayInfo) {
    // Get the order number from the store server
    var response = await fetch("/api/orders", { method: "POST" });
    var order = await response.json();

    gatewayInfo.orderNumber = order.number;
    gatewayInfo.returnUrl = "https://yourwebsite.com/orders/" + order.number;
    return gatewayInfo;
  },
});

Parameters that can be changed in the handler:

NameDescription
orderNumberOrder number in the store system.
tokenMerchant token.
returnUrlRedirect address after a successful payment.
dynamicCallbackUrlCallback notification address for this order.

The customer has already confirmed the amount, currency, and cart in the wallet window, so they are set only when the widget is initialized. If the handler fails, the payment does not go through and the customer sees a message about it.

Saving the customer's card

Save the customer's card during an Apple Pay or Google Pay payment to process further payments with a stored credential. In all cases, pass the customer identifier in your system in gatewayInfo.clientId.

During payment. Passing clientId is enough: after a successful payment, the stored credential is created automatically if the merchant is allowed to create stored credentials.

Guaranteed card saving. Add FORCE_CREATE_BINDING to gatewayInfo.features so that a stored credential is created with every payment. The feature must be enabled for the merchant in Payment gateway.

Card saving without payment. Pass features: ["VERIFY", "FORCE_CREATE_BINDING"]. The customer confirms the card in the wallet, no money is charged, and the card is saved. Suitable for setting up a subscription or linking a card in a personal account.

widget.init({
  gatewayInfo: {
    token: "i29v9o5hkmuv2590l7661p9vcu",
    amount: 0,
    returnUrl: "http\:\/\/yourwebsite.com\/success.html",
    merchantLogin: "buttonApple",
    clientId: "customer-12345", // Customer identifier in the store system
    features: ["VERIFY", "FORCE_CREATE_BINDING"],
  },
  applePay: {
    merchantId: "yourwebsite.com",
  },
  googlePay: {
    environment: "TEST",
  },
});

Button size and corner radius

You can fit the Apple Pay and Google Pay buttons into the design of your site: set the width, height, and corner radius. Three CSS variables on the button container are enough — the settings apply to both buttons at once.

VariableDefault valueDescription
--pay-buttons-button-width100%Button width.
--pay-buttons-button-height40pxButton height. For touch screens, we recommend a height of at least 44px.
--pay-buttons-button-border-radius0pxCorner radius. Specify the value in px. The 0px value sets square corners.
<style>
  #containerId {
    --pay-buttons-button-width: 320px;
    --pay-buttons-button-height: 48px;
    --pay-buttons-button-border-radius: 8px;
  }
</style>

<div id="containerId"></div>

The color and label of the buttons are set with the applePay.buttonStyle, applePay.paymentType, googlePay.buttonColor, and googlePay.buttonType parameters.

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://uat.dskbank.bg/payment/ address.

<script
  src="https://uat.dskbank.bg/payment/pay-buttons/pay-buttons.js"
  id="pay-buttons">
</script>

Production environment (PROD)

Connect the script with https://uat.dskbank.bg/payment/ address.

<script
  src="https://epg.dskbank.bg/payment/pay-buttons/pay-buttons.js"
  id="pay-buttons">
</script>
Categories:
eCommerceAPI V1
Beta
Categories
Search results