Initialize payment

This endpoint is used for initializing a transaction and securely processing payments. It handles everything from customer details to encrypted card information. It also supports 3D Secure for extra security against fraud.

Request Parameters

Request
curl --request POST \
  --url https://adapter.cepta.co/api/v1/pay/purchase \
  --header 'Authorization: <SECRET_KEY>' \
  --header 'Content-Type: application/json' \
  --data '
    {
        "transactionRef": "TX12345ABC",
        "customerEmail": "[email protected]",
        "amount": 100,
        "currency": "USD",
        "ipAddress": "192.168.1.1",
        "callbackUrl": "https://example.com/callback",
        "cardDetails": "encrypted_card_info",
        "deviceInformation": {
            "httpBrowserLanguage": "en-US",
            "httpBrowserJavaEnabled": true,
            "httpBrowserJavaScriptEnabled": true,
            "httpBrowserColorDepth": "24",
            "httpBrowserScreenHeight": "1080",
            "httpBrowserScreenWidth": "1920",
            "httpBrowserTimeDifference": "-60",
            "userAgentBrowserValue": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
            "deviceChannel": "Web"
        }
    }
  '

To get started with the charge API, you can initialize the transaction just like the example request described above. You will be required to pass in some parameters as part of the request. Amount, transactionRef, currency, and callbackUrl are some of the required parameters accepted. When a transaction is initialized and processed, ideally you want to redirect customers based on the status of the payment. The callbackUrl passed will be used for this purpose.

You can choose to pass your callbackUrl as a request parameter here or set it from within your Cepta dashboard settings page. We allow you to set test and production callbackUrl, to learn more check here.

Ensure transactionRef is unique for every transaction. Unique references are crucial for reconciling transactions with bank statements or payment processors.

Below is a list of request parameters accepted for the purchase API.

transactionRef
string
required

Unique reference for the transaction.

customerEmail
string
required

Email of the customer making the purchase.

amount
number
required

Amount to be charged

currency
string
required

Currency of the transaction (e.g., “USD”).

ipAddress
string
required

IP address of the customer.

callbackUrl
string
required

URL to redirect the customer after processing.

cardDetails
string
required

Encrypted card details for the payment.

deviceInformation
object

Device information for 3D Secure validation.

httpBrowserLanguage
string
required

Language of the browser.

httpBrowserJavaEnabled
boolean
required

Indicates if Java is enabled in the browser.

httpBrowserJavaScriptEnabled
boolean
required

Indicates if JavaScript is enabled in the browser.

httpBrowserColorDepth
string
required

Color depth of the browser display.

httpBrowserScreenHeight
string
required

Screen height of the browser.

httpBrowserScreenWidth
string
required

Screen width of the browser.

httpBrowserTimeDifference
string
required

Time difference from UTC in the browser.

userAgentBrowserValue
string
required

Browser user-agent string.

deviceChannel
string
required

Channel of the device (e.g., “Web”).

Device information is important for 3D Secure verification

Implementing 3D Secure verification helps us to verify that the transaction is being made by the rightful customer, adding an extra layer of security. This information includes details about the customer’s browser and device, such as whether JavaScript is enabled or the screen size.

If the 3D Secure authentication URL threedSecureUrl is provided, it should be shown to the customer, directing them to a secure page where they can complete the verification process. This ensures the payment is legitimate and helps prevent fraud.

Initialize transaction API Response

A sample response of what to expect when a call is made to the API

Success response
{
  "status": true,
  "message": "Transaction initiated successfully.",
  "data": {
    "referenceInformationCode": "REF12345",
    "responseCode": "00",
    "amount": "100.00",
    "transactionRef": "TX12345ABC",
    "status": "Pending",
    "submitTimeUtc": "2024-11-29T12:22:27.891Z",
    "transactionId": "TRX56789",
    "transactionId3DSecure": "3DS12345",
    "eciFlag": "05",
    "md": "merchant_data",
    "accessToken": "access_token_string",
    "threedSecureUrl": "https://secure.paymentgateway.com/3ds"
  }
}

Handling transaction response body

When a transaction has been initiated successfully, there is response data that is returned. This can be in turn to update the customer about the current stage of their transaction.

Below is the list of responses to expect and the usage.

Response body

status
boolean

Indicates if the request was successful.

message
string

Descriptive message about the request result.

data
object

Contains detailed transaction data.

referenceInformationCode
string

Reference information for the transaction

responseCode
string

Response code from the payment processor.

amount
string

Amount that was charged.

transactionRef
string

Transaction reference.

status
string

Status of the transaction.

submitTimeUtc
string

UTC time when the transaction was submitted.

transactionId
string

Unique ID for the transaction.

transactionId3DSecure
string

ID for 3D Secure transaction, if applicable.

eciFlag
string

Electronic Commerce Indicator flag.

md
string

Merchant data for 3D Secure authentication.

accessToken
string

Access token for subsequent operations.

threedSecureUrl
string

URL for 3D Secure authentication.