Request Payment

POST {{base-url}}/payment/create

Request a new payment. This API will return a payment id, a success status indicator, a redirect url and a trust signature. It also contains an array of the products containing the product sku, if the product was accepted or rejected and the cheapest price that Teljoy have on each product. The payment id can be used to check the status of the payment. The redirect url can be used to redirect the user to the Teljoy payment page. The trust signature can be used to verify the integrity of the response. The trust signature is a SHA256 hash of the provided trust seed and value.

Parameters

Headers

NameTypeRequiredDescription
api-keystringYesThe API key for access

Request

{
  "customer": {
    "first_Name": "string",
    "last_Name": "string",
    "email": "string",
    "mobile": "string",
    "salary": "string|null",
    "is_under_debt_review": "boolean|null",
    "registration_document_number": "string|null"
  },
  "billing_Address": {
    "building": "string",
    "street": "string",
    "suburb": "string",
    "city": "string",
    "province": "string",
    "postal_Code": "string",
    "country": "string",
    "longitude": 0,
    "latitude": 0
  },
  "shipping_Address": {
    "building": "string",
    "street": "string",
    "suburb": "string",
    "city": "string",
    "province": "string",
    "postal_Code": "string",
    "country": "string",
    "longitude": 0,
    "latitude": 0
  },
  "products": [
    {
      "name": "string",
      "description": "string",
      "short_Description": "string",
      "brand": "string",
      "images": ["string"],
      "url": "string",
      "price": 0,
      "sku": "string",
      "barcodes": ["string"],
      "quantity": 1,
      "categories": [
        {
          "categoryId": "string",
          "name": "string",
          "url": "string"
        }
      ],
      "properties": [
        {
          "key": "string",
          "value": "string"
        }
      ]
    }
  ],
  "redirects": {
    "order_Id": "string",
    "success_Redirect_Url": "string",
    "failure_Redirect_Url": "string",
    "final_Amount": 0,
    "tax_Amount": 0,
    "shipping_Amount": 0,
    "discount": 0,
    "trust_Value": "string",
    "trust_Seed": "string",
    "merchant_Store": "string"
  },
  "personal": {
     "employerName": "Test",
     "employerContactNumber": "0123456789",
     "nextOfKinName": "Test",
     "nextOfKinContactNumber": "0123456798",
     "maritalStatus": 0,
     "nextOfKinRelationshipType": 0
    }
}

payload

NameTypeRequiredDescription
apiKeystringYesThe API key for access
customerRequestPaymentCustomerDTOYesCustomer information
billing_AddressRequestPaymentAddressDTOYesBilling address information
shipping_AddressRequestPaymentAddressDTOYesShipping address information
productsarray of RequestPaymentProductDTOYesArray of products
redirectsRequestPaymentRedirectsDTOYesRedirect URLs and related details
personalPersonalInfoDTONoFurther customer information

RequestPaymentCustomerDTO

NameTypeRequiredDescription
first_NamestringYesCustomer's first name
last_NamestringYesCustomer's last name
emailstringYesCustomer's email
mobilestringYesCustomer's mobile
salarystringNoNet Salary
is_under_debt_reviewboolNoIs customer under debt review
registration_document_numberstringNoIdentity Number

RequestPaymentAddressDTO

NameTypeRequiredDescription
buildingstringYesBuilding name/number
streetstringYesStreet name
suburbstringYesSuburb name
citystringYesCity name
provincestringYesProvince name
postal_CodestringYesPostal code
countrystringYesCountry name
longitudenumberYesLongitude coordinate
latitudenumberYesLatitude coordinate

RequestPaymentProductDTO

NameTypeRequiredDescription
namestringYesProduct name
descriptionstringYesProduct description
short_DescriptionstringYesShort product description
brandstringYesProduct brand
imagesarray of stringYesArray of product image URLs
urlstringYesProduct URL
pricenumberYesProduct price
skustringYesProduct SKU
quantityintYesProduct Quantity
barcodesarray of stringYesArray of product barcodes
categoriesarray of RequestPaymentProductCategoryDTOYesArray of product categories
propertiesarray of RequestPaymentProductPropertyDTOYesArray of product properties

