Node.js / GP-API Collection / TRA_9.0 Transaction returns Batch ID
Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "account_name": "{{acc_name}}",
// "channel": "CP",
// "type": "SALE",
// "capture_mode": "AUTO",
// "amount": "15",
// "currency": "USD",
// "reference": "25482851",
// "country": "US",
// "payment_method": {
// "entry_mode": "MANUAL",
// "card": {
// "number": "4012001037141112",
// "expiry_month": "12",
// "expiry_year": "25",
// "cvv": "456"
// }
// }
// }
var json = new chilkat.JsonObject();
json.UpdateString("account_name","{{acc_name}}");
json.UpdateString("channel","CP");
json.UpdateString("type","SALE");
json.UpdateString("capture_mode","AUTO");
json.UpdateString("amount","15");
json.UpdateString("currency","USD");
json.UpdateString("reference","25482851");
json.UpdateString("country","US");
json.UpdateString("payment_method.entry_mode","MANUAL");
json.UpdateString("payment_method.card.number","4012001037141112");
json.UpdateString("payment_method.card.expiry_month","12");
json.UpdateString("payment_method.card.expiry_year","25");
json.UpdateString("payment_method.card.cvv","456");
http.SetRequestHeader("Content-Type","application/json");
http.SetRequestHeader("X-GP-Version","2020-12-22");
// Adds the "Authorization: Bearer {{token}}" header.
http.AuthToken = "{{token}}";
http.SetRequestHeader("Accept","application/json");
// resp: HttpResponse
var resp = http.PostJson3("https://apis.sandbox.globalpay.com/ucp/transactions","application/json",json);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
console.log(resp.StatusCode);
console.log(resp.BodyStr);
}
chilkatExample();
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer {{token}}"
-H "Accept: application/json"
-H "X-GP-Version: 2020-12-22"
-d '{
"account_name": "{{acc_name}}",
"channel": "CP",
"type": "SALE",
"capture_mode": "AUTO",
"amount": "15",
"currency": "USD",
"reference": "25482851",
"country":"US",
"payment_method": {
"entry_mode" : "MANUAL",
"card": {
"number": "4012001037141112",
"expiry_month": "12",
"expiry_year": "25",
"cvv": "456"
}
}
}'
https://apis.sandbox.globalpay.com/ucp/transactions
Postman Collection Item JSON
{
"name": "TRA_9.0 Transaction returns Batch ID",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "Bearer {{token}}"
},
{
"key": "Accept",
"value": "application/json"
},
{
"key": "X-GP-Version",
"value": "2020-12-22"
}
],
"body": {
"mode": "raw",
"raw": "\n{\n \"account_name\": \"{{acc_name}}\",\n \"channel\": \"CP\",\n \"type\": \"SALE\",\n \"capture_mode\": \"AUTO\",\n \"amount\": \"15\",\n \"currency\": \"USD\",\n \"reference\": \"25482851\",\n \"country\":\"US\",\n \"payment_method\": {\n \n \"entry_mode\" : \"MANUAL\",\n \"card\": {\n \"number\": \"4012001037141112\",\n \"expiry_month\": \"12\",\n \"expiry_year\": \"25\",\n \"cvv\": \"456\"\n }\n }\n}\n"
},
"url": {
"raw": "https://apis.sandbox.globalpay.com/ucp/transactions",
"protocol": "https",
"host": [
"apis",
"sandbox",
"globalpay",
"com"
],
"path": [
"ucp",
"transactions"
]
},
"description": "This request creates a transaction that returns a batch id."
},
"response": [
]
}