Using embedded payment buttons for Apple Pay, Google Pay, and Express checkout payments

Overview

In certain processing scenarios merchants may need to use branded payment buttons that allow their customers to pay for orders with the Apple Pay and Google Pay payment methods. When working with the ecommpay payment platform, you can use a specialised version of Payment Page embedded into the web service in the form of payment buttons with specific brand identities. These embedded buttons allow you to process express checkout payments, with the collection of all required information, including shipping details, in the services of the payment methods used to make the purchase.

When this functionality is implemented, the interface of the web service displays branded buttons of specific payment methods clicking which redirects the customer to the relevant payment service without involvement of the Payment Page interface. However, if additional data is required for payment processing, the customer can be shown a modal window with the relevant pages of the payment form. To avoid such cases, you are recommended to ensure that all additional data is passed in the requests for invoking Payment Page as well as to use the capability to collect customer data in the Apple Pay and Google Pay services.

Embedded payment buttons functionality is supported for Apple Pay and Google Pay payments and can be combined with invoking Payment Page for other payment processing options including card payments with tokens, redirecting to other payment methods by preselection in the web service, and using all available payment methods on the form. The size of embedded buttons can be configured via parameters for invoking the payment form. As of now, it is not possible to use the Payment Page Designer in Dashboard to set up the design of these buttons; however, the designer tool can be useful if you need to customise those pages of the payment form that are shown to the customers if additional data is required.

Processing scenario

The basic steps of the customer payment scenario with the use of embedded payment buttons are the following:

  1. The customer navigates to a page in the web service interface where embedded buttons are displayed and initiates a purchase using one of the payment methods.
  2. The customer is redirected to the service of the selected method.
  3. In the service, the customer provides a shipping address and selects the shipping option, if necessary, and performs other required actions.
  4. The customer is notified about the payment result (how this information is communicated depends on the configuration of the web service).

Workflow

The interaction between the web service and the payment platform when the branded buttons are embedded requires the use of specialised libraries provided by ecommpay and includes the following steps.

Figure 5. Processing a purchase made with the use of embedded payment buttons. Step-by-step description
  1. The web service sends the request for processing a purchase via Payment Page to the specified ecommpay URL.
  2. The request for processing a purchase via Payment Page is sent to the payment platform.
  3. The payment platform receives the request and validates the required parameters and signature.
  4. Payment Page is generated based on the project and request parameters.
  5. Embedded payment buttons are shown to the customer.
  6. The customer clicks the button of the payment method they need.
  7. The request is processed on the side of Payment Page.
  8. Payment Page sends a message that requires confirmation of the payment to the web service.
  9. The web service responds to Payment Page with a message that confirms the payment, following which the processing workflow for this specific method is invoked.
  10. Payment Page sends a message with the result information and the customer redirection URL to the web service.

The interaction between the web service and the payment platform when shipping information is provided in the service of the selected payment method (Google Pay or Apple Pay) includes the following steps.

Figure 6. Providing shipping information in the Google Pay service. Step-by-step description
  1. The web service responds to Payment Page with a message that confirms the payment.
  2. The request for invoking the interface and the payment form of Google Pay is sent to the payment platform.
  3. The request for invoking the interface and the payment form of Google Pay and retrieving information about the customer's cards is sent to the Google Pay service.
  4. The Google Pay service processes the request and generates the payment form with the list of cards available to the customer.
  5. The customer is shown the interface of the Google Pay service with the list of cards with masked numbers and the fields to enter shipping details.
  6. The customer enters a shipping address.
  7. The Google Pay service processes the request.
  8. The Google Pay service sends the message with the shipping address to Payment Page.
  9. Payment Page sends the message with the shipping address to the web service.
  10. The web service responds to Payment Page with a message confirming shipping availability to this address.
  11. Payment Page sends the message confirming shipping availability to the Google Pay service.
  12. The Google Pay service processes the request.
  13. The customer is shown information about available shipping options.
  14. The customer selects a shipping option.
  15. The Google Pay service processes the request.
  16. The Google Pay service sends the message with the information about the selected shipping option to Payment Page.
  17. Payment Page sends the message with the information about the selected shipping option to the web service.
  18. The web service responds to Payment Page with a message confirming this shipping option availability.
  19. Payment Page sends the message confirming the shipping option availability to the Google Pay service.
  20. The Google Pay service processes the request.
  21. The customer is shown purchase details with shipping information (shipping address and option).
  22. The customer performs other actions, if necessary, and confirms payment.
  23. The Google Pay service processes the request.
  24. The Google Pay service sends the message with purchase details that include shipping information to Payment Page
  25. Payment Page sends the message with purchase details that include shipping information to the web service.
  26. The web service responds to Payment Page with a message that confirms the payment, following which the processing workflow for this specific method is invoked.
  27. Payment Page sends a message with the result information and the customer redirection URL to the web service.

