Using embedded buttons for Apple Pay and Google Pay 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 appearance 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.

Special aspects

When using embedded Apple Pay and Google Pay buttons from ecommpay, consider the following special aspects:

  • Embedding branded payment buttons directly into the web service of the merchant can improve user experience and increase conversion rates: firstly, the buttons of these global payment services are easily recognised and enhance customer trust, and, secondly, with the use of these buttons the number of steps in the standard user scenario is kept to a minimum, without any additional redirections and confirmations. To compare, opening Payment Page with the Apple Pay or Google Pay method preselected adds at least one more step to a similar user scenario.
  • The design of the branded buttons is customised according to the guidelines of Apple and Google and can be configured by the merchant as long as the style is consistent with their recommendations.
  • The minimalist design of the embedded buttons can be useful in different cases, namely, for interfaces with high information density or for mobile purchases.
  • Processing a payment with the use of embedded buttons implies native collection of necessary additional customer data (including the customer's billing address, shipping address and shipping option, and other details) directly in the Apple Pay and Google Pay services, within the payment session. It spares merchants the effort of collecting these data on the side of the web service or in Payment Page, as well as prevents increasing the number of steps in user scenarios and eliminates the need to take more action in order to configure this functionality.
  • When the customer has been authenticated in the Apple Pay or Google Pay service, and this service already has relevant information, the customer's payment can be processed according to the express checkout flow. This processing workflow implies that all necessary customer data (card details, billing address, and shipping information) is automatically collected and specified. In addition, the relevant shipping information and billing address can be available to the merchant through the payment session of this service. The express checkout flow can be useful for unregistered customers, as it enables guest checkout, without the need to create a user account in the web service.
  • The Apple Pay and Google Pay buttons can be embedded into any page of the web service (for example, the product page or the section of the product catalogue) and into almost any structural element of the web page (including menus, various panels and containers), which ensures high level of flexibility and allows implementation of various ways to guide customers to payment.

Processing scenario

Below is a user scenario of making a purchase with embedded buttons.

  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).

Button design styles

The merchant can customise different aspects of the branded button's appearance, including the button's colour, contents (i.e. the caption and the logo), placement, size, and corner radius, with the help of the following parameters for opening the payment form.

Figure 5. Standard and customised design styles

When working with the parameters for customising the appearance of branded buttons, consider the following:

  • You must comply with the requirements and guidelines of Apple (details) and Google (details).
  • Values that you specify for parameters determining the placement and the size of the buttons apply to all buttons used, whereas other parameters can be passed to customise each branded button individually.
  • If you specify the layout option for the buttons, it will be applied only when the width of the element where the buttons are embedded exceeds 1047 pixels. In all other cases, the buttons will be vertically stacked.
  • To resize the buttons, you can specify their height, but not their width. The width is determined automatically and is adjusted depending on the width of the element where the buttons are embedded and the number of buttons in one row. The minimum allowed width of each button is 160 pixels, and the maximum allowed corresponds to the width of the element where the buttons are embedded. The default height of the buttons is 44 pixels.

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 6. 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 7. 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.
    Warning: Keep in mind that to ensure correct behaviour of the payment form, you must link the ecommpay CSS library via the CDN (Content Delivery Network). Storing this library locally is not allowed.
    <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="row">
      <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 id="widget-container-one-click-buttons"></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 made with the use of embedded payment buttons, you need to:

  1. Generate requests to display the required buttons.
  2. Invoke the payment form displayed as branded buttons.
  3. Confirm the transition to payment when the customer clicks a specific button.
  4. Confirm the availability of the shipping option selected by the customer.
  5. Confirm processing the payment with the finalised set of parameters.