RequestPaymentProductCategoryDTO

NameTypeRequiredDescription
categoryIdstringYesCategory ID
namestringYesCategory name
urlstringYesCategory URL

RequestPaymentProductPropertyDTO

NameTypeRequiredDescription
keystringYesProperty key
valuestringYesProperty value

RequestPaymentRedirectsDTO

NameTypeRequiredDescription
order_IdstringYesOrder ID
success_Redirect_UrlstringYesSuccess redirect URL
failure_Redirect_UrlstringYesFailure redirect URL
final_AmountnumberYesFinal amount
tax_AmountnumberYesTax amount
shipping_AmountnumberYesShipping amount
discountnumberYesDiscount amount
merchant_StorestringNoStore Name
trust_ValuestringYesTrust value
trust_SeedstringYesTrust seed

PersonalInfoDTO

NameTypeRequiredDescription
employerNamestringYesEmployers name
employerContactNumberstringYesEmployer's contact no
maritalStatusMaritalStatusEnumYesMarital Status
nextOfKinNamestringYesNext of kin name
nextOfKinContactNumberstringYesNext of kin contact no
nextOfKinRelationshipTypeRelationshipStatusEnumYesNext of kin relationship

MaritalStatusEnum

LabelValue
Married0
Single1
Divorced2
Widowed3
Living Together4

RelationshipStatusEnum

LabelValue
Spouse0
Partner1
Family2
Friend3
Colleague4

Response

{
  "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "success": true,
  "trust_signature": "string",
  "redirect_url": "string",
  "products": [
    {
      "sku": "string",
      "accepted": true,
      "price": 0
    }
  ]
}

payload

NameTypeDescription
idstringPayment ID
successbooleanSuccess status
trust_signaturestringTrust signature
redirect_urlstringRedirect URL
productsarray of RequestPaymentResponseProductDTOArray of response products

RequestPaymentResponseProductDTO

NameTypeRequiredDescription
skustringYesProduct SKU
acceptedbooleanYesProduct acceptance
pricenumberYesProduct price

Errors

CodeDescription
400One or more validation errors
500Server Error

Bad Request Example

{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "traceId": "1ed63b98-eda9-4634-9738-8ec74bac3bd6",
  "errors": {
    "apiKey": ["The apiKey field is required."],
    "customer": ["The customer field is required."]
  }
}

Internal Server Error Example

{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.6.1",
  "title": "An error occurred.",
  "status": 500,
  "traceId": "ced4db70-527d-41d6-9a90-e7eb165df5b6"
}

Example Usage

Here's an example of how to make a POST request to the /api/payment/create endpoint using Javascript and the fetch API:

let headersList = {
 "Accept": "*/*",
 "api-key": "your_api_key",
 "Content-Type": "application/json"
}

