Specifying extended purchase data for subsequent merchant use

Introduction

In addition to specifying required and provider-recommended parameters in In payment requests, merchants sometimes need to pass data that is related to specific payments and their statuses and that can be subsequently used by merchants them at their discretion. For this purpose, the Gate API includes the parameters that allow passing various data in requests and receiving these data together with other information in final callbacks.

Notice: When processing payments via Payment Page, you can use similar capabilities.

Specifying other extended purchase data

Overview

The merchant.data parameter can be used for keeping track of extended information about the order, applying promotions and bonus points, and other relevant data. In addition, the value of this parameter can be combined with the information passed in the payment.description parameter and the receipt information passed in the receipt_data object. As a result, all necessary data can be provided in callbacks without passing certain pieces of information multiple times in different parameters.

Use case

Here is an example of a use case when a merchant in the video game industry needs to:

  • collect and process data about add-on services that the gamers purchase as they play.
  • Provide the company's employees with the timely access to such information about each customer.

Merchant specialists in charge of the integration inform the Flashpay account manager about these requirements. As a result, the following workflow is devised and set up:

  1. Each request sent from the merchant web service to Gate contains information about the purchased services—passed as a JSON object in the data parameter of the merchant object.

    The data string includes the following:

    • The items array in which each element contains the SKU (sku), the description (description), and the number of the purchased services (count).
    • The total_count parameter with the total number of the purchased services or goods items.
    • The user_id parameter with the internal identifier of the customer.
  2. When a payment has been processed, the information specified in the data string is passed to the merchant web service in the final callback and can be viewed in the payment information tab in Dashboard.
  3. The web service processes this information as needed together with the rest of the payment data.

Setup

To use the capability of passing information in the merchant.data parameter, contact your account manager. The capability is then set up in the payment platform by the Flashpay specialists who will subsequently inform you that it is ready to be used and that the extended information is now available in callbacks and in the Dashboard interface.

Data format

In requests to process payments via Gate, the data specified in the merchant.data parameter must be passed as a JSON object. However, because this parameter is a string (string), to pass the JSON object in it when using the HTTP POST method, you need to escape the " character (quotation mark, U+0022) by adding \ (backlash or reverse solidus, U+005C) in front of it. It is necessary in order to distinguish on the level of programmatic interaction which quotation marks close the string and which quotations marks are part of the JSON contents within the string.

In final callbacks with payment results, the data that was specified in the merchant.data parameter is passed in the data parameter of the merchant object.

In the following examples, the contents of the parameter are split into several lines for the reader's convenience.

Figure 1. Example of data passed in the POST request (with escape sequences)
"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\"}"
Figure 2. Example of data passed in the final callback with the payment result information (with escape sequences)
"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\"}" 
}