Here is a more detailed description of these steps:

  1. Generate the required number of requests to open a payment form displayed as branded buttons.

    It can be one request to display both buttons in a single iframe element, two separate requests to display each button in separate iframe elements, or one separate request to display just one of the buttons. Each of the requests 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 parameters have been specified
    • To initiate additional steps to be performed on the side of the Apple Pay and Google Pay services, use the payment_methods_options parameter and specify the following:

      • 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)
      • information about the available shipping options in the shipping object—so that the customer can select one

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

    Figure 8. 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 9. Example of data specified in the payment_methods_options parameter
    {
      "express_checkout":{
        "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"
            }
          ]
        },
          "buttons":{
             "max_column":1,
             "height": 40,
             "border_radius": 100
          }
      },
       "google_pay_host":{
          "shipping":{
             "allowed_country_codes":[
                "GB",
                "IE"
             ]
          },
          "button":{
             "color":"black",
             "type":"checkout",
             "border_type":"no_border"
          }
       },
      "apple_pay_core":{
          "button":{
             "theme":"black",
             "type":"buy"
          }
       }
    }
  2. Invoke the payment form using the EPayWidget.runEmbedded method.

    When invoking the form, specify the configObj JavaScript object and declare necessary event handler functions, such as onCheckSubmit (used for handling button click information; more details below).

    Figure 10. 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() // Decline of purchase
            }
            if (!await merchantAPI.validateCartAmount(checkoutButtonsWidget.configObj.payment_amount, checkoutButtonsWidget.configObj.payment_currency)) {
                return reject() // Decline of purchase
            };
            return resolve(); // Purchase confirmation, with the option to specify the additional_parameters object as an argument
        },
    }, 'POST');
  3. When the customer confirms the payment (via the embedded button), check the payment details (including the amount and currency, as well as other important parameters) and call the relevant function: resolve to confirm the purchase or reject to decline it.

    At this stage, along with the payment confirmation, you can specify additional information if it was not specified when the payment form was invoked or if the information needs to be changed. You can pass:

    • customer information and redirect URLs—in the additional_parameters object
    • the customer identifier, information about the purchased items, and extended purchase data to be used on the web service side—in the payment_update object (in which you also specify the project identifier, the payment identifier, amount, and currency, as well as the signature for the parameters in this object)

    If the payment is declined, the customer should be provided with information about the error on the web service side.

    Figure 11. Example of data from the additional_parameters object
    {
    // General customer information
        customer_first_name:"Arthur",
        customer_last_name:"McDonald",
        customer_phone:"447700900123",
        customer_email:"mcdonald@space.com"
     
    // Customer's residential 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 used 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",
    };
    Figure 12. Example of data from the payment_update object
    {
       "project_id":22,
       "payment_id":"X03936",
       "payment_amount":131960,
       "payment_currency":"USD",
       "customer_id":"customer_112",
       "receipt_data":"eyJwb3NpdGlvbnMiOiBbeyJxdWFudGl0eSI6IDMsICJhbW91bnQiOiAxMDAwMCwgInRheCI6IDE4LCAidGF4X2Ftb3VudCI6IDE4MDAsICJkZXNjcmlwdGlvbiI6ICJEZXNpZ24gZnJhbWUifV0sICJ0b3RhbF90YXhfYW1vdW50IjogMTgwMCwgImNvbW1vbl90YXgiOiAxOH0=",
       "merchant_data":"{\"items\":[{\"sku\":\"GM12-CC\", \"description\":\"10 Copper Coins\",\"count\":1}, {\"sku\":\"GM12-GC\",\"description\":\"Golden Coin\", \"count\":2}],\"total_count\":3,\"user_id\":\"122\"",
       "signature":"OoyvuCort6RIe8jofbUwZMWhkTaIIr7iIDFwry3bKc0iWGRMqPB1/8jVK4yJX+dv2AZDrNU7Ip4TMcqMG8AD8w=="
    }
  4. If the request to open a payment form included information about available shipping options for goods or services in the shipping object, verify and confirm (or decline) the shipping availability.

    Use the onCheckShippingAddress and onCheckShippingMethod functions of the merchant.js library to respond to the customer's input of a shipping address and shipping option, respectively. When using these functions, keep in mind that the order in which the shipping address and shipping option are specified may vary depending on the specifics of the service being used, and that checking the shipping availability is repeated whenever the customer's input changes. You are also recommended to ensure that the error messages related to shipping availability are structured to provide sufficient information and convenience to customers and prevent future errors.

    To check shipping availability, each time the customer changes shipping parameters, follow these steps:

    • Regarding the shipping address, check the availability of shipping to the address specified by the customer and call the relevant function:
      • onCheckShippingAddress.resolve—to confirm shipping availability, with the mandatory passing of the payment amount with shipping included and, if applicable, with updated shipping parameters (specified in the shipping_methods array).
      • onCheckShippingAddress.reject—to notify that shipping is unavailable, with the mandatory passing of the payment amount excluding shipping and, if applicable, with the messages to be displayed to the customer, including a general error message and specific clarifications for each of the shipping details.
      Figure 13. Example of passing the shipping address provided by the customer
      {
        "region":"Belfast City",
        "city":"Belfast",
        "country_code":"GB",
        "postal_code":"BT99 0ZZ"
      }
      Figure 14. 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"
      }
    • Regarding the shipping option, check the availability of the shipping option selected by the customer and call the relevant function:

      • onCheckShippingMethod.resolve—to confirm shipping availability, with the mandatory passing of the payment amount with shipping included.
      • onCheckShippingMethod.reject—to notify that shipping is unavailable, with the mandatory passing of the payment amount excluding shipping and, if applicable, with the messages to be displayed to the customer.
      Figure 15. Example of specifying the shipping option selected by the customer
      {
        "identifier":"cosmo-shipping-012"
      }
      Figure 16. Example of the error information
      errors = {
          "message": "This shipping option cannot be selected for this address",
      }
  5. If you need to confirm the payment (with the selected shipping address and shipping option, or other details provided by the customer), check whether the finalised payment information is accurate.

    Use the onConfirmation function of the merchant.js library to obtain this information. After verifying, call the relevant function:

    • onConfirmation.resolve—to confirm the payment, with final details provided by the web service. This information includes:
      • the project identifier, the identifier, amount, and currency of the payment, and other relevant information (as needed, including information about the purchased items and extended purchase data for subsequent use on the web service side) and the signature for these parameters in the payment_update object
      • customer information and redirect URLs (if such information needs to be specified or updated) in the additional_parameters object
    • onConfirmation.reject—to decline the payment, with the mandatory passing of the payment amount and, if applicable, with the error message to be displayed to the customer.
    Figure 17. Example of payment information for verification on the web service side
    {
      "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"
      }
    }
    Figure 18. Example of payment confirmation information
    {
       "project_id":22,
       "payment_id":"X03936",
       "payment_amount":131960,
       "payment_currency":"USD",
       "customer_id":"customer_112",
       "receipt_data":"eyJwb3NpdGlvbnMiOiBbeyJxdWFudGl0eSI6IDMsICJhbW91bnQiOiAxMDAwMCwgInRheCI6IDE4LCAidGF4X2Ftb3VudCI6IDE4MDAsICJkZXNjcmlwdGlvbiI6ICJEZXNpZ24gZnJhbWUifV0sICJ0b3RhbF90YXhfYW1vdW50IjogMTgwMCwgImNvbW1vbl90YXgiOiAxOH0=",
       "merchant_data":"{\"items\":[{\"sku\":\"GM12-CC\", \"description\":\"10 Copper Coins\",\"count\":1}, {\"sku\":\"GM12-GC\",\"description\":\"Golden Coin\", \"count\":2}],\"total_count\":3,\"user_id\":\"122\"",
       "signature":"OoyvuCort6RIe8jofbUwZMWhkTaIIr7iIDFwry3bKc0iWGRMqPB1/8jVK4yJX+dv2AZDrNU7Ip4TMcqMG8AD8w=="
    }
    Figure 19. Example of data from 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"}
    
    Figure 20. Example of 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"
    }