let bodyContent = JSON.stringify({
  "customer": {
    "first_name": "John",
    "last_name": "Doe",
    "email": "john.doe@example.com",
    "mobile": "+27821112233",
    "salary": "8500",
    "is_under_debt_review": false,
    "registration_document_number": "1234567891023"
  },
  "shipping_address": {
    "building": "Building A",
    "street": "123 Street",
    "suburb": "Suburb",
    "city": "City",
    "province": "GP",
    "country": "ZA",
    "postal_code": "2060",
  },
  "billing_address": {
    "building": "Building A",
    "street": "123 Street",
    "suburb": "Suburb",
    "city": "City",
    "province": "GP",
    "country": "ZA",
    "postal_code": "2060",
  },
  "products": [
    {
      "name": "HISENSE 100L5F 10\" LASER TV1",
      "description": "string",
      "short_description": "The L5 Laser TV immerses you into a whole new 4K UHD viewing experience.",
      "brand": "HISENSE",
      "images": [
        "https://atomictest.co.za/wp-content/uploads/2021/11/100L5F.jpeg"
      ],
      "url": "https://www.amazon.co.za/Pampers-Anti-Rash-Shield-Pants-Diapers/dp/B0CMV81RBJ/ref=asc_df_B0CMV81RBJ",
      "sku": "100L5F",
      "quantity": "1",
      "price": "12657.00"
    }
  ],
  "redirects": {
    "order_id": "76144",
    "trust_value": "c10cd9445121e4ed6ad0ab47cdde2882",
    "trust_seed": "ew0KCQkJCQkJIm5hbWUiOiJISVNFTlNFIDEwMEw1RiAxMDAmcXVvdDsgTEFTRVIgVFYxIiwNCgkJCQkJCSJza3UiOiIxMDBMNUYiLA0KCQkJCQkJInF1YW50aXR5IjoiMSIsDQoJCQkJCQkicHJpY2UiOiIxMjY1Ny4wMCIsDQoJCQkJCQkiZGVzY3JpcHRpb24iOiAic3RyaW5nIiwNCgkJCQkJCSJicmFuZCI6ICJzdHJpbmciLA0KCQkJCQkJIm1lcmNoYW50X3Byb2R1Y3RfaWQiOiI1Mzc4MyIsDQoJCQkJCQkidmVuZG9yIjogew0KCQkJCQkJCSJ2ZW5kb3JfaWQiOiAic3RyaW5nIiwNCgkJCQkJCQkidXJsIjogInN0cmluZyIsDQoJCQkJCQkJIm5hbWUiOiAic3RyaW5nIg0KCQkJCQkJfSwNCgkJCQkJCSJpbWFnZXMiOiBbDQoJCQkJCQkJImh0dHBzOi8vYXRvbWljdGVzdC5jby56YS93cC1jb250ZW50L3VwbG9hZHMvMjAyMS8xMS8xMDBMNUYuanBlZyIgDQoJCQkJCQldLA0KCQkJCQkJImJhcmNvZGVzIjogWw0KCQkJCQkJCSIiDQoJCQkJCQldLA0KCQkJCQkJImNhdGVnb3JpZXMiOiBbIA0KCQkJCQkJXSwNCgkJCQkJCSJwcm9wZXJ0aWVzIjogWw0KCQkJCQkJCXsNCgkJCQkJCQkia2V5IjogInN0cmluZyIsDQoJCQkJCQkJInZhbHVlIjogInN0cmluZyINCgkJCQkJCQl9DQoJCQkJCQldDQoJCQkJCX0s",
    "success_redirect_url": "https://masons.teljoy.sinappsus.co.za/checkout/order-received/76144/?key=wc_order_KNvI7qWItjO7a&utm_nooverride=1&order_id=76144&wc-api=WC_Gateway_Teljoy",
    "failure_redirect_url": "https://masons.teljoy.sinappsus.co.za/checkout/order-received/76144/?key=wc_order_KNvI7qWItjO7a&utm_nooverride=1&status=cancelled",
    "final_amount": 12657.00,
    "tax_amount": 0,
    "shipping_amount": 0,
    "discount": "0",
    "merchant_Store": "Rosebank Mall"
  }
});

let response = await fetch("http://localhost:3000/api/payment/create", { 
  method: "POST",
  body: bodyContent,
  headers: headersList
});

let data = await response.text();
console.log(data);

Replace your_api_key with your actual API key.

Expected Response

This is an example of the expected response:

{
  "id": "be5a83ab-5b57-46f9-95ac-08db35c30d2b",
  "success": true,
  "trust_signature": "c14593cd6c9a24ac6257ab7cac1bb45f0ff272389e600b21580b0261752b04ae",
  "redirect_url": "https://pay.teljoy.dev/payment/be5a83ab-5b57-46f9-95ac-08db35c30d2b",
  "products": [
    {
      "sku": "100L5F",
      "accepted": true,
      "price": 299
    }
  ]
}
Last Updated:
Contributors: rzimanTJY