### Go Payment Request with Settlement Amount Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-request-api.md Go example for creating a payment request when the business client sets the settlement amount. Generates a verify token using SHA-256, sends a POST request to the payment endpoint, and prints the payment flow starting URL or errors. ```go package main import ( "crypto/sha256" "encoding/hex" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" ) func main() { // api-endpoint API_ENDPOINT := "https://testnet.app.nodexpay.com/api/v1/payment/receive" // Authentication Token AUTH_TOKEN := "YOUR AUTHENTICATION TOKEN" // Hash Token HASH_TOKEN := "YOUR HASH TOKEN" // Code set by the business client (Integrator) to uniquely identify the payment ORDER_CODE := "GENERATE UNIQUE CODE AND STORE IT ON YOUR DATABASE" // Set amount and Generate verify token amount_to_be_charged := 10.00 // this number must be Zero or more raw := fmt.Sprintf("%s::%f::%s", ORDER_CODE, amount_to_be_charged, HASH_TOKEN) verify_token := sha256.Sum256([]byte(raw)) // data to be sent to api data := url.Values{} data.Add("identification_token", AUTH_TOKEN) data.Add("order_code", ORDER_CODE) data.Add("verify_token", hex.EncodeToString(verify_token[:])) data.Add("amount", fmt.Sprintf("%f", amount_to_be_charged)) // sending post request and saving response as response object res, _ := http.PostForm(API_ENDPOINT, data) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) var responseObj interface{} _ = json.Unmarshal(body, &responseObj) url := responseObj.(map[string]interface{})["url"] if url != nil { fmt.Printf("url: %s\n", url) } else { err := responseObj.(map[string]interface{})["errors"] fmt.Println(err) } } ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://nodex-pay.gitbook.io/docs/integration-guide/advanced-features.md Perform an HTTP GET request on the current page URL with the ask query parameter and an optional goal parameter to retrieve information dynamically. ```http GET https://nodex-pay.gitbook.io/docs/integration-guide/advanced-features.md?ask=&goal= ``` -------------------------------- ### 200 Nodex Pay invoice successfully created Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-request-api.md Successful response from the payment creation request. The first example shows the default response when ext_reserved and ext_description are not provided. The second example shows the response when those fields are included. ```javascript { "url": "https://app.nodexpay.com/payment/PAYMENT_TOKEN_ISSUED_BY_NODEX", "token": "PAYMENT_TOKEN_ISSUED_BY_NODEX", "ext_reserved": "", "ext_description": "" } ``` ```javascript { "url": "https://app.nodexpay.com/payment/PAYMENT_TOKEN_ISSUED_BY_NODEX", "token": "PAYMENT_TOKEN_ISSUED_BY_NODEX", "ext_reserved": "0x00000000000000000............", "ext_description": "This value you input as ext_description" } ``` -------------------------------- ### Generate payment URL with fixed amount (Java) Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-request-api.md Java example for generating a payment URL when the integrator sets the amount. It computes a SHA-256 verify token from order_code, amount, and HASH_TOKEN, then POSTs to the API endpoint with identification_token, order_code, verify_token, and amount. Requires the org.json library; otherwise a compile error occurs. ```java import java.net.URL; import java.net.HttpURLConnection; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.InputStreamReader; import java.security.MessageDigest; import org.json.JSONObject; // Note: that if "org.json" library is not present, a compile error will occur public class GeneratePaymentURL { public static void main(String[] args) { // api-endpoint final String API_ENDPOINT = "https://testnet.nodexpay.app.com/api/v1/payment/receive"; // Authentication Token final String AUTH_TOKEN = "YOUR AUTHENTICATION TOKEN"; // Hash Token final String HASH_TOKEN = "YOUR HASH TOKEN"; // Code set by the business client (Integrator) to uniquely identify the payment String order_code = "GENERATE UNIQUE CODE AND STORE IT ON YOUR DATABASE"; // Set amount and Generate verify token Float amount_to_be_charged = 10.0f; try{ // generate verify token String raw = String.format("%s::%.2f::%s", order_code, amount_to_be_charged, HASH_TOKEN); MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(raw.getBytes()); byte[] verify_byte = md.digest(); StringBuilder verify_token = new StringBuilder(2 * verify_byte.length); for (byte b: verify_byte) { verify_token.append(String.format("%02x", b&0xff)); } // POST URL url = new URL(API_ENDPOINT); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); // allow POST conn.setRequestMethod("POST"); conn.connect(); // POST params String params = String.format("identification_token=%s&order_code=%s&verify_token=%s&amount=%.2f", AUTH_TOKEN, order_code, verify_token, amount_to_be_charged); OutputStream os = conn.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os)); writer.write(params); writer.flush(); writer.close(); os.close(); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line); } String result = sb.toString(); JSONObject obj = new JSONObject(result); String payment_url = obj.getString("url"); System.out.println("The URL is: " + payment_url); } catch (Exception e) { System.out.println(e); } } } ``` -------------------------------- ### Create Payment Request with PHP and Ruby Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-request-api.md Sample code for creating a payment request using the NodeX Pay API. It sets up the API endpoint, authentication token, and hash token, generates a verify token by hashing the order code, amount, and hash token, then sends a POST request to receive a payment URL. The response contains the URL to start the payment flow. ```php $order_code, "amount" => $amount_to_be_charged, "hash_token" => HASH_TOKEN ]; $raw = implode("::", $generate_params); $verify_token = hash("sha256", $raw); // Data to be sent to api $request_params = [ "identification_token" => AUTH_TOKEN, "order_code" => $order_code, "amount" => $amount_to_be_charged, "verify_token" => $verify_token ]; // Sending post request and saving response as response object $curl_handler = curl_init(API_ENDPOINT); curl_setopt($curl_handler, CURLOPT_POST, true); curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_handler, CURLOPT_POSTFIELDS, $request_params); $response = curl_exec($curl_handler); curl_close($curl_handler); // Extracting response text $data = json_decode($response); echo "The URL is:{$data->url}"; ``` ```ruby require 'net/http' require 'digest' require 'json' # api-endpoint API_ENDPOINT = URI.parse('https://testnet.app.nodexpay.com/api/v1/payment/receive') # Authentication Token AUTH_TOKEN = "YOUR AUTHENTICATION TOKEN" # Hash Token HASH_TOKEN = "YOUR HASH TOKEN" # Code set by the business client (Integrator) to uniquely identify the payment order_code = "GENERATE UNIQUE CODE AND STORE IT ON YOUR DATABASE" # Set amount and Generate verify token amount_to_be_charged = 10 # this number must be Zero or more raw = "#{order_code}::#{amount_to_be_charged}::#{HASH_TOKEN}" verify_token = Digest::SHA256.hexdigest(raw) # data to be sent to api data = { 'identification_token': AUTH_TOKEN, 'order_code': order_code, 'verify_token': verify_token, 'amount': amount_to_be_charged } # sending post request and saving response as response object r = Net::HTTP.post_form(API_ENDPOINT, data) # extracting response text payment_flow_starting_url = JSON.parse(r.body)['url'] p "The URL is: #{payment_flow_starting_url}" ``` -------------------------------- ### Implement Payment Status API in Python Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Provides a GET endpoint to retrieve order information based on a payment token. ```python def get_order(): query = NodexOrder.select() return json.loads(json.dumps(list(query.dicts()), default=str)) @app.route('/order', methods=['GET']) def get_order_route(): payment_token = request.args.get('payment_token') print(payment_token) orders = get_order() print(orders) return jsonify(orders) ``` -------------------------------- ### Next.js: Create order and redirect to payment URL Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-frontend-and-integrate-apis.md Use this Next.js function to call the API created in the previous section. It posts to `process.env.API_URL_CREATE_ORDER_NORMAL` and redirects to `result.data.paymentUrl` on success. On failure, it alerts the user to continue or restart the payment. ```javascript const callCheckout = async (data) => { // call the API that you created previous section const apiUrl = process.env.API_URL_CREATE_ORDER_NORMAL const result = await axios.post(apiUrl).catch(error => { console.log(error.response) }); if (result.status === 200) { window.location = result.data.paymentUrl } else { alert('You have already started this payment. Please continue the payment or start from order again.') } } return ( //...
//... ) ``` -------------------------------- ### Store purchasing data in Python Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Registers the order details in the database using the NodexOrder model. ```python NodexOrder.create( order_code = data['order_code'], amount = data['amount'], fiat_symbol = data['amount_type'], payment_token = data['token'], order_status = 'initiated', ) ``` -------------------------------- ### Implement Payment Result API in Python Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Minimal implementation of a POST route to handle payment result kickbacks and update the order status in the database. ```python def update_payment_status(order_code, result): order = NodexOrder.select().where(NodexOrder.order_code == order_code).get() # find order by order_code order.order_status = 'settled' if result else 'failed' # update order status order.save() # save order @app.route('/nodex-kickback/payment', methods=['POST']) def nodex_payment_kickback_route(): body = request.json update_payment_status(order_code=body['order_code'], result=body['result']) # save result to database return 'ok' ``` -------------------------------- ### Call Payment Request API in Python Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Generates payment data, creates a SHA-256 verification token, and sends a POST request to the Nodex Pay system. ```python # business clients has to implement new amount = 1 # Price amount_type = 'USD' # Currency of the Price order_code = generateOrderCode() # Unique per api call # automatically generated on the business client management screen authentication_token = os.getenv('NODEX_AUTH_TOKEN') hash_token = os.getenv('NODEX_HASH_TOKEN') # encrypto followin Nodex's manners raw = '{}::{}::{}'.format(order_code, amount, hash_token) verify_token = hashlib.sha256(raw.encode('utf-8')).hexdigest() # call Payment Request API request_obj = { 'identification_token': authentication_token, 'order_code': order_code, 'verify_token': verify_token, 'amount': amount, 'amount_type': amount_type } payment_request_url = os.getenv('NODEX_PAYMENT_REQUEST_URL') r = requests.post(url = payment_request_url, data = request_obj) result = r.json() # returned values payment_url = result['url'] payment_token = result['token'] ``` -------------------------------- ### HTML + JavaScript: Create order and open payment URL Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-frontend-and-integrate-apis.md Use this HTML page with embedded JavaScript to create a payment order via axios POST to `${API_URL}/create-order`. On success, it opens the returned `payment_url` in a new tab. Replace `YOUR_API_URL` with your actual API endpoint. ```html Store
Tshirt