Additionally, on the merchant's web service side, it is possible to manage the display of the preloader page and 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

You can also use callbacks to monitor payment processing results.

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 21. 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 Service check.

Example: BT99 0ZZ.

avs_street_address
string, optional

The address of the customer to be used in the Address Verification Service 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 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.

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.

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.

Specified in ISO 3166-1 alpha-2 format.

Example: GB.

customer_day_of_birth
string, optional

The date of birth of the customer.

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; 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 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_data
string, optional

Additional information that needs to be tracked by the web service.

The data that is passed in this parameter can vary. However, what data set is passed in this parameter should be communicated to the ecommpay specialists and configured beforehand to ensure the data is processed and displayed correctly in callbacks and payment information tabs (see this article). In specific cases can contain a JSON object; then, the " character (quotation mark, U+0022) needs to be preceded by the \ escape character (reverse solidus, U+005C) in order to be sent via a POST request.

Figure 22. Example of a JSON object for a POST request, with escape characters
"merchant_data": "{\"items\":[{\"sku\":\"GM12-CC\",
        \"description\":\"10 Copper Coins\",\"count\":1},
        {\"sku\":\"GM12-GC\",\"description\":\"Golden Coin\",
        \"count\":2}],\"total_count\":3,\"user_id\":\"122\"}"

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.

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

Example: USD.

payment_id
string, required

The payment identifier.

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.

receipt_data
string, optional

Information about line items in an order.

Can be used to generate a proof of purchase document to be sent to the customer (see this article). Consists of a string obtained by encoding a JSON object using the Base64 encoding scheme. The JSON object can include various combinations of elements from the list of supported data.

Figure 23. Supported data
  • positions, array—array which allows listing up to 300 purchased items in the notification. For each listed item, the following information can be specified:
    • amount, integer—the price of the item
    • quantity, integer—the number of purchased items of the same kind
    • tax, integer—the VAT rate if it differs for different listed items
    • tax_amount, integer—the VAT amount
    • description, string—the description of the purchased item.
  • total_tax_amount, integer—the total VAT amount for the entire purchase
  • common_tax, integer—the VAT rate if it is the same for all listed items
Figure 24. Example of a JSON object
{  
   "receipt_data":{  
      "positions":[  
         {  
            "quantity":3,
            "amount":10000,
            "tax":18,
            "tax_amount":1800,
            "description":"Design frame"
         }
      ],
      "total_tax_amount":1800,
      "common_tax":18       
   }
}
Figure 25. Example of the resulting string
receipt_data: "eyAgCiAgICAgICJwb3NpdGlvbnMiOlsgIAogICAgICAgICB7ICAKICAgICAg
ICAgICAgInF1YW50aXR5IjozLAogICAgICAgICAgICAiYW1vdW50IjoxMDAwMCwKICAgICAgICAgICAgInRheCI
6MTgsCiAgICAgICAgICAgICJ0YXhfYW1vdW50IjoxODAwLAogICAgICAgICAgICAiZGVzY3JpcHRpb24iOiJEZXN
pZ24gZnJhbWUiCiAgICAgICAgIH0KICAgICAgXSwKICAgICAgInRvdGFsX3RheF9hbW91bnQiOjE4MDAsCiAgICA
gICJjb21tb25fdGF4IjoxOCAgICAgICAKfQ"

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.

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.

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 and Google Pay payments in the payment_methods_options parameter.

Parameter Description

express_checkout
object, optional

Additional information relevant for all payment methods. 29-3

buttons
object, optional

Parameters customising the appearance of the branded buttons.

Example: "buttons":{"max_column":1, "height": 40, "radius": 100 }

29-3-129-3

height
integer, optional

Height of the button, in pixels.

Will be applied to each embedded button. Can be between 40 and 55 pixels. The default value is 44 pixels.

Example: 40

29-3-1-129-3-1

border_radius
integer, optional

Corner radius of the button, in pixels.

Will be applied to each embedded button. Can be between 0 and 100 pixels. The default value is 4 pixels.

Example: 100

29-3-1-229-3-1

max_columns
integer, optional

The indicator of the layout option for the buttons embedded in the iframe element.

The specified option is applied only when the width of the element where the buttons are embedded exceeds 1047 pixels. In all other cases, the value of this parameter will be ignored and only one button is displayed in one row.

Can take one of the following values:

  • 0—as many buttons as possible are displayed in one row (flexible layout; used by default).
  • 1—only one button is displayed in one row (strictly one-column layout).
  • 2—if possible, two buttons are displayed in one row (two-column layout if possible).

Example: 1

29-3-1-329-3-1

shipping
object, optional

Shipping information. 29-3-229-3

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-3-2-129-3-2

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-3-2-329-3-2

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-3-2-3-129-3-2-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-3-2-3-229-3-2-3

amount
integer, required*

The cost of the shipping.

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-3-2-3-329-3-2-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-3-2-3-429-3-2-3

billing_contact_fields
array, optional

Customer billing address information to be collected on the Apple Pay or 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-3-329-3

google_pay_host
object, optional

Additional information relevant for Google Pay payments. 29-2

shipping
object, optional

Shipping information. 29-2-129-2

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

button
object, optional

Parameters customising the appearance of the button.

Example: "button":{"theme":"black","type":"checkout","border_type": "no_border" }

29-2-329-2

border_type
string, optional

Indicator specifying the border type of the button (details).

Can take one of the following values:

  • default_border—with the border
  • no_border—with the border removed

The default value is default_border.

Example: no_border

29-2-3-129-2-3

color
string, optional

Indicator specifying the colour of the button (details).

Can take one of the following values:

  • black—for the dark style
  • white—for the light style

The default style is dark.

Example: black

29-2-3-229-2-3

type
string, optional

Indicator specifying the button's caption according to the Google Pay documentation (details).

For example, if you pass donate, the button with caption Donate with <Google Pay> will be displayed, to be used for collecting donations.

Example: checkout

29-2-3-329-2-3

apple_pay_core
object, optional

Additional information relevant for Apple Pay payments. 29-1

button
object, optional

Parameters customising the appearance of the button.

Example: "button":{"theme":"black","type":"buy" }

29-1-329-1

theme
string, optional

Indicator specifying the colour of the button (details).

Can take one of the following values:

  • black—for the dark style without the button outline
  • white—for the light style without the button outline
  • white-outline—for the light style with the outline

The default style is dark.

Example: black

29-1-3-129-1-3

type
string, optional

Indicator specifying the button's caption according to the Apple Pay documentation (details).

For example, if you pass contribute, the button with caption Contribute with <Apple Pay> will be displayed, to be used for collecting donations.

Example: buy

29-1-3-229-1-3