Setup and configuration

To start working with the embedded payment buttons functionality:

  1. On the client side, add the ecommpay CSS and JavaScript libraries available at https://paymentpage.ecommpay.com/shared/merchant.css and https://paymentpage.ecommpay.com/shared/merchant.js.
    <link rel="stylesheet" href="https://paymentpage.ecommpay.com/shared/merchant.css" />
    <script type="text/javascript" src="https://paymentpage.ecommpay.com/shared/merchant.js"></script>
  2. On the client side, add the element for displaying embedded payment buttons.
    // Displaying each embedded payment button in a separate iframe element
    <div class = "container-one" >
        <div id= "widget-container-google-pay" ></div>
        <div id= "widget-container-apple-pay" ></div>
    </div>
    
    // Displaying two embedded payment buttons in a single iframe element
    </div>
        <div class = "container-two" >
        <div id= "widget-container-one-click-buttons" ></div>
    </div>
  3. On the server side, set up data signing and sending signed data to the client side of the web service (use one of the specialised SDKs).
  4. Implement invoking the payment form on the client side using the JavaScript library from ecommpay and the EPayWidget.runEmbedded method.
  5. On the client side, implement functions for handling interface events. In addition to the functions described in this article, you can use event handlers described here.
  6. If you plan to take Apple Pay payments, make sure to register production domains of your web service in the Apple Pay service.

Use