Cotton T-shirt

$0.001

ATC 5050 Everyday Cotton Blend Tee

``` -------------------------------- ### Return Nodex Pay URL in Python Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Returns the payment URL to the client. ```python return { 'payment_url': payment_url } ``` -------------------------------- ### Next.js: Fetch and display order after payment Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-frontend-and-integrate-apis.md Use this Next.js component to fetch order details using the payment_token from the router query and display them. It uses useEffect to call an async function once the router is ready, and shows an alert on error. ```javascript const [order, setOrder] = useState({}) const router = useRouter() const asyncInit = async () => { const order = await callGetOrderByPaymentToken() setOrder(order) } useEffect(() => { if (!router.isReady) return; asyncInit() }, [router.isReady]) const callGetOrderByPaymentToken = async () => { const apiUrl = `${process.env.API_URL_GET_ORDER_BY_PAYMENT_TOKEN}?payment_token=${router.query.payment_token}` const result = await axios.get(apiUrl) if (result.status === 200) { return result.data.order } else { alert('error!') } } //... return ( //... // render "order" state with purchase completed message //... ) ``` -------------------------------- ### Generate Payment URL with Fixed Settlement Amount Source: https://nodex-pay.gitbook.io/docs Use this Python snippet when the business client (integrator) defines the specific payment amount. It requires an authentication token, hash token, and a unique order code to generate a verify token via SHA-256. ```python import requests import hashlib # api-endpoint API_ENDPOINT = "https://testnet.app.nodexpay.com/api/v1/payment/receive" # Authentication Token AUTH_TOKEN = "YOUR AUTHENTICATION TOKEN"; # Hash Token HASH_TOKEN = "YOUR HASH TOKEN"; # Code set by the business client (Integrator) to uniquely identify the payment order_code = "GENERATE UNIQUE CODE AND STORE IT ON YOUR DATABASE" # Set amount and Generate verify token amount_to_be_charged = 10 # this number must be Zero or more raw = '{}::{}::{}'.format(order_code, amount_to_be_charged, HASH_TOKEN) verify_token = hashlib.sha256(raw).hexdigest() # data to be sent to api data = {'identification_token':AUTH_TOKEN, 'order_code':order_code, 'verify_token':verify_token, 'amount':amount_to_be_charged} # sending post request and saving response as response object r = requests.post(url = API_ENDPOINT, data = data) # extracting response text payment_flow_starting_url = r.url print("The URL is:%s"%payment_flow_starting_url) ``` -------------------------------- ### HTML + JavaScript: Fetch and display order after payment Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-frontend-and-integrate-apis.md Use this HTML page with embedded JavaScript to fetch order details using the payment_token from the URL query string and render them in a table. It uses Axios to call the API endpoint and displays product name, order date/time, order code, and status. ```html Store

