Cronos EVM Docs
  • Getting Started
    • Getting Started
    • Background
    • Architecture
    • Cronos roadmap
  • FOR USERS
    • 💳Crypto.com Card Top Up
    • 🔥Crypto Wallets
    • 🦊MetaMask Configuration
    • 🦁Brave Wallet
    • 🌉Bridges
      • From the Crypto.com App and Exchange
        • From the Crypto.com App
        • From the Crypto.com Exchange
      • IBC (Cronos POS Chain, other Cosmos chains)
        • Cronos Bridge Web App
      • Independent bridges
      • FAQs for Bridge transfers
      • FAQs for transactions from/to centralized exchanges
    • 🚰Testnet Faucet
    • 💡Tips & FAQs
    • 👮Key Principles for Wallet Security
    • GasTracker
  • FOR DAPP DEVELOPERS
    • 💡Founder FAQs
    • 🏅Hacker's Getting Started Resources
    • 📃Smart Contracts
      • Contract Development on Testnet
      • Contract Deployment and Verification
      • Contract Verification Export: Cronoscan To Cronos Explorer
      • Best Practices
      • Token Contract Addresses
    • 💻dApp Creation
      • Free and commercial RPC endpoints
      • Wallet integrations
      • Web3-wallet
      • JSON-RPC methods
      • Address Conversion
      • Swagger Playground
    • ⚙️Dev Tools & Integrations
      • All dev tools & integrations
      • Account Abstraction
      • Band Protocol
      • Banxa
      • GoldRush
      • Cronos Safe
      • Flair
      • Google Bigquery
      • Moralis
      • Pyth
      • Secret Network
      • SubQuery
      • Witnet
    • Crypto.com AI Agent SDK
  • FOR NODE HOSTS
    • Running nodes
      • Cronos Mainnet
        • Quicksync
        • State-sync
        • Public Node Sync
        • KSYNC
        • The "Huygen" upgrade guide (v0.6.* to v0.7.*)
        • The "v0.7.0-hotfix" upgrade guide (v0.7.* to v0.8.*)
        • The "Galileo" upgrade guide (v0.8.* to v1.0.*)
        • The "Titan" upgrade guide (v1.0.* to v1.1.0)
        • The "v1.2" upgrade guide (v1.1.* to v1.2.0)
        • The "v1.3" upgrade guide (v1.2.* to v1.3.0)
        • The "v1.4" Pallene upgrade guide (v1.3.* to v1.4.1)
        • Patching Unlucky & Duplicate Tx
      • Cronos Testnet
      • Devnet
      • Best Practices
      • Cronosd build with Nix
      • VersionDB
      • MemIAVL
      • Local State Sync
    • Cronosd
  • CRONOS PLAY
    • Introduction
    • Unity Engine
      • Current Version
      • Legacy Version
        • EVM
        • Login Example
        • Custom RPC
        • ERC20
        • ERC721
        • ERC1155
      • Useful Links
    • Unreal Engine
      • Installation and Enabling
      • Working with Blueprint
        • Actors and Blueprint Classes
        • Cronos Configuration
        • Connect Defi Desktop/Onchain Wallet with URI
        • Connect Wallets with QR Code
        • Connect WalletConnect Step by Step
        • WalletConnect 2.0 and Unreal Engine 5: Hello World Example
        • Wallet
        • ERC20
        • ERC721
        • ERC1155
        • Broadcast Transactions
        • Get Tokens or Transactions
      • Working with C++
        • Creating a C++ Project
        • Creating a child DefiWalletCoreActor
        • Querying a contract
        • Customizing Network
      • Demo
    • Cronos Play C++ SDK
    • Crypto.com Pay Integration
    • Cronos Play FAQ
  • Block Explorers
    • Block Explorer and API Keys
    • Cronos Explorer
    • Cronoscan
  • CRONOS CHAIN PROTOCOL
    • Chain ID and Address Format
    • Cronos General FAQ
    • Genesis
    • Modules
      • module_bank
      • module_distribution
      • module_slashing
      • module_feemarket
    • Chain Details
      • List of parameters
      • Technical glossary
      • Protocol Documentation
    • Common IBC Commands
  • Cronos zkEVM
    • Cronos zkEVM
  • Resources
    • Media / brand kit
Powered by GitBook
On this page
  • Pre-requisites
  • Getting Started
  • Unity Web-view Module
  • Web-Hooks
  • Overview
  • Requirements
  • Installation
  • Crypto.com Pay documentation

Was this helpful?

Edit on GitHub
  1. CRONOS PLAY

Crypto.com Pay Integration

PreviousCronos Play C++ SDKNextCronos Play FAQ

Last updated 5 months ago

Was this helpful?

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

Pre-requisites

  • Crypto.com Pay Developer

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

Getting Started

The Crypto.com 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 Crypto.com Pay payment.

POST https://pay.crypto.com/api/payments
curl https://pay.crypto.com/api/payments \
  -u PUBLISHABLE_KEY: \
  -d amount=2500 \
  -d currency=USD \
  -d description="Crypto.com Tee (Unisex)"

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

Unity Web-view Module

To use the Crypto.com Pay module in Unity we can simple use the 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 Crypto.com 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": "https://github.com/gree/unity-webview.git?path=/dist/package",

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()
    {
        StartCoroutine(Checkout());
    }

    IEnumerator Checkout()
    {
        WWWForm form = new WWWForm();
        form.AddField("amount", "1000");
        form.AddField("currency", "USD");
        form.AddField("description", "Product Name");
        form.AddField("return_url", "http://YOUR_WEBSITE.com/orders/123/complete");
        form.AddField("cancel_url", "http://YOUR_WEBSITE.com/orders/123/fail");

        using (UnityWebRequest www = UnityWebRequest.Post("https://pay.crypto.com/api/payments", form))
        {
            www.SetRequestHeader("Authorization", "Bearer YOUR_PUBLISHABLE_KEY");
            yield return www.SendWebRequest();
            Response data = JsonUtility.FromJson<Response>(System.Text.Encoding.UTF8.GetString(www.downloadHandler.data));
            
            if (www.result != UnityWebRequest.Result.Success)
            {
                Debug.Log(www.error);
                Debug.Log(www.downloadHandler.data);
            }
            else
            {
                webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>();
                webViewObject.Init((msg) => {
                Debug.Log(msg);
                });
                webViewObject.LoadURL(data.payment_url);
                webViewObject.SetVisibility(true); 
            }                    
        }
    }
}

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

Overview

Requirements

Installation

Step 1. Clone the following repository

git clone https://github.com/cronos-labs/play-cpp-sdk.git

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 Crypto.com Pay API from a client (e.g. the web-view module in Unity).

Crypto.com Pay documentation

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

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

You can read more about the Crypto.com Pay integration .

module
access
ngrok
dashboard
UnityWebRequest
Resources
example
node.js
ngrok
here
Click Button
Complete Test Payment