Pay Integration

This page illustrates some integration options for the Pay module. The Pay module can be integrated directly into your game development environment.


  • Pay Developer access

  • Optional: Web-hook server (e.g. nodejs, ngrok)

Getting Started

The Pay module makes use of REST API calls to trigger certain actions. These action will create events that are retrievable via web-hooks. The following shell command illustrates how to initiate the Pay payment.

curl \
  -d amount=2500 \
  -d currency=USD \
  -d description=" Tee (Unisex)"

This API can be called using either your Secret Key or Publishable Key. These keys are generated in the merchant centre dashboard.

Unity Web-view Module

To use the Pay module in Unity we can simple use the UnityWebRequest module to simulate a post request. We recommend to use a web-hook server to retrieve the payment event responses. This section illustrates how a new web-view game object is created to display the Pay page within the game. To install the web-view module, please follow the examples below.

Step 1. Create a new 3d Game in Unity.

Step 2. Add the following dependency to the manifest file in Packages/manifest.json

"net.gree.unity-webview": "",

Step 3. Create a button game object.

Step 4. Create a script called CdcPay.cs and add the following code to yourc

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Networking; 

public class CdcPay : MonoBehaviour
    public Text status;
    WebViewObject webViewObject;

    public class Response {
        public string payment_url;

    public void OnCDCPay()

    IEnumerator Checkout()
        WWWForm form = new WWWForm();
        form.AddField("amount", "1000");
        form.AddField("currency", "USD");
        form.AddField("description", "Product Name");
        form.AddField("return_url", "");
        form.AddField("cancel_url", "");

        using (UnityWebRequest www = UnityWebRequest.Post("", form))
            www.SetRequestHeader("Authorization", "Bearer YOUR_PUBLISHABLE_KEY");
            yield return www.SendWebRequest();
            Response data = JsonUtility.FromJson<Response>(System.Text.Encoding.UTF8.GetString(;
            if (www.result != UnityWebRequest.Result.Success)
                webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>();
                webViewObject.Init((msg) => {

Step 5. Create an empty game object called script, and add the CdcPay.cs script to it.

Step 6. Drag the script game object into the button onClick component and select the CdcPay() method

Step 7. Run from the editor and click the checkout button.

Step 8. Complete a test order and retrieve the payload via web-hook as explained in the next section.


Web-hooks make it easier to integrate with Pay by allowing you to subscribe to a set of events. You can refer to Resources for the schema of the objects.


To simulate a purchase and retrieve the payload from the Pay events, you can use this web-hook server example.



Step 1. Clone the following repository

git clone

Step 2. Run the following commands:

cd demo
npm install
node server.js

Please ensure to replace the SIGNATURE_SECRET from you merchants dashboard after adding the web-hook endpoint

Step 3. Open a new terminal and run the following command:

ngrok http 4567

Step 4. Add the forwarding url from the ngrok GUI as your payload endpoint in your merchant dashboard.

Step 5. Run the Pay API from a client (e.g. the web-view module in Unity). Pay documentation

You can read more about the Pay integration here.

Last updated