In general, to process a payment using embedded payment buttons, the following is required:

  1. On the web service side, generate a request to open the payment form. The request must contain the configObj JavaScript object with the parameters for invoking the payment form and the signature for them.

    When creating a request for opening the payment form, consider the following:

    • The essential data set required for processing a payment in this case includes:
      • target_element—identifier of the iframe element in which the payment form should be opened
      • payment_id—payment identifier unique within the project
      • payment_amount—payment amount in the smallest currency unit
      • payment_currency—payment currency code in the ISO-4217 alpha-3 format
      • project_id—project identifier obtained from ecommpay during integration
      • merchant_domain—domain name of the web service in which the payment form should be opened
      • force_payment_group to display buttons for both methods (with the value one_click_buttons) or force_payment_method to display the button for only one of the methods (with the value apple_pay_core for the Apple Pay method or google_pay_host for the Google Pay method)
      • modePayment Page operation mode indicator with the value purchase
      • signature—request signature generated after all target parameters are specified
    • To initiate additional steps to be performed on the side of the Apple Pay and Google Pay services, specify the payment_methods_options parameter with:
      • a list of requested customer information in the billing_contact_fields array if collection of customer information is not configured for all payments within the project being used (details)
      • shipping information in the shipping object to enable shipping option selection by the customer

      The detailed list of information that can be passed in the payment_methods_options parameter can be found below.

    • To display each button in a separate iframe element, send a separate request for each of them.
    Figure 7. Example of data from a request to open the payment form
    {
      "target_element":"widget-container-one-click-buttons",
      "payment_id":"X03936",
      "payment_amount":131960,
      "payment_currency":"USD",
      "project_id":22,
      "merchant_domain":"cosmoshop.jupiter.example",
      "force_payment_group":"one_click_buttons",
      "mode":"purchase",
      "signature":"YWb6Z20ByxpQ30hfTIjaCCsVIwVynXV"
    }
    Figure 8. Example of data passed in the payment_methods_options parameter
    {
      "google_pay_host":{
        "billing_contact_fields":[
          "email",
          "name",
          "phone",
          "billing_address",
          "postal_code"
        ],
        "shipping":{
          "shipping_fields":[
            "shipping_address",
            "name",
            "phone"
          ],
          "allowed_country_codes":[
            "GB",
            "IE"
          ],
          "shipping_methods":[
            {
              "label":"Speed of sound shipping",
              "detail":"Express shipping (1 hour)",
              "amount":199,
              "identifier":"cosmo-shipping-009"
            },
            {
              "label":"Warp drive shipping",
              "detail":"Instant shipping",
              "amount":2999,
              "identifier":"cosmo-shipping-012"
            }
          ]
        }
      },
      "apple_pay_core":{
        "billing_contact_fields":[
          "email",
          "name",
          "phone",
          "billing_address",
          "postal_code"
        ],
        "shipping":{
          "shipping_fields":[
            "shipping_address",
            "name",
            "phone"
          ],
          "shipping_methods":[
            {
              "label":"Speed of sound shipping",
              "detail":"Express shipping (1 hour)",
              "amount":199,
              "identifier":"cosmo-shipping-009"
            },
            {
              "label":"Warp drive shipping",
              "detail":"Instant shipping",
              "amount":2999,
              "identifier":"cosmo-shipping-012"
            }
          ]
        }
      }
    }
  2. On the web service side, invoke the payment form using the EPayWidget.runEmbedded method, specifying the configObj JavaScript object and the onCheckSubmit handler function, following which the embedded payment button is displayed to the customer.

    The onCheckSubmit function is intended for registering and processing information about clicking the embedded button.

    Figure 9. Example of invoking the form with the use of the runEmbedded method
    const checkoutButtonsWidget = EPayWidget.runEmbedded({
        ...configObj,
        onCheckSubmit: async function (data, resolve, reject) {
            if (!await merchantPage.validateCheckoutPage()) {
                return reject()
            }
            if (!await merchantAPI.validateCartAmount(checkoutButtonsWidget.configObj.payment_amount, checkoutButtonsWidget.configObj.payment_currency)) {
                return reject()
            };
            return resolve();
        },
    }, 'POST');
  3. On the Payment Page side, clicking the embedded payment button is registered, following which on the web service side you need to verify payment information (such as the payment amount and currency as well as other required data) and call one of the functions: resolve to confirm the payment or reject to decline it. If the payment is declined, the customer should be provided with the error information from the web service side.

    Along with the payment confirmation, at this stage you can pass the customer information if it was not passed when the payment form was initialised or if it needs to be changed and specify URLs for automatic customer redirection once the payment is complete. For this, use the additional_parameters object.

    Figure 10. Example of data from the additional_parameters object
    {
    // General customer information
        customer_id:"customer_112",
        customer_first_name:"Arthur",
        customer_last_name:"McDonald",
        customer_phone:"447700900123",
        customer_email:"mcdonald@space.com",
     
    // Customer's address
        customer_country:"GB",
        customer_city:"Belfast",
        customer_address:"14A Cosmos Crescent, Flat 25",
        customer_zip:"BT99 0ZZ",
     
    // Customer's billing address
        billing_country:"GB",
        billing_city:"Belfast",
        billing_address:"14A Cosmos Crescent, Flat 25",
        billing_postal:"BT99 0ZZ",
     
    // Customer's address for the AVS check
        avs_street_address:"14A Cosmos Crescent, Flat 25",
        avs_post_code:"BT99 0ZZ",
     
    // Customer's redirection information
        redirect_success_url:"https://cosmoshop.jupiter.example/pages/success",
        redirect_success_mode:"parent_page",
        redirect_fail_url:"https://cosmoshop.jupiter.example/pages/failed",
        redirect_fail_mode:"parent_page",
    };
  4. If the request for opening the payment form contains shipping information (in the shipping object), proceed as follows:
    1. Once the customer enters the shipping address, which is registered with the onCheckShippingAddress function of the merchant.js library, ensure that the web service checks the availability of shipping to the specified address.
      Figure 11. Example of specifying the shipping address provided by the customer
      {
        "region":"Belfast City",
        "city":"Belfast",
        "country_code":"GB",
        "postal_code":"BT99 0ZZ"
      }

      Depending on the result of the availability check, call one of the following functions:

      • onCheckShippingAddress.resolve—for confirming shipping availability, with specifying the amount of the purchase with shipping being mandatory and specifying updated information about shipping details (in the shipping_methods array)—optional.
      • onCheckShippingAddress.reject—for notifying that shipping is unavailable, with an option to specify the error messages to be shown to the customer (both the general error message and the specific clarifications for each of the shipping details). It is recommended that you show extended error information for customers' convenience.
        Figure 12. Example of the error information
        errors = {
            "fields": {
                "country_code": "Supported shipping countries: GB, DE, IT",
                "region": "This region is not supported",
                "city": "Only Dublin is available",
                "postal_code": "The range of postal address 10060 - 100150",
            },
            "message": "Cannot ship to the provided address",
        }

      This step can be performed several times. It can also be performed before or after the step that follows as it depends on the actions of the customer and the specifics of the service.

    2. Once the customer selects the shipping option, which is registered with the onCheckShippingMethod function of the merchant.js library, ensure that the web service checks the availability of this shipping option.
      Figure 13. Example of specifying the shipping option selected by the customer
      {
        "identifier":"cosmo-shipping-012"
      }

      Depending on the result of the availability check, call one of the following functions:

      • onCheckShippingMethod.resolve—for confirming the shipping option availability, with specifying the amount of the purchase with shipping being mandatory.
      • onCheckShippingMethod.reject—for notifying that the shipping option is unavailable, with specifying the amount of the purchase with shipping being mandatory and the error message to be shown to the customer—optional. It is recommended that you show extended error information for customers' convenience.
        Figure 14. Example of the error information
        errors = {
            "message": "This shipping option cannot be selected for this address",
        }

      This step can be performed several times. It can also be performed before or after the step that follows as it depends on the actions of the customer and the specifics of the service.

    3. After the customer confirms the payment, which is registered with the onConfirmation function of the merchant.js library, ensure that the web service checks the details of the payment—specifically, the provided shipping address, the shipping option selected by the customer, and the updated purchase amount.
      Figure 15. Example of payment data to be checked by the web service
      {
        "customer":{
            "email":"mcdonald@space.com",
            "first_name":"Arthur",
            "last_name":"McDonald",
            "phone":"447700900123"
         },
        "billing_address":{
            "address":"14A Cosmos Crescent, Flat 25",
            "city":"Belfast",
            "region":"Belfast City",
            "country_code":"GB",
            "postal_code":"BT99 0ZZ"
        },
        "shipping_address":{
          "address":"Dock 7, Innovation Hangar",
          "city":"Belfast",
          "region":"Belfast City",
          "country_code":"GB",
          "postal_code":"BT99 1XY",
          "first_name":"Arthur",
          "last_name":"McDonald",
          "phone":"447700900321"
        }
      }

      Depending on the result of the availability check, call one of the following functions:

      • onConfirmation.resolve—for confirming the payment, with the essential payment information—project and payment identifiers, the payment amount and currency, and the signature (in the payment_update object).
        Figure 16. Example of data sent to confirm the payment
        {
          "payment_id":"X03936",
          "project_id":22,
          "payment_amount":134959,
          "payment_currency":"USD",
          "signature":"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u"
        }

        At this step, you can submit necessary customer data if it was not passed in the request to open the payment form or it needs changing in the additional_parameters object.

        Figure 17. Example of data in the additional_parameters object
        {"billing_country": "GB", "customer_email": "mcdonald@space.com", "avs_post_code": "BR1 1AA", "redirect_success_url":"https://cosmoshop.jupiter.example/order?id=123"}
        
      • onConfirmation.reject—for declining the payment, with the payment amount and the error message to be shown to the customer.
        Figure 18. Example of the error information
        errors = {
            "fields": {
                "country_code": "Supported shipping countries: GB, DE, IT",
                "region": "This region is not supported",
                "city": "Only Dublin is available",
                "postal_code": "The range of postal address 10060 - 100150",
            },
            "message": "Cannot ship to the provided address"
        }

      The information about the final purchase amount with the included shipping cost is passed in callbacks.

