a a

Transaction API Call

ENDPOINT
https://api-test.surchx.com/v1/ch

For testing purpose, please use the Test Cards

HEADERS
    Content-Type : application/json
    X-Requested-With : xhr
    Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3Mjc2MDAsImlhdCI6MTU2NjUwMDMxOCwibmFtZSI6IkhVR08gRE9DUyAtKERPTlQgREVMRVRFKSIsImlkIjoiNjVlZmJiMjMtNGY4Zi00M2ZjLTk1MDQtODk4YThjZWQzNWNkIn0.ehlu051arjjraE8E5PP8WBM_YBfS2r4CPoS_V_D8hog
REQUEST BODY
For subsequent calls : Either mTxId/sTxId is mandatory.
{
    "campaign": [
        "Testing"
    ],
     "country":"840",
       "region":"85004",
       "processor":"standard",
       "nicn":"424242",
       "amount":100
    
}

curl    --location --request POST "https://api-test.surchx.com/v1/ch" \
        --header "Content-Type: application/json" \
        --header "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3Mjc2MDAsImlhdCI6MTU2NjUwMDMxOCwibmFtZSI6IkhVR08gRE9DUyAtKERPTlQgREVMRVRFKSIsImlkIjoiNjVlZmJiMjMtNGY4Zi00M2ZjLTk1MDQtODk4YThjZWQzNWNkIn0.ehlu051arjjraE8E5PP8WBM_YBfS2r4CPoS_V_D8hog" \

        --data "{
            "campaign": ["test"],
             "country":"840",
             "region":"85004",
             "processor":"standard",
             "nicn":"424242",
             "amount":100
        }"

var https = require('https');

var options = {
    'method': 'POST',
    'hostname': 'api-test.surchx.com',
    'path': '/v1/ch',
    'headers': {
        'Content-Type': 'application/json',
        'X-Requested-With': 'xhr'
    }
};

var req = https.request(options, function (res) {
    var chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

var postData =  "{
                    "campaign": ["test"],
                    "country":"840",
                    "region":"85004",
                    "processor":"standard",
                    "nicn":"424242",
                    "amount":100
                }";

req.write(postData);

req.end();

var settings = {
    "url": "https://api-test.surchx.com/v1/ch",
    "method": "POST",
    "timeout": 0,
    "headers": {
        "Content-Type": "application/json",
        "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3Mjc2MDAsImlhdCI6MTU2NjUwMDMxOCwibmFtZSI6IkhVR08gRE9DUyAtKERPTlQgREVMRVRFKSIsImlkIjoiNjVlZmJiMjMtNGY4Zi00M2ZjLTk1MDQtODk4YThjZWQzNWNkIn0.ehlu051arjjraE8E5PP8WBM_YBfS2r4CPoS_V_D8hog"
    },
    "data": "{
                "campaign": ["test"],
                "country": "840",
                 "region":"85004",
                 "processor":"standard",
                 "nicn":"424242",
                 "amount":100
            }";

$.ajax(settings).done(function (response) {
    console.log(response);
});

require "uri"
require "net/http"

url = URI("https://api-test.surchx.com/v1/ch")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3Mjc2MDAsImlhdCI6MTU2NjUwMDMxOCwibmFtZSI6IkhVR08gRE9DUyAtKERPTlQgREVMRVRFKSIsImlkIjoiNjVlZmJiMjMtNGY4Zi00M2ZjLTk1MDQtODk4YThjZWQzNWNkIn0.ehlu051arjjraE8E5PP8WBM_YBfS2r4CPoS_V_D8hog"

request.body =  "{
                    "campaign": ["test"],
                    "country": "840",
                    "region": "85004",
                    "processor": "standard",
                    "nicn": "424242",
                    "amount": 100
                }"

response = https.request(request)
puts response.read_body

