API Documentation

Our set of API allows you to integrate our services, manage organisations, users in a simple and programmatic way, using conventional HTTP requests. The endpoints are intuitive and powerful, allowing you to easily make calls to retrieve information or to execute actions.

The API documentation will start with a general overview about the design and technology that has been implemented, followed by reference information about specific endpoints.

Types of integration

  1. Service Redirect
    • This method requires minimal development time as most of the logic is hosted on our service page you are redirecting to.
    • This method will still require the setup of a auth token before redirecting.
    • Services that supports redirect: Agent Assist, Agent Monitor and Agent Request.
  2. Service Enterprise
    • Most of the API's are straight forward REST.
    • Some services like ASSIST/MONITOR/REQUEST are event driven. This will require you to setup Websocket event listeners using the WAMP2 protocol. You can use a cross platform library like Autobahn to connect to our endpoint.
    • This type of integration requires you to setup your own UI logic.
    • Services that supports enterprise integration: Agent Assist, Agent Monitor, Agent Request, Express and POS.
  3. Webhooks
    • Used for recon.
    • Will send you related information right after a transaction is completed.
    • Configurable under Settings→Integration in the admin console.
    • Response log can be viewed here: Webhook Logs
    • Important Notice: Webhooks will exclusively originate from the following two IP addresses. It is important to whitelist them:
    • 54.72.191.28
    • 54.194.139.201

Webhook payload example

In settings you can configure your success, refund and error webhook urls. The result will be sent as an HTTP POST request in the following format:

We do not have static IPs to whitelist and we recommend doing lookup api calls:
Payments: /api/v1/gateway-transaction/$GATEWAY_TRANSACTION_ID
Payouts: /api/v1/payout/100/$PAYOUT_TRANSACTION_ID

Webhook success/error sample post request

                
                POST = [
                    'success' => {1 or 0}
                    'status' => {statusString}
                    'organisation_id' => {merchant_id}
                    'amount' => {amount}
                    'callpay_transaction_id' => {gateway_transaction_id}
                    'reason' => ‘{reasonForFailureIfApplicable}’
                    'user' => ‘{paymentUser}’
                    'merchant_reference' => ‘{merchant_reference}’
                    'gateway_reference' => ‘{psp_reference}'
                    'gateway_response' => ‘{additionalDataFromPSP}’
                    'currency' => ‘{currency}’
                    'payment_key' => ‘{payment_key}’
                ]
                
            

Refund webhook url post request differs slightly, refunded_amount set instead of amount

                
                POST = [
                    'success' => {1 or 0}
                    'organisation_id' => {merchant_id}
                    'refunded_amount' => {amountRefunded}
                    'callpay_transaction_id' => {gateway_transaction_id}
                    'reason' => ‘{reasonForFailureIfApplicable}’
                    'user' => ‘{paymentUser}’
                    'merchant_reference' => ‘{merchant_reference}’
                    'gateway_reference' => ‘{psp_reference}'
                    'currency' => ‘{currency}’
                    'payment_key' => ‘{payment_key}’
                    'gateway_response' => ‘{additionalDataFromPSP}’
                ]
                
            

Payment Method Types


This document is filtered by services & Payment Method types assigned for: Credit Card Test Merchant
Your account currently has the following Payment Methods activated:
Payment Methods Integration methods Activated
Agent Assist
A call center service for taking payment details while on call.
Redirect & Enterprise No
Agent Monitor
A call center service for taking payment details by forwarding the customer on the call to an IVR
Redirect & Enterprise No
Agent Request
A call center service for taking payment details over network initiated USSD.
Enterprise No
Credit Card Payments
A website or mobile service for accepting credit card payments via a redirect.
Checkout & Redirect & Enterprise Yes
EFTsecure
A website or mobile service for accepting instant EFT
Checkout & Redirect & Enterprise Yes
Notify Express (Pay by Link)
A notification service for Pay Direct and EFTsecure. Email, SMS and Link supported.
Enterprise Yes
Snapscan
Accept Snapscan payments by scanning a QR Code as an option through the checkout widget.
Checkout & Redirect No
Zapper
Accept Zapper payments by scanning a QR Code as an option through the checkout widget.
Checkout & Redirect No
OTT-Voucher
Accept Voucher payments as an option through the checkout widget.
Checkout & Redirect No
1Voucher
Accept Voucher payments as an option through the checkout widget.
Checkout & Redirect No
BluVoucher
Accept Voucher payments as an option through the checkout widget.
Checkout & Redirect No
EasyPay Voucher (Kazang Voucher)
Accept Voucher payments as an option through the checkout widget.
Checkout & Redirect No
Masterpass
Accept payments by scanning a QR code using any Masterpass app.
Checkout & Redirect No
Mobicred
Accept payments through a Micro loans provider, as and option from the checkout widget.
Checkout & Redirect No
Fasta
Accept payments through a Micro loans provider, as and option from the checkout widget.
Checkout & Redirect No
Epos
Accept data payloads for validation.
No
Chinapay
Checkout & Redirect No
Pay just Now
Accept payments through a Micro loans provider, as and option from the checkout widget.
Checkout & Redirect No
Payflex
Accept payments through a Micro loans provider, as and option from the checkout widget.
Checkout & Redirect No
Crypto
Accept Crypto payments as an option through the checkout widget.
Checkout & Redirect No
Vfd
Accept Vfd payments as an option through the checkout widget.
Checkout & Redirect No
Shop 2 Shop Voucher
Accept Voucher payments as an option through the checkout widget.
Checkout & Redirect No
Capitec Pay
Accept Capitec Pay payments as an option through the checkout widget.
Checkout & Redirect No
Fivewest
Accept Fivewest payments as an option through the checkout widget.
Checkout & Redirect No
Capitec EFT
Accept Capitec EFT payments as an option through the checkout widget.
Checkout & Redirect No
RealPay Capitec Pay
Accept RealPay Capitec Pay payments as an option through the checkout widget.
Checkout & Redirect No

Requests

Any tool that is fluent in HTTP can communicate with the API simply by requesting the correct URI. Requests should be made using the HTTPS protocol so that traffic is encrypted. The interface responds to different methods depending on the action required.

Method Usage
GET

For simple retrieval of information you should use the GET method. The information you request will be returned to you as a JSON object.

DELETE

To destroy a resource and remove it from your account and environment, the DELETE method should be used.

PUT

To update the information about a resource in your account, the PUT method is available.

POST

To create a new object, your request should specify the POST method.

The POST request includes all of the attributes necessary to create a new object. When you wish to create a new object, send a POST request to the target endpoint.

HTTP Statuses

Along with the HTTP methods that the API responds to, it will also return standard HTTP statuses, including error codes.

In the event of a problem, the status will contain the error code, while the body of the response will usually contain additional information about the problem that was encountered.

In general, if the status returned is in the 200 range, it indicates that the request was fulfilled successfully and that no error was encountered.

Return codes in the 400 range typically indicate that there was an issue with the request that was sent. Among other things, this could mean that you did not authenticate correctly, that you are requesting an action that you do not have authorization for, that the object you are requesting does not exist, or that your request is malformed.