Additionally, on the merchant's web service side, it is possible to manage the display of the preloader page, as well as receive information about errors and payment processing results using the following functions for handling interface events:

  • onShowLoader—for displaying the web service preloader
  • onHideLoader—for hiding the web service preloader (if it is necessary to display the payment form pages to the customer)
  • onPaymentSubmitResult—for receiving information about the request identifier (if it is necessary to check payment status information)
  • onError—for receiving information about errors on the payment form side

The following is an example of the HTML code for the web service frontend that ensures the capability of performing purchases made with embedded payment buttons.

Figure 19. Example of code with functions for handling various events
const expressButtons = EPayWidget.runEmbedded({
    payment_amount: 131960,
    payment_currency: "USD",
    project_id: "22",
    payment_id: "X03936",
    force_payment_group: "one_click_buttons",
    payment_methods_options: {"google_pay_host": {"billing_contact_fields": ["name", "email", "phone", "billing_address"]}},
    target_element: "widget-container-one-click-buttons",
    merchant_domain: cosmoshop.jupiter.example,
    signature: "abcYWb6Z30hfTIjaCCsVIDEF123",
 
    onShowLoader: merchantPage.showMerchantLoader,
    onHideLoader: merchantPage.hideMerchantLoader,
    onCheckSubmit: async function (data, resolve, reject) {
        if (await merchantAPI.canStartPayment(merchantPage.cart)) {
            return resolve();
        }
        return reject();
    },
    onCheckShippingAddress: async function (data, resolve, reject) {
        const {addressIsAvailable, newPaymentAmount, newShippingMethods, errors} = await merchantAPI.validateShippingAddress(data);
        if (addressIsAvailable) {
            return resolve({payment_amount: newPaymentAmount, shipping_methods: newShippingMethods});
        } else {
            return reject({payment_amount: newPaymentAmount, errors});
        }
    },
    onCheckShippingMethod: async function (data, resolve, reject) {
        const {addressIsAvailable, newPaymentAmount} = await merchantAPI.saveShippingMethod(orderId, data.identifier);
        if (addressIsAvailable) {
            return resolve({payment_amount: newPaymentAmount});
        } else {
            return reject({payment_amount: newPaymentAmount});
        }
    },
    onConfirmation: async function (data, resolve, reject) {
        const { orderId, paymentUpdate, additionalParameters, errors } = await merchantAPI.placeOrder(merchantPage.cart, merchantPage.customerInfo);
         
        if (orderId) {
            return resolve({payment_update: paymentUpdate, additional_parameters: additionalParameters});
        } else {
            return reject({errors})
        }
    },
    onPaymentSubmitResult: async function (data) {
        await merchantAPI.saveTransactionId(data.request_id)
    },
    onError: async function ({ messages }) {
        await merchantAPI.log("Payment error occurred " + messages)
        if (messages.includes("invalid payment_id")) {
            merchantPage.redirectToContactSupportPage();
        }
    },
});

