Table of Contents
How Does It Work?
a) Establish a Connection
This is self-explanatory. Connect to the URL of the API server.
let sUrl = 'https://testlink.c9pg.com:11911/restApi'; // test server
nConn = PgcNewConn(sUrl, 'Browser1', '');
b) Create a Session
Session is a wrapper for transactions. You can have a single transaction per Session (default) or many. Session is what gets sent to the API server.
nSess = PgcNewSess(nConn, 1);
c) Set Request Parameters
//Set Merchant Account Info (Merchant ID, Terminal ID, Password)
//This is a test account preconfigured for you
PgcSetStr(nSess, 0, "GMID", '1001396250');
PgcSetStr(nSess, 0, "GTID", 'GT1001396253');
PgcSetStr(nSess, 0, "GMPW", '123');
//Set Operation Type (SALE|REFUND|etc)
PgcSetStr(nSess, 0, "TransType" , "Sale");
//Set Transaction Type (CREDIT CARD)
PgcSetStr(nSess, 0, "Medium", "Credit");
// Set Transaction Info (ACCOUNT_NUM, EXP_DATE, AMOUNT, REF#)
PgcSetStr(nSess, 0, "AccountNum", "4111111111111111");
PgcSetStr(nSess, 0, "ExpDate", "0828");
d) Send the Session. No need to close it (autoclose is by default)
let nErr = PgcRequest(nSess, onReply);
e) Read the Response
let sStatus = PgcGetStr(nCbkSess, 0, "Status");
let sRespCode = PgcGetStr(nCbkSess, 0, "ResponseCode");
let sRespText = PgcGetStr(nCbkSess, 0, "ResponseText");
let sRespTransID = PgcGetStr(nCbkSess, 0, "GTRC"); // Gateway Tracking ID
You can see our full API below if you want to know what other parameters and values are available
You will be using a TSYS test server. For successful transactions, you will need to use specific test card numbers, amounts, CVV, AVS, etc.
IMPORTANT: please, see TSYS Test Account for complete information on getting successful authorizations with our test sandbox. You will receive errors if you use the wrong parameters.
As a quick guide, you can use real card numbers (they will not be charged or used), $1.00 amounts and 999 CVV.
C9 OpenAPI Introduction
We are proud to present to you our C9 API in the OpenAPI format (Swagger). This is a documentation suite combined with a testing sandbox, which allows you to play with live samples while learning how the API works. Full schema and examples are included.
- Schema, which is just a list of parameter names and their values. You can see those in the sample source code. They have names, such “Sale” or “GMID”, which stands for Gateway Merchant ID
- Examples. which show you sample ways of using the Schema
- Try It, which is a way to run the JSON payload against the API server