If you receive a status in the 500 range, this generally indicates a server-side problem. This means that we are having an issue on our end and cannot fulfill your request currently.

HTTP status example

RESPONSE


{
    "name": "Unauthorized",
    "message": "",
    "code": 0,
    "status": 401,
    "type": "yii\\web\\UnauthorizedHttpException"
}

Responses

When a request is successful, a response body will typically be sent back in the form of a JSON object.

For example, if you send a GET request to /api/v1/user/$USER_ID you will get back an object for that user. If you send the GET request /api/v1/organisation/$ORGANISATION_ID/user you will get back an array of objects.

Examples

Single Object


{
    "id": 1,
    "name": "John",
    ...
}

Object Collection


[
    {
        "id": 1,
        "name": "John",
        ...
    },
    {
        "id": 2,
        "name": "Joe",
        ...
    },
    {
        "id": 3,
        "name": "Jane",
        ...
    }
]

Authentication API V1 (Basic Auth)

A token must be sent in the headers of a request for authentication

A token can be created for a user by making an API call with basic authentication (a valid user's username and password must be sent as credentials) to following URL:

Keep in mind that Agent users are limited to service api calls that they are authorised to use.

Fetch token example

Request

curl -X POST  -u validusername:validpassword https://gateway.switch.tj/api/v1/token 

Response


{
    "token": "b5cfaae0e94e79d0073f4925143dca2c",
    "expires": "2016-09-07 08:46:16"
}
                

Constants

Some of these constants are required for certain API calls.

Available Service IDs

These are the service IDs available to your organisation.

ID Service
11 Notify Express
12 EftX
13 Direct
16 Pay per token

Available Gateway IDs

List of available gateways

ID Gateway
28 Imbeko

User roles

List of available user roles Post with string value
eg. User[role] = 'agent'

Role Description
administrator User that can manage the organisation and users
agent Call centre agent that uses our services

Using services

Allows agents and apps to make use of our services through the API.

Create Credit Card Token

Create Credit Card Token for user if organisation enabled gateway supports tokenization.
NB* This can only be done once credit card, expiry date and cvv have been posted by customer via agent assist or request

For authentication use BasicAuth with the current agent's username and password to ensure correct credit card details are tokenized.

Request Method: POST

Url: https://gateway.switch.tj/api/v1/customer-token

Post parameters:

Attribute Type Description Required
merchant_reference string A unique reference number to match against token Yes

Example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/customer-token -d "merchant_reference=reference3"

Response


{
    "merchant_reference": "reference3",
    "token": "ec8bb02b-1f64-403a-b18b-fe6568de77ca,2FCC5339-2783-4148-BC6A-F5A981E493A8",
    "guid": "4a7c851d-9400-4c67-bc48-b45419dd2582",
    "expiry_date": "05-2023"
}
        

Create Credit Card Token directly through API

Create Credit Card Token for user if organisation enabled gateway supports tokenization.
With this API call you submit all the PAN details

Request Method: POST

Url: https://gateway.switch.tj/api/v1/customer-token/direct

Post parameters:

Attribute Type Description Required
merchant_reference string A unique reference number to match against token Yes
pan number Credit card number Yes
expiry string {m}{y} ie 1220 yes
cvv number 3 to 5 digits yes

Example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/customer-token/direct -d "merchant_reference=reference_test&pan=4242424242424242&expiry=1223&cvv=123"

Response


{
"merchant_reference": "reference_test",
"token": "ec8bb02b-1f64-403a-b18b-fe6568de77ca,2FCC5339-2783-4148-BC6A-F5A981E493A8",
"guid": "4a7c851d-9400-4c67-bc48-b45419dd2582",
"expiry_date": "12-2023"
}
    

Credit Card Enquiry

Check status of Credit Card if supported by gateway eg. Hot Card, Fraud etc.

Request Method: POST

Url: https://gateway.switch.tj/api/v1/card-enquiry

Post parameters:

Attribute Type Description Required
pan number Credit card number Yes
expiry string {m}{y} ie 1220 yes
cvv number 3 to 5 digits yes

Example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/card-enquiry -d "pan=4242424242424242&expiry=1223&cvv=123" 

Response


{
    "card_valid":false,
    "message":"Card type not accepted (Test Card Number used)"
}

View Credit Card Token

Fetch Credit Card token using unique merchant reference.

For authentication use BasicAuth with agent's username and password.

Request Method: GET

Url: https://gateway.switch.tj/api/v1/customer-token/$MERCHANT_REFERENCE

Returned attributes::

Attribute Type Description
merchant_reference string Unique reference number
token string Unique customer token
guid string Unique token guid
expiry_date Date (eg. 06-2019) The token expiry date
pan string Masked out card number
card_bin string Bank Identification Number

Example

cURL Request

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/customer-token/reference3 

Response


{
    "merchant_reference": "reference3",
    "token": "ec8bb02b-1f64-403a-b18b-fe6568de77ca,2FCC5339-2783-4148-BC6A-F5A981E493A8",
    "guid": "4a7c851d-9400-4c67-bc48-b45419dd2582",
    "expiry_date": "05-2019",
    "pan": "4242********4242",
    "card_bin": "424242"
}
        

Delete Credit Card Token

Delete Credit Card Token using unique merchant reference.

For authentication use BasicAuth with agent's username and password.

Request Method: DELETE

Url: https://gateway.switch.tj/api/v1/customer-token/$MERCHANT_REFERENCE

Returned attributes::

Attribute Type Description
success boolean Boolean value confirming success/failure if request
message string Message confirming success/failure if request

Example

cURL Request

curl -X DELETE -u validusername:validpassword https://gateway.switch.tj/api/v1/customer-token/reference3 

Response


{
    "success": "true",
    "message": "Card token deleted for reference/guid reference3"
}
        

Credit Card Token Payments

Accepts the unique card token guid to process a real-time payment after tokenising card details. See Service Redirect.

Note: Performance of this call is directly affected by Payment Service Provider response times.

Request Method: POST

Url: https://gateway.switch.tj/api/v1/customer-token/{token_guid}/pay

Post parameters:

Attribute Type Description Required
amount float Amount to be paid Yes
reference string(32) Unique payment reference Yes

Example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/customer-token/4a7c851d-9400-4c67-bc48-b45419dd2582/pay -d "amount=10.00&reference=SomePaymentRef123" 

Response


{
  "success": 1,
  "amount": "10.00",
  "reason": "n/a",
  "callpay_transaction_id": 12345,
  "organisation_id": 54321,
  "user": "n/a",
  "merchant_reference": "SomePaymentRef123",
  "gateway_reference": "12345APPROVED",
  "gateway_response": {
	//Dynamic sub response from PSP
  }}
        

Create Payment schedule

Schedule payment dates for a customer Credit Card token, multiple payment schedules can be posted as an array. Each payment schedule must have an interval, amount, start_date, count
merchant_reference is an optional field for payment schedule

interval for scheduled payment is the frequency of when payments must be processed, either once off, monthly , daily or weekly. Must be set to one following values:
[once_off, monthly, daily, weekly]
start_date must be formatted DD-MM-YYYY eg. 02-05-2017
count is amount of payments to be made for schedule eg. if count is 3, interval is weekly and start date is 07-01-2017 payments will be processed on following dates: 07-01-2017, 14-01-2017, 21-01-2017

Request Method: POST

Url: https://gateway.switch.tj/api/v1/payment-schedule

Post parameters:

Attribute Type Description Required
guid string A guid that matches a customer Credit Card token on our system Yes
schedules array One or more scheduled dates, required fields for array: bank, amount, branch, account, count. Yes

Example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/payment-schedule -d "guid=4a7c851d-9400-4c67-bc48-b45419dd2582&schedules[0][interval]=monthly&schedules[0][amount]=100.50&schedules[0][start_date]=18-04-2018&schedules[0][count]=2&schedules[1][interval]=weekly&schedules[1][amount]=80&schedules[1][start_date]=01-01-2017&schedules[1][count]=4" 

Response


[
    {
        "id": 27,
        "interval": "monthly",
        "amount": "100.50",
        "start_date": "18-04-2018",
        "count": 2,
        "reference": "reference3"
    },
    {
        "id": 28,
        "interval": "weekly",
        "amount": "80.00",
        "start_date": "01-01-2017",
        "count": 4,
        "reference": "reference3"
    }
]
        

Update Payment schedule

Will update payment schedule for a customer Credit Card token.
NB Will remove any payment schedules that have not been processed yet and add new ones.

Request Method: PUT

Url: https://gateway.switch.tj/api/v1/payment-schedule/$GUID

Post parameters:

Attribute Type Description Required
guid string A guid that matches a customer Credit Card token on our system Yes
schedules array One or more scheduled dates, required fields for array: bank, amount, branch, account, count. Yes

Example

cURL Request

curl -X PUT -u validusername:validpassword https://gateway.switch.tj/api/v1/payment-schedule/4a7c851d-9400-4c67-bc48-b45419dd2582 -d "schedules[0][interval]=monthly&schedules[0][amount]=100.50&schedules[0][start_date]=01-04-2017&schedules[0][count]=2" 

Response


[
    {
        "id": 29,
        "interval": "monthly",
        "amount": "100.50",
        "start_date": "01-04-2017",
        "count": 2,
        "reference": "reference3"
    }
]
        

View Payment schedule

Will view payment schedule for a customer Credit Card token

Request Method: GET

Url: https://gateway.switch.tj/api/v1/payment-schedule/$GUID

Returned attributes:

Attribute Type Description
schedules array One or more scheduled dates

Example

cURL Request

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/payment-schedule/4a7c851d-9400-4c67-bc48-b45419dd2582 

Response


[
    {
        "id": 29,
        "interval": "monthly",
        "amount": "100.50",
        "start_date": "01-04-2017",
        "count": 2,
        "reference": "reference3"
    }
]
        

View Payment schedules by organisation

Will view payment schedules for an organisation

Request Method: GET

Url: https://gateway.switch.tj/api/v1/payment-schedule/$ORGANISATION_ID/organisation

Filtering by start date is optional (see Curl example)

Returned attributes:

Attribute Type Description
schedules array One or more scheduled dates

Example

cURL Request

curl -X GET -u validusername:validpassword "https://gateway.switch.tj/api/v1/payment-schedule/70/organisation?from_date=01-01-2017&to_date=31-12-2017" 

Response


[
    {
    "id": 11,
    "interval": "weekly",
    "amount": "80.00",
    "start_date": "01-01-2017",
    "count": 4,
    "reference": "reference1"
    },
    {
    "id": 13,
    "interval": "weekly",
    "amount": "80.00",
    "start_date": "01-01-2017",
    "count": 4,
    "reference": "reference2"
    }
]
        

Delete Payment schedule

Deletes all unprocessed payment schedules for a customer Credit Card token

Request Method: DELETE

Url: https://gateway.switch.tj/api/v1/payment-schedule/$GUID

Delete one payment schedule by ID

Url: https://gateway.switch.tj/api/v1/payment-schedule/id/$ID

Example

cURL Request

curl -X DELETE -u validusername:validpassword https://gateway.switch.tj/api/v1/payment-schedule/4a7c851d-9400-4c67-bc48-b45419dd2582 

Response


{
    "success": true,
    "message": "Payment schedules successfully deleted with reference reference123"
}
        

cURL Request example delete by ID

curl -X DELETE -u validusername:validpassword https://gateway.switch.tj/api/v1/payment-schedule/id/1111 

Response


{
    "success": true,
    "message": "Payment schedule ID 1111 successfully deleted"
}
        

Express transaction sms

Send sms with express transaction link.

Request Method: POST

Url: https://gateway.switch.tj/api/v1/express/sms

Will send an sms with express transaction link to user's mobile phone.

Post parameters:

Attribute Type Description Required
amount decimal ie. 10.00 Yes
reference string custom reference No
number string valid mobile number Yes
expiry_date date DD-MM-YYYY No
organisation_id integer Partners only No

Sms example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/express/sms -d "amount=25.00&reference=test&number=27821112222" 

Response


{
    "id": 96,
    "recipient": "https://gateway.switch.tj/u/331e902aa"
}
            

Express transaction Email

Send email with express transaction link.

Request Method: POST

Url: https://gateway.switch.tj/api/v1/express/email

Will send an email with express transaction link to user's email address.

Post parameters:

Attribute Type Description Required
amount decimal ie. 10.00 Yes
reference string custom reference No
email string valid email address Yes
expiry_date date DD-MM-YYYY No
organisation_id integer Partners only No
files[] post array of files File attachments should be posted as array No

Email example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/express/email -d "amount=25.00&reference=test&email=jondoe@domain.com" 

Response


{
    "id": 96,
    "link": "http://gateway.switch.tj/u/331e902aa"
}
    

Cancel Express transaction

Cancel a express transaction via the API.

Request Method: DELETE

Url: https://gateway.switch.tj/api/v1/express

Parameters:

Attribute Type Description Required
id integer 100 OR→reference
reference string merchant unique reference OR→id
organisation_id integer Partners only No

Examples

Cancel From ID

curl --request DELETE  -u validusername:validpassword --url https://gateway.switch.tj/api/v1/express --header 'content-type: application/x-www-form-urlencoded' --data id={expressTransactionID} 

Cancel from Merchant Ref

curl --request DELETE   -u validusername:validpassword --url https://gateway.switch.tj/api/v1/express --header 'content-type: application/x-www-form-urlencoded' --data reference={yourReference} 

Response


{
	"id": {expressTransactionID},
	"status": "deleted"
}

Payment Setup

The payment key is a setup identifier for each payment and required by EFTsecure and Checkout integrations.

Url: https://gateway.switch.tj/api/v1/payment-key

The response will contain a key that can be used for the checkout widget or redirect.

Important notes for EFT payments

  • If sending custom beneficiary bank details the hash field is required.
    You must add an API salt in your organisation's settings under the general tab for this.
    To generate the hash concatenate the beneficiary_account_number, beneficiary_name, beneficiary_account_type,
    beneficiary_bank fields and your API salt in that order. Convert the string to lower case then hash that string using SHA-256 algorithm.
    See code examples below on how to generate in different programming languages.
  • Listed beneficiary account can be set as a string or an associative array to set a different account per bank eg. listed_beneficiary_account[absa] = 'value1'; listed_beneficiary_account[fnb] = 'value2';

Shared parameters:

Attribute Type Description Required
token Auth token ie. c8e542542bcd6b35a5bb708a6df66f08 If no basic auth
amount decimal[10,2] 10.00 Yes
merchant_reference string transaction reference for merchant Yes
customer_reference string transaction reference for customer No
success_url string Redirect url for success No
error_url string Redirect url on error No
cancel_url string Redirect url on cancel No
notify_url string Webhook for getting notified about results No
payment_type string Which payment type to offer the customer
eg. [eft,credit_card]
Will determine hosted endpoint in response.
No
currency_code string Country currency code, will return supported services for that currency
eg. [ZAR, NGN]
Will default to the organisation default currency
No

EFT payment parameters:

Attribute Type Description Required
customer_bank string For pre-selecting a bank for the first step No
listed_beneficiary_account string OR associative array(see above**) The account number reference for the customer if merchant is public listed beneficiary at the bank No
default_beneficiary_reference string The default reference when creating the beneficiary. Useful for account numbers. No
beneficiary_account_number string To override beneficiary account number. No
beneficiary_name string To override beneficiary name. No *required if beneficiary account number set
beneficiary_account_type string Beneficiary account type
[cheque, savings, transmission]
No *required if beneficiary account number set
beneficiary_bank string Beneficiary account number bank
[ABSA, Nedbank, Capitec, FNB, Standard, Investec]
No *required if beneficiary account number set
hash string A sha256 hash of account details and API salt No *required if beneficiary account number set
eft_token guid Eft Token to be used for recurring transactions
Note: This can only be sent if payment_type is eft
No

Credit Card payment parameters:

Attribute Type Description Required
card_token guid Credit Card Token to be used for recurring transactions
Note: This can only be sent if payment_type is credit_card
No
card_token_3ds boolean(0 or 1) Enable/Disable 3ds for Credit Card token payment if gateway supports it No (will default to backend setting)
is_authorisation string is_authorisation confirms if payment has been set as an authorised payment and then will be settled or reversed thereafter No
pending_url String Redirect url for card transactions that does not have a status yet and used for credit card authorisations Yes

Fetch payment key example

Request example

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/payment-key -d "amount=1&merchant_reference=testref123" 

Response


{
    "key": "4ea1ea853463dab5b24f7066c1fc8f4b",
    "url": "https://gateway.switch.tj/eft?payment_key=4ea1ea853463dab5b24f7066c1fc8f4b",
    "origin": "https://gateway.switch.tj"
}

EFT beneficiary hash examples


// PHP
$stringToHash = $beneficiary_account_number.$beneficiary_name.$beneficiary_account_type.$beneficiary_bank.$api_salt;
$hash = hash('sha256', strtolower($stringToHash));

// RUBY
require 'digest'
stringToHash = beneficiary_account_number+beneficiary_name+beneficiary_account_type+beneficiary_bank+api_salt;
hash = Digest::SHA256.hexdigest(stringToHash.downcase);

// PYTHON
import hashlib
string_to_hash = beneficiary_account_number+beneficiary_name+beneficiary_account_type+beneficiary_bank+api_salt
hash = hashlib.sha256(string_to_hash.lower()).hexdigest()

EFTsecure Introduction

The EFTsecure service is our instant EFT payment method. It requires a customer to login as if on their internet banking system and automates the rest of the payment process and notifies to merchant through web hooks or enterprise api's that the payment has been made. A merchants banking details can be setup under settings→eft in the admin console.

Integration methods:

  • Hosted: Redirect to a secure payment page hosted on our system. We manage the security and redirect back with a result.
  • Self Hosted: EFTsecure's enterprise integration, allows you to change the styling and host on your own pages. Requires a SSL certificate.
  • Checkout: EFTsecure's on page payment popup. Allows payments to be processed on page without leaving the site and still being descoped from PCI compliance. Requires a SSL certificate.

Requirements

  • A unique payment-key securely generated server side.
  • The self hosted and checkout integration requires JQuery 1.* and a SSL certificate hosted page for production.
  • At the moment this is a web based service, if you require a in-app solution you will need to see if your framework supports web views.

EFTsecure Hosted (Redirect)

Our hosted method for instant EFT's requires minimal development.

It requires a redirect to a endpoint which will in turn be the payment page hosted on our platform.

After a payment is complete we can notify your system through our web hooks or you can do a lookup of the transaction.

First you will need to create a payment key. This will be used to setup the payment.

EFTsecure Hosted Example

Sample url to redirect to


https://gateway.switch.tj/eft?payment_key={generatedPaymentKey}                
            

EFTsecure Self Hosted (Enterprise)

This integration method gives you more flexibility and allows you to host it on your own website/platform.

You can apply your own stylesheet or use our bootstrap stylesheet. See framework option in the javascript library.

After a payment is complete we can notify your system through our web hooks or you can do a lookup of the transaction.

First you will need to create a Payment key. This will be used by the library to authenticate every jsonp call and save your initial data.

Then you will need to copy a code snippet (see example below) onto your page which will invoke a EFTsecure javascript plugin. Link to javascript plugin

EFTsecure javascript plugin parameters:

Attribute Type Description Required
key string Payment key generated server side Yes
baseUrl string
Default:https://gateway.switch.tj
Overrides base url for plugin api calls (eg. for white labelled domains) No
formId string
default:"eftx-form"
The html ID of the form to populate No
titleId string
default:"eftx-title"
The html ID of the primary heading to populate No
subTitleId string
default:"eftx-subtitle"
The html ID of the secondary heading to populate No
cssFramework string[plain,bootstrap]
default:"plain"
How to format the html for the form No
buttonContainerId string Override to specify a specific button container No
onLoadStart callback Executed when form is submitted on each step No
onLoadStop callback Executed when result is received for each step No

Examples

Unstyled example

Add the following to your <head> tag:

                
<!-- If you do not already use jQuery include it  -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="https://gateway.switch.tj/js/eft-secure.min.js"></script>
                
            

Copy and paste the following html and insert the dynamic {{parameters}}:


                    
<!-- Eftx plain START --> <h1 id="eftx-title">Initialising Transaction</h1> <div>Merchant: {{merchantName}} ({{merchantBank}}), Amount: {{currencyFormattedAmount}}</div> <h2 id="eftx-subtitle"></h2> <div id="loader" style="display: none;">Loading...</div> <form id="eftx-form" autocomplete="false"></form> <div style="clear:both"></div> <div id="eftx-button-container"></div> <script> $(document).ready(function() { new Eftx({ key: "{{paymentKey}}", formId: "eftx-form", titleId: "eftx-title", subTitleId: "eftx-subtitle", cssFramework: "plain", buttonContainerId: "eftx-button-container", //onCancelUrl: "{{yourCancelUrl}}", //onCompleteUrl: "{{yourCompleteUrl}}", onLoadStart: function(){ $("#loader").hide(); $("#eftx-form").hide(); $("#eftx-button-container").hide(); //Do other stuff here }, onLoadStop: function(){ $("#loader").addClass("hide"); $("#eftx-form").show(); $("#eftx-button-container").show(); //Do other stuff here } }); }); </script> <!-- Eftx plain END -->

Boostrap styled example

Add the following to your <head> tag:

                
<!-- If you do not already use jQuery include it  -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="https://gateway.switch.tj/js/eft-secure.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://gateway.switch.tj/css/eftx.css">
                
            

Copy and paste the following html and insert the dynamic {{parameters}}:


                    
<!-- Eftx boostrap START --> <div class="eft modal" id="eftxModal" tabindex="-1" role="dialog" aria-labelledby="title"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title pull-left" id="eftx-title">Initialising Transaction</h4> <h4 class="modal-title pull-right">Amount: {{currencyFormattedAmount}}</h4> <div class="clearfix"></div> <div>Merchant: {{merchantName}} ({{merchantBank}})</div> </div> <div class="modal-body"> <h4 id="eftx-subtitle"></h4> <div class="eftx-loader"> <div class="container"> <div class="loader"> <div class="loader--dot"></div> <div class="loader--dot"></div> <div class="loader--dot"></div> <div class="loader--dot"></div> <div class="loader--dot"></div> <div class="loader--dot"></div> <div class="loader--text"></div> </div> </div> </div> <form id="eftx-form" autocomplete="false"></form> <div class="clearfix"></div> </div> <div class="modal-footer" id="eftx-button-container"> </div> </div> </div> </div> <script type="text/javascript"> $(document).ready(function() { new Eftx({ key: "{{paymentKey}}", //enum[bootstrap, none] cssFramework: "bootstrap", buttonContainerId: "eftx-button-container", //onCancelUrl: "{{yourCancelUrl}}", //onCompleteUrl: "{{yourCompleteUrl}}", backgroundEnabled: true, onLoadStart: function(){ $(".eftx-loader").removeClass("hide"); $("#eftx-form").hide(); $(".modal-footer button").hide(); //Do other stuff here }, onLoadStop: function(){ $(".eftx-loader").addClass("hide"); $("#eftx-form").show(); $(".modal-footer button").show(); //Do other stuff here } }); }); </script> <!-- Eftx bootstrap END -->

Credit Card Payments

A service for accepting Credit Card payments via Redirect, Checkout, Server to Server.

Integration methods:

  • Redirect: Redirect to a secure payment page hosted on our system. We manage the security and redirect back with a result.
  • Checkout: The on page payment popup. Allows payments to be processed on page without leaving the site and still being descoped from PCI compliance. Requires a SSL certificate.
  • Server to Server: a Self hosted option for Credit Card payments, Note that this will place you in scope for PCI Compliance.

Requirements

  • A unique payment-key securely generated server side.
  • The self hosted and checkout integration requires JQuery 1.* and a SSL certificate hosted page for production.
  • At the moment this is a web based service, if you require a in-app solution you will need to see if your framework supports web views.

Credit Card Hosted (Redirect)

Our hosted method for instant Credit Cards requires minimal development.

It requires a redirect to a endpoint which will in turn be the payment page hosted on our platform.

After a payment is complete we can notify your system through our web hooks or you can do a lookup of the transaction.

First you will need to create a payment key. This will be used to setup the payment.

Server to Server

Server to server ZAR credit card payments

Request Method: POST

Url: https://gateway.switch.tj/api/v1/pay/direct

Responses of type "result":
Transaction result received and can be details directly available in the response.

You must check the status of the transaction in api result or webhook body by checking the "status" field

Available statuses:

Status Description
complete has been completed/settled succesfully
failed transaction has failed
refunded transaction has been refunded
partially-refunded transaction has been partially refunded
authorised transaction amount has been authorised. (Not yet settled/reversed)
reversed authorised transaction has been reversed

Responses of type "3ds_redirect":
3D authentication is required by the gateway. Customer will need to be redirected to the specified url and transaction can be reconciled using the redirect or webhook response..

NB: We strongly recommend implementing webhooks since redirects can fail for a variety of reasons. If using only using the redirect result we strongly recommend confirming the status and amount via the View Transaction API call

Post parameters:

Attribute Type Description Required
pan number Credit card number Yes
expiry string {m}{y} ie 1220 yes
cvv number 3 to 5 digits yes
amount decimal (ZAR) ie. 10.00 Yes
merchant_reference string max 20 chars yes
first_name string max 20 chars no
last_name string max 20 chars no
return_url string to return from auth if 3ds enabled
notify_url string Server to server webhook no

Fields for 3D Secure 2:
These fields are optional, however might be required when using certain payment gateways with 3D Secure 2.

Post parameters:

Attribute Type Example
screen_color_depth string 24
java_enabled string True
navigator_language string en-US
window_inner_height string 390
window_inner_width string 1848
timezone string -120
navigator_user_agent string Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0

Pay Direct examples

cURL: Non 3Ds enabled Card/Payment

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/pay/direct -d "amount=1.00&merchant_reference=yourReference&pan=4242424242424242&expiry=1223&cvv=123&first_name=John&last_name=Doe" 

Response

                
{
  "type": "result",
  "transaction": {
    "id": 1356875,
    //Payment success flag
    "successful": 1,
    "status": "complete",
    "amount": "1.00",
    //Reason to be used if not successfull
    "reason": "n/a",
    "displayAmount": "R1.00",
    "currency": "ZAR",
    "merchant_reference": "yourReference",
    "gateway_reference": "8ac7a4a068f0543a0169050233c8335c",
    "payment_key": "0cd95fd9adabdc00275fdf6eef675950",
    "created": "2019-02-19 09:07:02",
    "refunded_amount": "0.00",
    "refunded": 0,
    "service": "Direct",
    "gateway": "Imbeko",
    //Dynamic gateway response. Different per gateway
    "gateway_response_parameters": {...}
  }
}
                
            

cURL: 3Ds enabled Card/Payment

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/pay/direct -d "amount=1.00&merchant_reference=yourReference&pan=4242424242424242&expiry=1223&cvv=123&first_name=John&last_name=Doe&return_url=http://myreturnurl.com" 

Response

                
{
  "type": "3ds_redirect",
  "redirect_url": "https://gateway.switch.tj/gatewaytransactions/3ds/?transactionID=1356876",
  "gateway_transaction_id": "1356876"
}
                
            

Authorisation example (Without 3D secure) - (This call allows you to authorise funds on the customers card, which can then be settled or reversed via the api afterwards)

CURL: Non 3Ds enabled Card/Payment - The purpose of the authorise call is to authorise funds on the users card without settling. The funds can be settled or reversed via the api afterwards

curl -X POST -u username:password http://gateway.switch.tj/api/v1/pay/auth -d "amount=10.00&merchant_reference=yourReference&pan=11223340000000044&expiry=1022&cvv=123"

Response

                
    {
      "type": "result",
      "transaction": {
        "id": 59,
        "successful": 0,
        "status": "authorised",
        "amount": "10.00",
        "reason": null,
        "displayAmount": "R1.00",
        "currency": "ZAR",
        "merchant_reference": "yourReference",
        "gateway_reference": "59000000-0000-0000-0000-000000000000",
        "payment_key": "7b72821464c18cc441ab7adf50cd0418",
        "created": "2021-03-02 08:24:17",
        "refunded_amount": "0.00",
        "refunded": 0,
        "service": "Direct",
        "gateway": "Imbeko",
        "gateway_response_parameters": {...},
        "call": "",
        "location": "",
        "signature": null,
        "is_demo_transaction": 1
      }
    }
                
            

Authorisation example (3D secure)

CURL: 3Ds enabled Card/Payment

curl -X POST -u username:password http://gateway.switch.tj/api/v1/pay/auth -d "amount=10.00&merchant_reference=yourReference&pan=5412830000965153&expiry=1022&cvv=314&return_url=http://myreturnurl.com"

Response

                
{
  "type": "3ds_redirect",
  "redirect_url": "https://gateway.switch.tj/gatewaytransactions/3ds/?session=f67b08b2a23340fd30075136fda1f0a0",
  "gateway_transaction_id": "82"
}
                
            

Authorisation example paying with a Credit Card token (Without 3D secure)

CURL: Non 3Ds enabled Credit Card Token Payment

curl -X POST -u username:password http://gateway.switch.tj/api/v1/customer-token/A075A036-A2BF-4557-8206-DB5B035FB5C0/auth -d "amount=1.00&reference=yourReference&is_authorisation=1"

Response

                
{
  "success": 0,
  "amount": "1.00",
  "reason": null,
  "callpay_transaction_id": 1122,
  "organisation_id": 5,
  "merchant_reference": "yourReference",
  "gateway_reference": "11220000-0000-0000-0000-000000000000",
  "gateway_response": {...}
}
                
            

Authorisation example paying with a token (With 3D secure)

CURL: 3Ds enabled Credit Card Token Payment

curl -X POST -u username:password http://gateway.switch.tj/api/v1/customer-token/A075A036-A2BF-4557-8206-DB5B035FB5C0/auth -d "amount=1.00&reference=yourReference&is_authorisation=1&pending_url=https://mypendingurl.com"

Response

                
{
  "type": "3ds_redirect",
  "redirect_url": "https://services.callpay.com/gatewaytransactions/3ds/?session=f67b08b2a23340fd30075136fda1f0a0",
  "gateway_transaction_id": "82"
}
                
            

Settle authorisation example (This call allows you to settle either the full authorised amount or settle a partial amount)

CURL: settle card auth by Gateway Reference

curl -X PUT -u username:password http://gateway.switch.tj/api/v1/pay/settle -d "gateway_reference=59000000-0000-0000-0000-000000000000"

CURL: settle card auth by Gateway Transaction ID (With Partial settlement Amount)

curl -X PUT -u username:password http://gateway.switch.tj/api/v1/pay/settle -d "gateway_transaction_id=6&amount=5.00"

Response

                
{
  "type": "result",
  "message": "Transaction settled successfully",
  "transaction": {
    "id": 6,
    "successful": 1,
    "status": "complete",
    "amount": "5.00",
    "reason": null,
    "displayAmount": "R5.00",
    "currency": "ZAR",
    "merchant_reference": "yourReference",
    "gateway_reference": "59000000-0000-0000-0000-000000000000",
    "payment_key": "7b72821464c18cc441ab7adf50cd0418",
    "created": "2021-03-02 08:24:17",
    "refunded_amount": "0.00",
    "refunded": 0,
    "service": "Direct",
    "gateway": "Imbeko",
    "gateway_response_parameters": {...},
    "call": "",
    "location": "",
    "signature": null,
    "is_demo_transaction": 1
  }
}
                
            

Reverse authorisation example (This call allows you to reverse the authorised amount)

CURL: reverse card auth

curl -X PUT -u username:password http://gateway.switch.tj/api/v1/pay/reverse -d "gateway_reference=60000000-0000-0000-0000-000000000000"

Response

                
{
  "type": "result",
  "message": "Transaction reversed",
  "transaction": {
    "id": 60,
    "successful": 0,
    "status": "reversed",
    "amount": "1.00",
    "reason": null,
    "displayAmount": "R1.00",
    "currency": "ZAR",
    "merchant_reference": "yourReference",
    "gateway_reference": "60000000-0000-0000-0000-000000000000",
    "payment_key": "5599e73ca457ee554c7b8b5f852ff236",
    "created": "2021-03-02 08:29:12",
    "refunded_amount": "0.00",
    "refunded": 0,
    "service": "Direct",
    "gateway": "Imbeko",
    "gateway_response_parameters": {...},
    "call": "",
    "location": "",
    "signature": null,
    "is_demo_transaction": 1
  }
}
                
            

Credit Card Tokenisation

Token Payment Methods:

Token Payments

Tokenisation Methods:

  • Server to Server (non 3Dsecure): Self hosted option, only available for non #d payments.
  • Checkout: Pass card token parameter to payment key Api call, and skip first card collection step for payment.
  • Redirect: Pass card token parameter to payment key Api call, and skip first card collection step for payment.

Checkout Widget

This integration method allows you to host EFT, Credit Card payments on your own website/platform and still descope you from PCI compliance.

NB: A SSL certificate is required to ensure compatibility with the frame.

First you will need to create a Payment key. This will be used by the widget to authenticate the payment in the frame.

NB: When creating a payment key you must specify the redirect success and error urls, if not set page will redirect to default receipt page after transaction

You will need to copy a code snippet (see example below) onto your page which will invoke a EFTsecure checkout widget. Click here to view a live example

Checkout widget parameters:

Attribute Type Description Required
paymentKey string Payment key generated server side Yes
paymentType string
Force payment type [eft,credit_card] No
onLoad event Override for example re-enable payment button No
cardOptions object Enable Card options Eg. "rememberCard" default value 0 No

Checkout Example

Add the following to your <head> tag:

                
<!-- If you do not already use jQuery include it  -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<!-- The data-origin attribute value is the origin value returned from the payment key API call  -->
<!-- Also ensure that the id attribute is set to og-checkout -->
<script type="text/javascript" src="https://gateway.switch.tj/ext/checkout/v3/checkout.js" id="og-checkout" data-origin="https://gateway.switch.tj"></script>
                                    
            

Copy and paste the following html and insert the dynamic {{parameters}}:


                    
<form id="#payment-form" action="/checkout?confirm=1" style="margin-top: 50px"> <div class="text-center"> <button id="pay-button" class="btn btn-primary btn-sx" type="button" data-payment-key="{{paymentKey}}">Pay</button> </div> </form> <script type="text/javascript"> $(function() { $('#pay-button').on('click', function() { $(this).hide(); var paymentKey = $(this).data('payment-key'); eftSec.checkout.init({ paymentKey: paymentKey, paymentType: 'credit_card', // optional: force payment type onLoad: function() { $('#pay-button').show(); }, cardOptions: { //optional for Tokenizing Card rememberCard: false, rememberCardDefaultValue: 0 }, }); }); }); </script>

Transaction, Recon & Exports

Allows you to view/confirm or list a organisation transactions.

List organisation transactions

Fetch all transactions for an organisation by organisation id.' Organisation id is required in url

Request Method: GET

Url: https://gateway.switch.tj/api/v1/organisation/$ORGANISATION_ID/gateway-transaction

Returned attributes per transaction:

Attribute Type Description
id integer unique primary key for transaction
successful integer integer indicating whether transaction was successful or not (1 being true 0 being false)
amount decimal transaction amount
gateway_reference text payment gateway reference number
created date date and time of transaction
service text name of service used by agent
from_date date (dd-mm-yyyy) Where date >=
to_date date (dd-mm-yyyy) Where date <=

List organisation transactions example

cURL Request

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/organisation/$ORGANISATION_ID/gateway-transaction

Response


[
    {
        "id": 166,
        "successful": 1,
        "amount": "123.00",
        "gateway_reference": "Gateway_merchant_ref_1434026074",
        "created": "2015-06-11 12:34:34",
        "service": "Scan Card"
    },
    {
        "id": 167,
        "successful": 1,
        "amount": "123.00",
        "gateway_reference": "Gateway_merchant_ref_1434026303",
        "created": "2015-06-11 12:38:23",
        "service": "POS"
    },
    {
        "id": 168,
        "successful": 1,
        "amount": "123.00",
        "gateway_reference": "Gateway_merchant_ref_1434027451",
        "created": "2015-06-11 12:57:31",
        "service": "POS"
    }
]

Export transactions (CSV)

Download a csv containing transactions. Can be filtered by the parameters in the table below.

Request Method: GET

Url: https://gateway.switch.tj/api/v1/export/gateway-transactions

Filtering attributes:

Parameter Type Description
from_date date (dd-mm-yyyy) Where date >=
to_date date (dd-mm-yyyy) Where date <=

Export CSV example

cURL Request

curl -X GET  -u validusername:validpassword https://gateway.switch.tj/api/v1/export/gateway-transactions?from_date=28-02-2024&to_date=28-03-2024

List transactions by User

Fetch all transactions for user by user id.User id is required in url

Request Method: GET

Url: https://gateway.switch.tj/api/v1/user/$USER_ID/gateway-transaction

Returned attributes per transaction:

Attribute Type Description
id integer unique primary key for the transaction
successful integer integer indicating whether transaction was successful or not (1 being true 0 being false)
amount decimal transaction amount
gateway_reference text payment gateway reference number
created date date and time of transaction
service text name of service used by agent

List gateway transactions by user example

cURL Request

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/user/$USER_ID/gateway-transaction

Response


[
    {
        "id": 166,
        "successful": 1,
        "amount": "123.00",
        "gateway_reference": "Gateway_merchant_ref_1434026074",
        "created": "2015-06-11 12:34:34",
        "service": "Scan Card"
    },
    {
        "id": 167,
        "successful": 1,
        "amount": "123.00",
        "gateway_reference": "Gateway_merchant_ref_1434026303",
        "created": "2015-06-11 12:38:23",
        "service": "POS"
    },
    {
        "id": 168,
        "successful": 1,
        "amount": "123.00",
        "gateway_reference": "Gateway_merchant_ref_1434027451",
        "created": "2015-06-11 12:57:31",
        "service": "POS"
    }
]

View Transaction

View transaction by id. Will be sent back as single object and status 200. Transaction id is required

Request Method: GET

Url: https://gateway.switch.tj/api/v1/gateway-transaction/$GATEWAY_TRANSACTION_ID

Returned attributes:

Attribute Type Description
id integer unique primary key for transaction
successful integer integer indicating whether transaction was successful or not (1 being true 0 being false)
amount decimal transaction amount
gateway_reference text payment gateway reference number
created date date and time of transaction
service text name of service used by agent

Fetch transaction example

cURL By ID

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/gateway-transaction/$GATEWAY_TRANSACTION_ID
OR

cURL By merchant reference

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/gateway-transaction/?reference=$MERCHANT_REFERENCE 
OR

cURL By payment key

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/gateway-transaction/?key=$PAYMENT_KEY 

Response


{
  "id": 11111,
  "successful": 1,
  "status": "complete",
  "amount": "5.00",
  "reason": "n/a",
  "displayAmount": "R5.00",
  "currency": "ZAR",
  "merchant_reference": "1111111-11111-1111",
  "gateway_reference": "11111111-0000-0000-0000-000000000000",
  "payment_key": "19440ff6006e2179ea4bbd6b470693ee",
  "created": "2021-02-18 11:59:58",
  "refunded_amount": "0.00",
  "refunded": 0,
  "service": "Direct",
  "gateway_response_parameters": {
    "accountFrom": "30",
    "accountTo": "00",
    "amount": 500,
    "authCode": "843199",
    "card": "424242*****4242",
    "cardName": "Diners",
    "cardToken": "1111111-1111-1111-1111-1111111",
    "currency": "710",
    "dmsIndicator": false,
    "echo": "52857350-dd49-46df",
    "pos": "00173138",
    "reference": "22117406-0000-0000-0000-000000000000",
    "responseCode": "00",
    "responseText": "Approved",
    "rrn": "00001111111",
    "seq": "1111111",
    "store": "000000001111111",
    "storeDetails": {
      "city": "Cape Town    ",
      "country": "ZA",
      "name": "Store name",
      "region": "WC"
    },
    "tran": "00",
    "tranQualifier": "008601",
    "gatewayCardToken": "1111111-1111-1111-1111-1111111",
    "card_token": "1111111-1111-1111-1111-1111111", // Token to be re-used
    "bin": "424242"
  },
  "call": "",
  "location": "",
  "signature": null,
  "is_demo_transaction": 1,
  "token": "1111111-1111-1111-1111-1111111", // Token to be re-used
}

Refund a transaction

Some gateways supports refund capability of the full amount.

Request Method: PUT

Url: https://gateway.switch.tj/api/v1/gateway-transaction/refund/{$transaction_id}

By default this will refund the complete transaction amount.

Attribute Type Description
amount float Optional. Amount lower or equal to the transaction amount.

Refund a transaction

cURL Request

curl -X PUT -u validusername:validpassword https://gateway.switch.tj/api/v1/gateway-transaction/refund/12345678 

Response


{
    "result": true
}

Resend a webhook

This API call allows you to resend a webhook for a transaction.

Request Method: POST

Url: https://gateway.switch.tj/api/v1/gateway-transaction/resend-webhook/{$gateway_transaction_id}

This will allow you to resend your webhook and the API call requires a custom URl to attribute

Attribute Type Description Required
url string URL to post webhook data to Yes

Resend webhook example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/gateway-transaction/resend-webhook/{$gateway_transaction_id} -d 'url=https://yoursite.com/webhook-endpoint' 

Response


{
  "success": true,
  "message": "Webhook has been queued successfully"
}

User

Allows you manage organisation users.

List all Users

Fetch all users for an organisation by organisation id.' Organisation id is required in url

Request Method: GET

Url: https://gateway.switch.tj/api/v1/organisation/$ORGANISATION_ID/user

Returned attributes per user:

Attribute Type Description
id integer unique primary key for user
name text user first name
lastname text user last name
username text user username
email valid email address user email address
contact_number integer user contact number
organisation_id integer user organisation id
created date date user was created
extension integer If user is type agent will return an extension for him/her

List all example

cURL Request

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/organisation/$ORGANISATION_ID/user

Response


[
    {
        "id": 2,
        "name": "John",
        "lastname": "Doe",
        "username": "johndoe",
        "email": "johndoe@merchantcompany.co.za",
        "contact_number": 0821234567,
        "organisation_id": 3,
        "created": "2015-02-03 14:19:39",
        "extension": "4444"
    },
    {
        "id": 3,
        "name": "Joe",
        "lastname": "Doe",
        "username": "joedoe",
        "email": "joedoe@merchantcompany.co.za",
        "contact_number": 0821234567,
        "organisation_id": 3,
        "created": "2015-02-03 14:19:39",
        "extension": "5555"
    }
]

View User

View existing user by User id. Will be sent back as single object and status 200. User id is required

Request Method: GET

Url: https://gateway.switch.tj/api/v1/user/$USER_ID

Returned attributes:

Attribute Type Description
id integer unique primary key for user
name text user first name
lastname text user last name
username text user username
email valid email address user email address
contact_number integer user contact number
organisation_id integer user organisation id
created date date user was created
extension integer If user is type agent will return an extension for him/her

View example

cURL Request

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/user/3 

Response


{
    "id": 3,
    "name": "Joe",
    "lastname": "Doe",
    "username": "joedoe",
    "email": "joedoe@merchantcompany.co.za",
    "contact_number": 0821234567,
    "organisation_id": 3,
    "created": "2015-02-03 14:19:39",
    "extension": "5555"
}

Create User

Create new user Will be send back a single object (see View User for returned attributes) and status 201 (Created).

Request Method: POST

Url: https://gateway.switch.tj/api/v1/user

User Post parameters: post as User[$ATTRIBUTE]

Attribute Type Description Required
username text user username Yes
role valid user role See list of user roles Yes
password text user password No
name text user first name No
lastname text user last name No
email valid email address user email address No
contact_number integer user contact number No

Create example

cURL Request

curl -X POST -u validusername:validpassword https://gateway.switch.tj/api/v1/user -d "User[username]=unique&User[role]=agent" 

Response


{
    "id": 8,
    "name": null,
    "lastname": null,
    "username": "unique",
    "email": null,
    "contact_number": null,
    "organisation_id": 3,
    "created": "2015-02-03 14:19:39",
    "extension": null
}
      

Update User

Update existing organisation by User id.User id is required in url'); ?>

Request Methods: PUT

Url: https://gateway.switch.tj/api/v1/user/$USER_ID

User Put parameters: post as User[$ATTRIBUTE]

Attribute Type Description
username text user username
password text user password
role valid user role See list of user roles
name text user first name
lastname text user last name
email valid email address user email address
contact_number integer user contact number

Update example

cURL Request

curl -X PUT -u validusername:validpassword https://gateway.switch.tj/api/v1/user/8 -d "User[name]=Jason" 

Response


{
    "id": 8,
    "name": "Jason",
    "lastname": null,
    "username": "unique",
    "email": null,
    "contact_number": null,
    "organisation_id": 3,
    "created": "2015-02-03 14:19:39",
    "extension": null
}

Licenses

Allows you to update organisation licenses and activate/deactivate agent licenses.

Update organisation licenses

Update amount of licenses organisation has for a service by Organisation id.Organisation id is required in url

Request Method: PUT

Url: https://gateway.switch.tj /api/v1/organisation/$ORGANISATION_ID/licenseupdate

Put parameters: post array of service ids with service id as key and amount of licenses as value
eg. serviceId[$SERVICE_ID_ONE]=$AMOUNT_OF_LICENSES
eg. serviceId[$SERVICE_ID_TWO]=$AMOUNT_OF_LICENSES
See available service IDs

Update example

cURL Request

curl -X PUT -u validusername:validpassword https://gateway.switch.tj/api/v1/organisation/10/licenseupdate -d "serviceId[1]=25&serviceId[2]=35"

Response


{
    "Organisation": "Organisation name",
    "Services": {
        "serviceId": {
            "1": "25",
            "2": "35"
        }
    }
}

Activate user

Activate user license for service/s by user id.User id is required in url

Request Method: PUT

Url: https://gateway.switch.tj/api/v1/user/$USER_ID/activate

Put parameters: post array of service ids
eg. serviceId[]=$SERVICE_ID_ONE
serviceId[]=$SERVICE_ID_TWO
See available service IDs

Activate user example

cURL Request

curl -X PUT -u validusername:validpassword https://gateway.switch.tj/api/v1/user/2/activate -d "serviceId[]=1&serviceId[]=2"

Response


{
    "services": {
            "service_one": "Activated",
            "service_two": "Activated"
        },
    "User": {
            "id": 2,
            "name": "4315",
            "lastname": "4315",
            "email": "4315@yourdomain.co.za",
            "username": "4315"
        }
}

Deactivate user

Deactivate user license for service/s by user id.User id is required in url

Request Method: PUT

Url: https://gateway.switch.tj/api/v1/user/$USER_ID/deactivate

Put parameters: post array of service ids
eg. serviceId[]=$SERVICE_ID_ONE
eg. serviceId[]=$SERVICE_ID_TWO
See available service IDs

Deactivate user example

cURL Request

curl -X PUT -u validusername:validpassword https://gateway.switch.tj/api/v1/user/3/deactivate -d "serviceId[]=1&serviceId[]=2" 

Response


{
    "services": {
            "service_one": "Deactivated",
            "service_two": "Deactivated"
        },
    "User": {
            "id": 3,
            "name": "4315",
            "lastname": "4315",
            "email": "4315@yourdomain.co.za",
            "username": "4315"
        }
}

Receipts

Send a payment receipt via email or sms

Send a SMS/Email receipt

Use this api call to notify a customer of a successful transaction.
Templates can be set in settings.

Request Method: POST

Url: https://gateway.switch.tj/api/v1/notification/send

POST parameters:

Attribute Type Description
recipient text a valid mobile number or email address
type text [Sms, Email]
transactionID bigint a valid transction ID

Example(s)

cURL Request

curl -X GET -u validusername:validpassword https://gateway.switch.tj/api/v1/organisation/1/gateway-transaction -d "recipient=0720000000&type=Sms&transactionID=1" 

Response


{
    "result": true
}