import requests
url = 'https://api-test.surchx.com/v1/ch'
payload =   "{
                "campaign": ["test"],
                "country": "840",
                "region": "85004",
                "processor": "standard",
                "nicn": "424242",
                "amount": 100
            }"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3Mjc2MDAsImlhdCI6MTU2NjUwMDMxOCwibmFtZSI6IkhVR08gRE9DUyAtKERPTlQgREVMRVRFKSIsImlkIjoiNjVlZmJiMjMtNGY4Zi00M2ZjLTk1MDQtODk4YThjZWQzNWNkIn0.ehlu051arjjraE8E5PP8WBM_YBfS2r4CPoS_V_D8hog'
}
response =  requests.request('POST', url, headers = headers, data = payload, allow_redirects=False,
                timeout=undefined, allow_redirects=false)
print(response.text)

<?php
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-test.surchx.com/v1/ch",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS =>   "{
                                "campaign": ["test"],
                                "country": "840",
                                "region": "85004",
                                "processor": "standard",
                                "nicn": "424242",
                                "amount": 100
                            }",
    CURLOPT_HTTPHEADER => array(
        "Content-Type: application/json",
        "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NzE3Mjc2MDAsImlhdCI6MTU2NjUwMDMxOCwibmFtZSI6IkhVR08gRE9DUyAtKERPTlQgREVMRVRFKSIsImlkIjoiNjVlZmJiMjMtNGY4Zi00M2ZjLTk1MDQtODk4YThjZWQzNWNkIn0.ehlu051arjjraE8E5PP8WBM_YBfS2r4CPoS_V_D8hog"
    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}
?>

package main

import (
    "fmt"
    "strings"
    "os"
    "path/filepath"
    "net/http"
    "io/ioutil"
)

func main() {

url := "https://api-test.surchx.com/v1/ch"
method := "POST"

payload := strings.NewReader("{
    "campaign": ["test"],
    "country": "840",
    "region": "85004",
    "processor": "standard",
    "nicn": "424242",
    "amount": 100
}")

client := &http.Client {
    CheckRedirect: func(req *http.Request, via []*http.Request) error {
        return http.ErrUseLastResponse
    },
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
    fmt.Println(err)
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("X-Requested-With", "xhr")

res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)

fmt.Println(string(body))
}

RESPONSE
{
    "transactionFee": 3.75,
    "sTxId": "47k17y158esu5yz158exfq22o",
    "message": "ok"
}

JSON payload including all fields (for syntax)
{
    "amount": 10.00,
    "totalAmount": 100.00,
    "campaign": [ "fall2020" ],
    "country": "840",
    "nicn": "411111",
    "processor": "standard",
    "mTxId": "e6a47e63-628e-415b-8d0a-2a4c87e8f0c4",
    "sTxId": "47k17y158esu5yz158exfq22o",
    "region": "CA"
}

Nomenclature
NameInformationMandatory
AmountTransaction amount in US dollars.Yes
TotalAmountThe transaction total US dollars. Applicable when using multi-pay.Yes - when using multipay
CampaignThis is opaque data that is available for further data analytics and is also used during A/B Test-Implementation phases.
CountryThis is an optional field and will default to 840/US. The ISO Numerical Country Code. See for Reference .
NICN (Non-Identifiable Card Number)The first 6-8 digits of credit card number. SurchX never handles more than 12 digits and therefore is not in conflict with PCI requirements or guidelines.Yes
ProcessorThe MID or Name value of the processor to use for calculating Transaction Fees. This field is optional when the Merchant has only one configured processor. In that case the single, configured processor is used.Yes
cardTokenA credit card tokenization key to be associated with this transaction and reused later by calling /recur/surcharge.
Transaction FeeSurchX generated fee for making a credit card transaction (sent in response from API).
mTxIdA Merchant orderId or unique identifier in the Merchant e-commerce scope referencing the Order or Shopping Cart. This field is optional. If the mTxId is not known until the "capture" sequence, it may be passed at that time..
sTxIdIt is a unique identifier in the SurchX system which refers to the persistence state of the Transaction Fee calculation.
RegionZip code, two letter state abbreviation, or the ISO State Code. See for Reference.Yes