Parameters

General parameters

The following parameters can be used when you work with the functionality of embedded payment buttons.

Parameter Description

avs_post_code
string, optional

The postal code of the customer to be used in the Address Verification ServiceAVS check.

Example: BT99 0ZZ.

avs_street_address
string, optional

The address of the customer to be used in the Address Verification ServiceAVS check.

Consists of a house number and a street name.

Example: 14A Cosmos Crescent, Flat 25.

billing_address
string, optional

The house number (including any additional parts of the address such as building and apartment numbers) and the name of the street in street name of the customer's billing address.

To collect customer billing address information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: 14A Cosmos Crescent, Flat 25.

billing_city
string, optional

The name of the city in the customer's billing address.

To collect customer billing address information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: Belfast.

billing_country
string, optional

The country code in the customer's billing address in the ISO 3166-1 alpha-2 format.

To collect customer billing address information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: GB.

billing_postal
string, optional

The postal code in the customer's billing address.

To collect customer billing address information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: BT99 0ZZ.

billing_region
string, optional

The name of the region (i.e., state, province, or other administrative division type) in the customer's billing address.

To collect customer billing address information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: Belfast City.

billing_region_code
string, optional

The recipient's country subdivision code (state, province, region, or territory). The value of this parameter is the second element of a code for a subdivision (in ISO 3166-2), without the two-letter country code and the hyphen-minus used as a separator. This parameter should be specified in requests where the billing_country parameter is also specified.

The internal region code in the customer's billing address.

Consists of the second part of the ISO 3166-2 international territory code (without the two-letter country code or the separating hyphen) and should be specified in requests where the billing_country parameter is also specified.

To collect customer billing address information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: BFS.

customer_address
string, optional

The name of the street and the house number (including any additional parts of the address such as building and apartment numbers) in the customer's address, separated by a comma.

The length of the string cannot be more than 255 characters.

Example: 14A Cosmos Crescent, Flat 25.

customer_birthplace
string, optional

The name of the customer's birthplace (e.g., town, city, or other settlement type).

The length of the string cannot be more than 255 characters.

Example: York.

customer_city
string, optional

The name of the place of residence (e.g., town, city, or other settlement type) in the customer's address.

The length of the string cannot be more than 255 characters.

Example: Belfast.

customer_country
string, optional

The country code in the customer's address (in ISO 3166-1 alpha-2 format).

Specified in ISO 3166-1 alpha-2 format.

Example: GB.

customer_day_of_birth
string, optional

The date of birth of the customer in DD-MM-YYYY format.