Your order

PRODUCT NAME DATE TIME ORDERED YOUR ORDER CODE STATUS
``` -------------------------------- ### Store purchasing data in Node.js + DynamoDB Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Saves the order information to a DynamoDB table using the AWS SDK. ```javascript const puttingItem = { order_code: orderCode, /* a value generated at previous section */ amount: amount, amount_type: amountType, payment_token: paymentToken, /* a value returned at previous section */ status: 'initiated', /* anything you want */ } const putParams = { TableName: process.env.DYNAMODB_CUSTOMER_TABLE, Item: puttingItem, } await dynamoDb.put(putParams) ``` -------------------------------- ### Call Payment Request API in Node.js Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Generates payment data, creates a SHA-256 hash, and uses axios to post the request to the Nodex Pay system. ```javascript // business clients has to implement new const amount = 1 /* Price */ const amountType = 'USD' /* Currency of the Price */ const orderCode = generateOrderCode() /* Unique per api call */ // automatically generated on the business client management screen const authenticationToken = process.env.NODEX_AUTH_TOKEN const hashToken = process.env.NODEX_HASH_TOKEN // encrypto followin Nodex's manners const raw = orderCode + '::' + amount + '::' + hashToken const hashHex = crypto.createHash('sha256').update(raw, 'utf8').digest('hex') // call Paument Request API const requestObj = { identification_token: authenticationToken, order_code: orderCode, verify_token: hashHex, amount: amount, amount_type: amountType, } const paymentRequestUrl = process.env.PAYMENT_REQUEST_URL const result = await axios.post(paymentRequestUrl, requestObj).catch((error) => { return error.response }) if (result.status !== 200) { return { statusCode: result.status, body: JSON.stringify(result.data), headers: { 'Content-Type': 'application/json', } } } // returned values const paymentUrl = result.data.url const paymentToken = result.data.tokens ``` -------------------------------- ### POST /api/v1/payment/receive Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-request-api.md Creates a payment request from a Business Client to Nodex Pay. Returns a payment process URL to redirect the payer to. ```APIDOC ## POST /api/v1/payment/receive ### Description Creates a payment request from a Business Client to Nodex Pay. Returns a payment process URL to redirect the payer to. ### Method POST ### Endpoint https://app.nodexpay.com/api/v1/payment/receive ### Parameters #### Request Body - **identification_token** (string) - Required - "Authentication Token" can be obtained from the Business Client Management screen - **order_code** (string) - Required - The value set by the business client to uniquely identify the payment. Limit to 255 single-byte characters. - **verify_token** (string) - Required - The value obtained by hashing the string 'order_code::amount::Hash Token' with SHA256 if amount is not null. In case amount is null, hashing the string 'order_code::::Hash Token' with SHA256. "Hash Token" can be obtained from the Business Client Management screen - **amount** (number, float) - Optional - The amount to be charged by your deposit currency. It is Zero or more. If a currency is specified in amount_type field, the amount in that currency is converted to the amount in the business client receipt token to generate the settlement data. If amount_type is not specified, this value is set as the amount of the business client receipt token. If the payer determines the amount to be paid, this field can be null. When specifying this field, values from 0.000001 to 100000000 can be specified. - **color_theme** (string) - Optional - 'dark' or 'light' - **amount_type** (string) - Optional - "USD", "JPY", "EUR", "AED", "SGD", "HKD", "CAD", "IDR", "PHP", "INR", "KRW". If a currency is specified in this field, the amount field value in this currency is converted to the amount in the business client receipt token to generate the settlement data. If this field value is not specified, the amount field value is set as the amount of the business client receipt token. - **uimode** (string) - Optional - 'switchable'. Set in case that you implement Window widget. - **ext_description** (string) - Optional - Sets the description of ext_reserved. Limit to 100 characters. - **deadline** (int) - Optional - You can specify the expiration date of the payment. To specify an arbitrary expiration date, set this parameter to a value in unixtime format. If this parameter is not specified, the system automatically sets the default value. The default value is set to the date and time one hour after the API request. - **description** (string) - Optional - Set in case you want to show a custom message in payment page. Limit to 100 characters. ### Request Example { "identification_token": "string", "order_code": "string", "verify_token": "string", "amount": 0, "color_theme": "dark", "amount_type": "USD", "uimode": "switchable", "ext_description": "string", "deadline": 0, "description": "string" } ### Response #### Success Response (200) - **url** (string) - Payment process URL on nodexpay.com. The payer is redirected to this URL to make the payment. - **token** (string) - Payment token issued by Nodex. - **ext_reserved** (string) - Reserved field, echoed back if provided. - **ext_description** (string) - Description of ext_reserved, echoed back if provided. #### Response Example { "url": "https://app.nodexpay.com/payment/PAYMENT_TOKEN_ISSUED_BY_NODEX", "token": "PAYMENT_TOKEN_ISSUED_BY_NODEX", "ext_reserved": "", "ext_description": "" } #### Error Response (400) - **status** (string) - HTTP status code. - **data** (object) - Contains errors array with error codes. #### Error Codes - RECEIVED_IDENTIFICATION_TOKEN_EMPTY = 2010 - RECEIVED_IDENTIFICATION_TOKEN_INVALID = 2011 - RECEIVED_ORDER_CODE_EMPTY = 2020 - RECEIVED_ORDER_CODE_DUPLICATE = 2021 - RECEIVED_AMOUNT_INVALID_FORMAT = 2030 - RECEIVED_COLOR_THEME_INVALID_FORMAT = 2050 - RECEIVED_VERIFY_TOKEN_EMPTY = 2060 - RECEIVED_VERIFY_TOKEN_INVALID = 2061 - RECEIVED_INVALID_CALLBACK_URL = 2040 - RECEIVED_INVALID_DEADLINE = 2460 - CONTRACT_PAYMENT_TOKEN_EMPTY = 2070 - CONTRACT_NETWORK_TYPE_EMPTY = 2080 - CONTRACT_NETWORK_TYPE_INVALID_VALUE = 2081 - CONTRACT_ADDRESS_EMPTY = 2090 - RECEIVED_EXT_RESERVED_INVALID = 2101 - RECEIVED_EXT_DESCRIPTION_INVALID = 2102 - PUBLISH_TRANSACTION_DUPLICATE = 2110 - PUBLISH_TRANSACTION_PAYMENT_TOKEN_EMPTY = 2120 - UPDATE_TRANSACTION_PAYMENT_TOKEN_EMPTY = 2130 ``` -------------------------------- ### 200 OK: Payment cancelled successfully Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-cancel-api.md Successful response when the payment has been cancelled. The response body is shown as a placeholder comment. ```json { // Response } ``` -------------------------------- ### Django Model for NodexOrder Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/preparing-your-database.md Provides a Django model definition for tracking payment orders, mapping to the required fields for payment processing. ```python class NodexOrder(BaseModel): id = AutoField() order_code = CharField(unique=True) amount = (max_digits=31, decimal_places=18, default=0.0) fiat_symbol = CharField() payment_token = CharField(unique=True) order_status = CharField() transaction_hash = CharField() ``` -------------------------------- ### POST e.g. yourdomain/apiname Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-result-api.md Receives a kickback sent from the Nodex Pay to the Business Client when payment is finalized. This endpoint is implemented on the business client site side to receive the notification of the payment result. ```APIDOC ## POST e.g. yourdomain/apiname ### Description Receives a kickback sent from the Nodex Pay to the Business Client when payment is finalized. This endpoint is implemented on the business client site side to receive the notification of the payment result. ### Method POST ### Endpoint e.g. yourdomain/apiname ### Parameters #### Request Body - **order_code** (String) - Required - The value set by the business client (Integrator) to uniquely identify the payment transaction when executed Payment Request API - **transaction_code** (String) - Required - The value set by the Nodex Pay to uniquely identify the payment transaction. A 12 character string, separated by hyphens every 4 characters for a total of 14 characters. e.g. A1B2-3CD4-5E6F - **amount** (String) - Required - Amount paid - **symbol** (String) - Required - Business Client deposit crypto symbol i.e.) USDT, USDC, DAI, JPYC - **result** (Boolean) - Required - Success=true, Failed=false - **verify_token** (String) - Required - This value is a hash value used to check whether the Payment Result API parameters have been tampered with. The validity of the parameters can be verified by hashing a string in the following format with SHA256 and checking it against the "verify_token" of this API. OERDER_CODE_IN_THIS_API_PARAMETER::AMOUNT_IN_THIS_API_PARAMETER::YOUR_HASH_TOKEN - **chain_id** (String) - Required - Chain ID of the blockchain where the payer made the payment. See https://chainlist.org/ - **transaction_hash** (String) - Required - Identification code to uniquely identify the transaction issued by the blockchain settled by the payer. ### Request Example { "order_code": "string", "transaction_code": "string", "amount": "string", "symbol": "string", "result": true, "verify_token": "string", "chain_id": "string", "transaction_hash": "string" } ### Response #### Success Response (200) No response body documented. #### Response Example No response example documented. ``` -------------------------------- ### Return Nodex Pay URL in Node.js Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Returns the payment URL as a JSON response. ```javascript return { statusCode: 200, body: JSON.stringify({ paymentUrl: paymentUrl, }) } ``` -------------------------------- ### MySQL DDL for nodex_orders table Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/preparing-your-database.md Defines the structure for the nodex_orders table in MySQL, including fields for order codes, amounts, fiat symbols, payment tokens, status, and transaction hashes. ```sql create table nodex_orders ( order_code char(xx) not null unique, -- You HAVE TO generate per Nodex "Payment Request API" -- Per cart if the business client uses a cart system amount decimal(31,18), -- Amount of this order fiat_symbol char(3) -- Fiat of this amount payment_token unique char(32) not null unique, -- Unique value per payment request api that Nodex returns order_status varchar not null, -- such as [initiated, started, settled, failed] transaction_hash varchar -- tx of payment ); ``` -------------------------------- ### Generate Payment URL with Payer-Determined Amount Source: https://nodex-pay.gitbook.io/docs Use this Python snippet when the payer should decide the settlement amount. The amount field is omitted from the data payload, and the verify token is generated accordingly. ```python import requests import hashlib # api-endpoint API_ENDPOINT = "https://testnet.app.nodexpay.com/api/v1/payment/receive" # Authentication Token AUTH_TOKEN = "YOUR AUTHENTICATION TOKEN"; # Hash Token HASH_TOKEN = "YOUR HASH TOKEN"; # Code set by the business client (Integrator) to uniquely identify the payment order_code = "GENERATE UNIQUE CODE AND STORE IT ON YOUR DATABASE" raw = '{}::::{}'.format(order_code, HASH_TOKEN) verify_token = hashlib.sha256(raw).hexdigest() # data to be sent to api data = {'identification_token':AUTH_TOKEN, 'order_code':order_code, 'verify_token':verify_token} # sending post request and saving response as response object r = requests.post(url = API_ENDPOINT, data = data) # extracting response text payment_flow_starting_url = r.url print("The URL is:%s"%payment_flow_starting_url) ``` -------------------------------- ### Implement Payment Result API in Node.js with DynamoDB Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Handles payment result kickbacks by updating the corresponding order status in a DynamoDB table. ```javascript const { order_code: orderCode, transaction_hash: transactionHash, result, } = JSON.parse(event.body) const params = { TableName: process.env.DYNAMODB_CUSTOMER_TABLE, Key: { order_code: orderCode }, UpdateExpression: 'set #status = :status, #transaction_hash = :transaction_hash', ExpressionAttributeNames: { '#status': 'status', '#transaction_hash': 'transaction_hash' }, ExpressionAttributeValues: { ':status': result ? 'settled' : 'failed', ':transaction_hash': transactionHash }, } // update payment status of the item that created previous section const dynamodb = new AWS.DynamoDB.DocumentClient() await dynamodb.update(params).promise() return { statusCode: 200, body: {}, } ``` -------------------------------- ### Implement Payment Status API in Node.js with DynamoDB Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/implement-apis.md Queries DynamoDB to retrieve order status using a payment token provided in the query string. ```javascript const payment_token = event.queryStringParameters.payment_token const params = { TableName: process.env.DYNAMODB_CUSTOMER_TABLE, ExpressionAttributeNames: { '#payment_token': 'payment_token', }, ExpressionAttributeValues: { ':payment_token': payment_token, }, KeyConditionExpression: '#payment_token = :payment_token', IndexName: 'payment-token', } const dynamodb = new AWS.DynamoDB.DocumentClient() const result = await dynamodb.query(params).promise() if (!result) { return { statusCode: 404, } } return { statusCode: 200, body: JSON.stringify({ order: result }), } ``` -------------------------------- ### Amazon DynamoDB Table Definition Source: https://nodex-pay.gitbook.io/docs/integration-guide/integration-guide/preparing-your-database.md Configures an Amazon DynamoDB table using the Serverless Framework, including attribute definitions and a global secondary index for the payment token. ```yaml #In case that you use Amazon DynamoDB via Serverless Frameworktable definitions in serverless.yaml is like follows. orderTable: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: order_code AttributeType: S - AttributeName: payment_token AttributeType: S BillingMode: PAY_PER_REQUEST KeySchema: - AttributeName: order_code KeyType: HASH GlobalSecondaryIndexes: - IndexName: payment-token KeySchema: - AttributeName: payment_token KeyType: HASH Projection: ProjectionType: 'ALL' TableName: ${self:service}-orderTable-${sls:stage} ``` -------------------------------- ### 400: Bad Request error codes Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-request-api.md Error response format for a 400 Bad Request. The first block shows the JSON structure with an error number placeholder. The second block lists the possible error codes and their numeric values. ```plaintext { "status": "400", "data: { errors: [ The following ERROR NUMBER ] } ``` ```plaintext RECEIVED_IDENTIFICATION_TOKEN_EMPTY = 2010; RECEIVED_IDENTIFICATION_TOKEN_INVALID = 2011; RECEIVED_ORDER_CODE_EMPTY = 2020; RECEIVED_ORDER_CODE_DUPLICATE = 2021; RECEIVED_AMOUNT_INVALID_FORMAT = 2030; RECEIVED_COLOR_THEME_INVALID_FORMAT = 2050; RECEIVED_VERIFY_TOKEN_EMPTY = 2060; RECEIVED_VERIFY_TOKEN_INVALID = 2061; RECEIVED_INVALID_CALLBACK_URL = 2040; RECEIVED_INVALID_DEADLINE = 2460; CONTRACT_PAYMENT_TOKEN_EMPTY = 2070; CONTRACT_NETWORK_TYPE_EMPTY = 2080; CONTRACT_NETWORK_TYPE_INVALID_VALUE = 2081; CONTRACT_ADDRESS_EMPTY = 2090; RECEIVED_EXT_RESERVED_INVALID = 2101; RECEIVED_EXT_DESCRIPTION_INVALID = 2102; PUBLISH_TRANSACTION_DUPLICATE = 2110; PUBLISH_TRANSACTION_PAYMENT_TOKEN_EMPTY = 2120; UPDATE_TRANSACTION_PAYMENT_TOKEN_EMPTY = 2130; ``` -------------------------------- ### POST /api/v1/payment/cancel Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-cancel-api.md Cancels an unpaid payment using the provided identification token, order code, and verify token. ```APIDOC ## POST /api/v1/payment/cancel ### Description Cancels an unpaid payment. The payment cannot be cancelled if there is a blockchain transaction associated with it, in which case an error with code 2024 is returned. ### Method POST ### Endpoint https://app.nodexpay.com/api/v1/payment/cancel ### Parameters #### Request Body - **identification_token** (String) - Required - Authentication Token obtained from the Business Client Management screen. - **order_code** (String) - Required - The value set by the business client to uniquely identify the payment. - **verify_token** (String) - Required - The value obtained by hashing the string 'order_code::amount::Hash Token' with SHA256 if amount is not null. In case amount is null, hashing the string 'order_code::::Hash Token' with SHA256. "Hash Token" can be obtained from the Business Client Management screen. ### Response #### Success Response (200) Payment has successfully been cancelled. #### Response Example ```json { // Response } ``` #### Error Response (400) Bad Request. The response contains an errors array with one of the following error numbers: - RECEIVED_IDENTIFICATION_TOKEN_EMPTY = 2010 - RECEIVED_ORDER_CODE_EMPTY = 2020 - RECEIVED_ORDER_CODE_ALREADY_CANCELLED = 2022 - PAYMENT_NOT_FOUND = 2023 - PAYMENT_NOT_CANCELABLE = 2024 - RECEIVED_VERIFY_TOKEN_EMPTY = 2060 - RECEIVED_VERIFY_TOKEN_INVALID = 2061 #### Error Response Example ```json { errors: [ The following ERROR NUMBER ] } ``` #### Service Unavailable (503) Service Unavailable. The response contains a message indicating maintenance. #### Service Unavailable Example ```javascript { "Currently under maintenance. Please wait for a while until it is restored." } ``` ``` -------------------------------- ### 400 Bad Request: Error response and error codes Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-cancel-api.md Error response format for a 400 Bad Request. The error body contains an errors array with the corresponding error number. The listed error codes include RECEIVED_IDENTIFICATION_TOKEN_EMPTY (2010), RECEIVED_ORDER_CODE_EMPTY (2020), RECEIVED_ORDER_CODE_ALREADY_CANCELLED (2022), PAYMENT_NOT_FOUND (2023), PAYMENT_NOT_CANCELABLE (2024), RECEIVED_VERIFY_TOKEN_EMPTY (2060), and RECEIVED_VERIFY_TOKEN_INVALID (2061). ```json { errors: [ The following ERROR NUMBER ] } ``` ```text RECEIVED_IDENTIFICATION_TOKEN_EMPTY = 2010 RECEIVED_ORDER_CODE_EMPTY = 2020 RECEIVED_ORDER_CODE_ALREADY_CANCELLED = 2022 PAYMENT_NOT_FOUND = 2023 PAYMENT_NOT_CANCELABLE = 2024 RECEIVED_VERIFY_TOKEN_EMPTY = 2060 RECEIVED_VERIFY_TOKEN_INVALID = 2061 ``` -------------------------------- ### 503 Service Unavailable: Maintenance response Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-cancel-api.md Response when the service is unavailable (503). The body indicates the service is under maintenance and asks to wait until it is restored. ```json { "Currently under maintenance. Please wait for a while until it is restored." } ``` -------------------------------- ### Payment Request API Error Codes Source: https://nodex-pay.gitbook.io/docs/integration-guide/apis/payment-request-api.md List of error codes for the payment request API, each with a unique numeric identifier. Use these codes to identify specific error conditions returned by the API. ```javascript UPDATE_TRANSACTION_EMAIL_INVALID_FORMAT = 2140; UPDATE_TRANSACTION_EXCHANGED_AMOUNT_INVALID_FORMAT = 2150; UPDATE_TRANSACTION_BASE_CURRENCY_UNMATCH = 2160; UPDATE_TRANSACTION_BASE_AMOUNT_INVALID_FORMAT = 2170; UPDATE_TRANSACTION_RATE_INVALID_FORMAT = 2180; UPDATE_TRANSACTION_MARGIN_RATE_INVALID_FORMAT = 2190; UPDATE_TRANSACTION_NETWORK_TYPE_INVALID_FORMAT = 2210; UPDATE_TRANSACTION_CONTRACT_ADDRESS_INVALID_FORMAT = 2220; UPDATE_TRANSACTION_WALLET_ADDRESS_INVALID_FORMAT = 2230; UPDATE_TRANSACTION_PAY_SYMBOL_INVALID_FORMAT = 2240; UPDATE_TRANSACTION_PAY_AMOUNT_INVALID_FORMAT = 2250; UPDATE_TRANSACTION_TRANSACTION_ADDRESS_INVALID_FORMAT = 2260; UPDATE_TRANSACTION_TARGET_NOT_EXIST = 2270; UPDATE_TRANSACTION_COMBINATION_INVALID = 2280; UPDATE_TRANSACTION_TARGET_STATE_MISMATCH = 2290; PAYMENT_TRANSACTION_UPDATE_PAYMENT_TOKEN_EMPTY = 2310; GET_PAYMENT_RECEIVE_INFO_PAYMENT_TOKEN_EMPTY = 2320; GET_EXCHANGE_RATE_PAYMENT_TOKEN_EMPTY = 2330; GET_EXCHANGE_RATE_EXCHANGE_SETTING_INVALID = 2331; GET_EXCHANGE_RATE_LEGAL_CURRENCY_EMPTY = 2340; GET_EXCHANGE_RATE_LEGAL_CURRENCY_INVALID = 2341; GET_EXCHANGE_RATE_AMOUNT_INVALID = 2350; GET_PAYMENT_COMPLETED_URL_SETTING_INVALID_PAYMENT_TOKEN = 2360; RECEIVE_CONTRACT_UNPUBLISHED = 2370; GET_PAYMENT_AVAILABLE_NETWORK_PAYMENT_TOKEN_INVALID = 2380; GET_PAYMENT_NORMAL_TRANSACTION_PAYMENT_TOKEN_INVALID = 2390; GET_PAYMENT_NORMAL_TRANSACTION_UNPUBLISHED = 2410; GET_GENERATED_DONATION_ORDER_CODE_IDENTIFICATION_TOKEN_EMPTY = 2420; GET_GENERATED_DONATION_ORDER_CODE_DONATION_FOR_INVALID_FORMAT = 2430; GET_MERCHANT_CONTRACT_STATUS_PAYMEMT_TOKEN_NOT_VALID = 2431; REFRESH_PAYMENT_TOKEN_DATA_NOT_EXIST = 2440; GET_NORMAL_TRANSACTION_DEVICE_MATCH_STATUS_DEVICE_ID_INVALID_FORMAT = 2450; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.