Consists of a string specified in DD-MM-YYYY format.

Example: 12-03-1986.

customer_email
string, optional

The email address of the customer.

The length of the string cannot be more than 255 characters. The string consists of a local-part and a domain name, separated by the @ symbol.

To collect customer email address information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: mcdonald@space.com.

customer_first_name
string, optional

The first name of the customer.

The length of the string cannot be more than 255 characters.

To collect customer first name information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: Arthur.

customer_id
string, optional

The identifier assigned to the customer within the scope of the project (specified in project_id).

Each web service account should be linked to only one identifier and vice versa. This requirement is intended to address various risks and fraudulent operations.

Example: customer_112.

customer_last_name
string, optional

The last name of the customer.

The length of the string cannot be more than 255 characters.

To collect customer last name information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: McDonald.

customer_middle_name
string, optional

The middle, second, or patronymic name of the customer.

The length of the string cannot be more than 255 characters.

Example: Rhys.

customer_phone
string, optional

The phone number of the customer.

Generally, should include the country code and contain between 4 and 24 digits.

Generally, should include the country code; however, some cases do not require a country code to be specified.

Should contain between four and 24 digits. If a particular project and payment method allow for the inclusion of punctuation marks and special characters in the phone number, the parameter can contain such characters in those cases; this is usually specially arranged beforehand.

To collect customer phone number information on the Apple Pay and Google Pay service side, use the payment_methods_options parameter.

Example: 447700900123.

customer_state
string, optional

The name of the region (state, province, or other administrative subdivision type) of in the customer's address.

The length of the string cannot be more than 255 characters.

Example: Belfast City.

customer_street
string, optional

The name of the street in the customer's address.

The length of the string cannot be more than 255 characters.

Example: Cosmos Crescent.

customer_zip
string, optional

The postal or zip code in the customer's address.

The length of the string cannot be more than 10 characters.

Example: BT99 0ZZ.

force_payment_method
string, required*

For processing payments using embedded payment buttons; can take one of the following values:

  • apple_pay_core—to display the button for the Apple Pay method
  • google_pay_host—to display the button for the Google Pay method

Only one of the parameters, force_payment_method or force_payment_group, must be specified with each payment form invocation, not both.

Example: google_pay_host.

force_payment_group
string, required*

For processing payments using embedded payment buttons; can take the value one_click_buttons. In this case, buttons for both methods, Apple Pay and Google Pay, are displayed.

Only one of the parameters, force_payment_method or force_payment_group, must be specified with each payment form invocation, not both.

Example: one_click_buttons.

merchant_domain
string, required

Domain name of the web service in which the payment form should be opened.

Example: cosmoshop.jupiter.example.

mode
string, required

Indicator that specifies the Payment Page operation mode.

For processing payments using One-click buttons, must take the value purchase.

Example: purchase.

payment_amount
integer, required

The amount of the payment in the smallest currency unit.

Specified in the smallest currency unit without a decimal separator.

Example: 131960 (for the amount of 1319.60 in the currency with two decimals).

payment_currency
string, required

Three-letter code of the payment currency.

The payment currency code (in the ISO-4217 alpha-3 format, according to the currency codes reference).

Specified in the ISO-4217 alpha-3 format, according to the currency codes reference.

Example: USD.

payment_id
string, required

The payment identifier assigned within the project; at most 255 characters long, case-insensitive.

Must be assigned by the web service. Should consist of a string no longer than 255 characters, be case-insensitive, and correspond one-to-one with the relevant payment within that project.

Example: X03936.

payment_methods_options
string, optional

Additional information relevant for specific payment methods and third-party services. Should include parameters listed in the table below.

project_id
integer, required

Identifier of the project intended to manage the interactions of the web service with the payment platform. This identifier is, assigned by ecommpay during the integration (details).

Example: 22.

redirect_fail_url
string, optional

URL for final redirection to the web service if the purchase is declined.

Example: https://cosmoshop.jupiter.example/pages/failed.

redirect_success_url
string, optional

URL for final redirection to the web service by customer decision when a purchase is completed.

Example: https://cosmoshop.jupiter.example/pages/success.

signature
string, required

The digital signature used to sign the query parameters (see this article).

Should be generated using the appropriate algorithm after all relevant parameters have been specified (see this article).

target_element
string, required

The iframe element identifier (for the HTML page of the web service) of the element where the payment form should be opened for opening the payment form.

Example: widget-container-one-click-buttons.

Parameters specific to Apple Pay and Google Pay

When working with the functionality of embedded payment buttons, you can specify the following data relevant to Apple Pay or Google Pay payments in the payment_methods_options parameter.

Parameter Description

google_pay_host
object, optional

Additional information relevant for Google Pay payments. 29-2

shipping
object, optional

Shipping information. 29-2-129-2

shipping_fields
array, optional

Shipping address information, to be collected on the Google Pay service side.

An array with the list of required data, including:

  • phone—the phone number of the shipment recipient
  • name—the first and last name of the shipment recipient
  • shipping_address—shipping address

Example: "shipping_fields":["shipping_address"]

29-2-1-129-2-1

allowed_country_codes
array, optional

Information about the countries where the shipping is available. If this information is not specified, the shipping is deemed available in all countries.

An array with the list of country codes in ISO 3166-1 alpha-2.

Example: "allowed_country_codes":["GB","IE"]

29-2-1-229-2-1

shipping_methods
array, optional

Information about available shipping options. The shipping option listed first is shown in the Google Pay service as a default one. 29-2-1-329-2-1

label
string, required*

The name of the shipping option to be shown to the customer.

Must be specified when the shipping_methods array is passed.

Example: Warp drive shipping

29-2-1-3-129-2-1-3

detail
string, required*

Description of the shipping option to be shown to the customer.

Must be specified when the shipping_methods array is passed.

Example: Instant shipping

29-2-1-3-229-2-1-3

amount
integer, required*

The cost of the shipping, in the smallest currency unit.

Specified in the smallest unit of currency passed in the payment_currency parameter, without a decimal separator.

Must be specified when the shipping_methods array is passed.

Example: 2999 (for the amount of 29.99 in the currency with two decimals)

29-2-1-3-329-2-1-3

identifier
string, required*

The identifier of the shipping option, assigned on the side of the web service.

Must be specified when the shipping_methods array is passed.

Example: cosmo-shipping-012

29-2-1-3-429-2-1-3

billing_contact_fields
array, optional

Customer billing address information to be collected on the Google Pay service side.

Represents an array with a list of requested information, which can include:

  • email—the customer's email address
  • name—the customer's first and last name
  • phone—the customer's phone number
  • postal_code—the postal code from the customer's address
  • billing_address—the customer's billing address

Example: "billing_contact_fields":["email","phone"].

29-2-229-2

button_height
integer, optional

Button height in pixels.

Example: 40.

29-2-329-2

apple_pay_core
object, optional

Additional information relevant for Apple Pay payments. 29-1

shipping
object, optional

Shipping information. 29-1-129-1

shipping_fields
array, optional

Shipping address information, to be collected on the Apple Pay service side.

An array with the list of required data, including:

  • phone—the phone number of the shipment recipient
  • name—the first and last name of the shipment recipient
  • shipping_address—shipping address

Example: "shipping_fields":["shipping_address"]

29-1-1-129-1-1

shipping_methods
array, optional

Information about available shipping options. The shipping option listed first is shown in the Apple Pay service as a default one. 29-1-1-329-1-1

label
string, required*

The name of the shipping option to be shown to the customer.

Must be specified when the shipping_methods array is passed.

Example: Warp drive shipping

29-1-1-3-129-1-1-3

detail
string, required*

Description of the shipping option to be shown to the customer.

Must be specified when the shipping_methods array is passed.

Example: Instant shipping

29-1-1-3-229-1-1-3

amount
integer, required*

The cost of the shipping, in the smallest currency unit.

Specified in the smallest unit of currency passed in the payment_currency parameter, without a decimal separator.

Must be specified when the shipping_methods array is passed.

Example: 2999 (for the amount of 29.99 in the currency with two decimals)

29-1-1-3-329-1-1-3

identifier
string, required*

The identifier of the shipping option, assigned on the side of the web service.

Must be specified when the shipping_methods array is passed.

Example: cosmo-shipping-012

29-1-1-3-429-1-1-3

billing_contact_fields
array, optional

Customer billing address information to be collected on the Apple Pay service side.

Represents an array with a list of requested information, which can include:

  • email—the customer's email address
  • name—the customer's first and last name
  • phone—the customer's phone number
  • postal_code—the postal code from the customer's address
  • billing_address—the customer's billing address

Example: "billing_contact_fields":["email","phone"].

29-1-229-1

button_height
integer, optional

Button height in pixels.

Example: 40.

29-1-329-1