DEVELOPERS
Developers / Integration guides / Hosted/Token Integration
INTEGRATION GUIDE / V2 · CARDS

Hosted/Token Integration

Hosted card entry, one-time payments and saved-card transactions.

Start integration →

Overview

EnvironmentBase URL
Sandboxhttps://{sandbox-host}/api
Productionhttps://{production-host}/api

Obtain your hosts, merchant IDs and credentials during onboarding. Use JSON requests with Content-Type: application/json. Hosted flows may require a browser redirect.

Authentication

POST/api/auth

Request example

{
    "username": "your-issued-username",
    "password": "your-issued-password"
}

Response example

{
    "access_token": "eyJ...",
    "token_type": "bearer",
    "expires_in": 3600
}
Authorization: Bearer eyJ...

Refresh an existing or recently expired token using POST /api/refresh.

Response envelope

Success

{
    "status": "success",
    "error": false,
    "message": "...",
    "data": {
        "...": "..."
    }
}

Request error

{
    "status": "failure",
    "error": true,
    "code": "VALIDATION_ERROR",
    "message": "..."
}

Payment declined

{
    "status": "failure",
    "error": true,
    "code": "CARD_PAYMENT_DECLINED",
    "paymentStatus": "DECLINED",
    "message": "Payment declined"
}

Hosted redirect

{
    "status": "success",
    "error": false,
    "message": "card capture required to complete the transaction",
    "type": "url",
    "paymentPageUrl": "https://.../capture/..."
}
HTTPMeaning
200Success or redirect required
402Issuer decline
400 / 401 / 403 / 404 / 409 / 422Request error

Key concepts

TermMeaning
bankMIDAcquirer, currency and gateway routing
cardIdFirst six and last four card digits; actual token remains with WEBXPAY
customer.idMerchant customer identifier; use consistent ID and email
CITCustomer actively initiates the payment
MITMerchant initiates a pre-agreed charge without customer presence

MIT and authenticated CIT require supported MPGS or CyberSource routing. Paycorp cannot perform token-level authentication or MIT.

Save card

POST/api/v2/merchant/hc/cards/save

Verify and tokenize a card through hosted checkout. The verification hold is reversed automatically.

FieldTypeRequirement / notes
currencystringRequired; matches bankMID
bankMIDstringRequired; issued MID
secure3dResponseURLstringRequired; browser return URL
customer.idstringRequired
customer.emailstringRequired
customer.firstNamestringRequired
customer.lastNamestringRequired
customer.contactNumberstringRequired
orderNumberstringOptional reference

Request example

{
    "currency": "LKR",
    "bankMID": "YOUR_BANK_MID",
    "secure3dResponseURL": "https://yourapp.com/payments/return",
    "customer": {
        "id": "2097",
        "email": "jane@example.com",
        "firstName": "Jane",
        "lastName": "Perera",
        "contactNumber": "+94771234567"
    }
}

Response example

{
    "status": "success",
    "error": false,
    "message": "card capture required to complete the transaction",
    "type": "url",
    "paymentPageUrl": "https://.../capture/..."
}

Browser callback

  1. Send the API request.
  2. Navigate the customer browser to paymentPageUrl.
  3. Complete hosted card entry and applicable 3-D Secure.
  4. Receive result3ds on secure3dResponseURL; base64-decode and parse the JSON outcome.

Decoded result3ds

{
    "status": "success",
    "error": false,
    "message": "Card verified and saved successfully",
    "instrument": "CARD",
    "paymentStatus": "APPROVED",
    "data": {
        "card": {
            "id": "4000002503",
            "cardFirst": "400000",
            "cardLast": "2503",
            "scheme": "VISA",
            "expiry": "0842",
            "dateAdded": "2026-08-06T12:35:00Z"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        },
        "refundStatus": true
    }
}

Retain data.card.id for subsequent card operations. For future MIT, collect consent before the customer leaves this flow.

Save & pay

POST/api/v2/merchant/hc/cards/saveandpay
FieldTypeRequirement / notes
currencystringRequired; matches bankMID
bankMIDstringRequired; issued MID
secure3dResponseURLstringRequired; browser return URL
customer.idstringRequired
customer.emailstringRequired
customer.firstNamestringRequired
customer.lastNamestringRequired
customer.contactNumberstringRequired
orderNumberstringRequired; unique
amountstringRequired; up to two decimal places

Request example

{
    "currency": "LKR",
    "bankMID": "YOUR_BANK_MID",
    "secure3dResponseURL": "https://yourapp.com/payments/return",
    "customer": {
        "id": "2097",
        "email": "jane@example.com",
        "firstName": "Jane",
        "lastName": "Perera",
        "contactNumber": "+94771234567"
    },
    "orderNumber": "ORD-1042",
    "amount": "1500.00"
}

Response example

{
    "status": "success",
    "error": false,
    "message": "card capture required to complete the transaction",
    "type": "url",
    "paymentPageUrl": "https://.../capture/..."
}

Browser callback

  1. Send the API request.
  2. Navigate the customer browser to paymentPageUrl.
  3. Complete hosted card entry and applicable 3-D Secure.
  4. Receive result3ds on secure3dResponseURL; base64-decode and parse the JSON outcome.

Decoded approved result

{
    "status": "success",
    "error": false,
    "message": "Card verified, saved and paid successfully",
    "instrument": "CARD",
    "orderNumber": "ORD-1030",
    "webxOrderReference": "T64925...",
    "merchantProvidedOrderNumber": "ORD-1030",
    "paymentStatus": "APPROVED",
    "receipt": "016153...",
    "amount": "1500.00",
    "data": {
        "card": {
            "id": "4000002503",
            "cardFirst": "400000",
            "cardLast": "2503",
            "scheme": "VISA",
            "expiry": "0842",
            "dateAdded": "2026-08-06T12:35:00Z"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        },
        "refundStatus": true
    }
}

Decoded declined result

{
    "status": "failure",
    "error": true,
    "code": "CARD_PAYMENT_DECLINED",
    "paymentStatus": "DECLINED",
    "message": "Payment declined",
    "data": {
        "card": {
            "id": "4000002503",
            "cardFirst": "400000",
            "cardLast": "2503",
            "scheme": "VISA",
            "expiry": "0842",
            "dateAdded": "2026-08-06T12:35:00Z"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        }
    }
}

A declined initial charge does not remove the saved card.

Pay once (no save)

POST/api/v2/merchant/hc/cards/pay-onetime
FieldTypeRequirement / notes
currencystringRequired; matches bankMID
bankMIDstringRequired; issued MID
secure3dResponseURLstringRequired; browser return URL
customer.idstringRequired
customer.emailstringRequired
customer.firstNamestringRequired
customer.lastNamestringRequired
customer.contactNumberstringRequired
orderNumberstringRequired; unique
amountstringRequired; up to two decimal places

Request example

{
    "currency": "LKR",
    "bankMID": "YOUR_BANK_MID",
    "secure3dResponseURL": "https://yourapp.com/payments/return",
    "customer": {
        "id": "2097",
        "email": "jane@example.com",
        "firstName": "Jane",
        "lastName": "Perera",
        "contactNumber": "+94771234567"
    },
    "orderNumber": "ORD-1042",
    "amount": "1500.00"
}

Response example

{
    "status": "success",
    "error": false,
    "message": "card capture required to complete the transaction",
    "type": "url",
    "paymentPageUrl": "https://.../capture/..."
}

Browser callback

  1. Send the API request.
  2. Navigate the customer browser to paymentPageUrl.
  3. Complete hosted card entry and applicable 3-D Secure.
  4. Receive result3ds on secure3dResponseURL; base64-decode and parse the JSON outcome.

Decoded approved result

{
    "status": "success",
    "error": false,
    "message": "Payment completed successfully",
    "instrument": "CARD",
    "orderNumber": "ORD-1042",
    "webxOrderReference": "T64925...",
    "merchantProvidedOrderNumber": "ORD-1042",
    "paymentStatus": "APPROVED",
    "receipt": "016153...",
    "amount": "1500.00",
    "data": {
        "card": {
            "cardFirst": "400000",
            "cardLast": "2503",
            "cardExpiry": "0842",
            "scheme": "VISA"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        }
    }
}

Decoded declined result

{
    "status": "failure",
    "error": true,
    "code": "CARD_PAYMENT_DECLINED",
    "paymentStatus": "DECLINED",
    "message": "Payment declined",
    "instrument": "CARD",
    "orderNumber": "ORD-1042",
    "merchantProvidedOrderNumber": "ORD-1042",
    "data": {
        "card": {
            "cardFirst": "400000",
            "cardLast": "2503",
            "cardExpiry": "0842",
            "scheme": "VISA"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        }
    }
}

No reusable cardId or refundStatus is returned. Choose Save & pay if future saved-card charges are needed.

Pay — customer present (CIT)

POST/api/v2/merchant/hc/cards/pay
FieldTypeRequirement / notes
cardIdstringRequired
amountstringRequired; up to two decimal places
orderNumberstringRequired; unique
currencystringRequired
bankMIDstringRequired
customer.idstringRequired; matches saved card
customer.emailstringRequired
secure3dResponseURLstringRequired even without authenticated CIT
authenticationRequiredbooleanOptional; request live authentication

Request example

{
    "cardId": "4000002503",
    "amount": "1500.00",
    "orderNumber": "ORD-1030",
    "currency": "LKR",
    "bankMID": "YOUR_BANK_MID",
    "secure3dResponseURL": "https://yourapp.com/payments/return",
    "customer": {
        "id": "2097",
        "email": "jane@example.com"
    }
}

Approved · HTTP 200

{
    "status": "success",
    "error": false,
    "message": "Payment completed successfully",
    "instrument": "CARD",
    "orderNumber": "ORD-1030",
    "webxOrderReference": "T64925...",
    "merchantProvidedOrderNumber": "ORD-1030",
    "paymentStatus": "APPROVED",
    "receipt": "016153...",
    "amount": "1500.00",
    "data": {
        "card": {
            "cardFirst": "400000",
            "cardLast": "2503",
            "cardExpiry": "0842",
            "scheme": "VISA"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        }
    }
}

Declined · HTTP 402

{
    "status": "failure",
    "error": true,
    "code": "CARD_PAYMENT_DECLINED",
    "paymentStatus": "DECLINED",
    "message": "Payment declined",
    "instrument": "CARD",
    "orderNumber": "ORD-1030",
    "webxOrderReference": "T64925...",
    "merchantProvidedOrderNumber": "ORD-1030",
    "receipt": null,
    "data": {
        "card": {
            "cardFirst": "400000",
            "cardLast": "2503",
            "cardExpiry": "0842",
            "scheme": "VISA"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        }
    }
}

Authenticated CIT

Where enabled, MPGS and CyberSource can return a frictionless result or require a live issuer challenge. To request authentication for one payment, set authenticationRequired to true. Explicit authentication on Paycorp fails with CIT_AUTHENTICATION_UNSUPPORTED_GATEWAY; merchant-wide enablement alone does not change Paycorp's stored-credential flow.

Request example

{
    "cardId": "4000002503",
    "amount": "1500.00",
    "orderNumber": "ORD-1030",
    "currency": "LKR",
    "bankMID": "YOUR_BANK_MID",
    "secure3dResponseURL": "https://yourapp.com/payments/return",
    "customer": {
        "id": "2097",
        "email": "jane@example.com"
    },
    "authenticationRequired": true
}

Step-up required · HTTP 200

{
    "status": "success",
    "error": false,
    "message": "3DS redirect required to complete the transaction",
    "orderNumber": "ORD-1030",
    "type": "3ds",
    "html3ds_url": "https://.../webx/3ds/..."
}

Navigate the browser to html3ds_url, then decode result3ds at your return URL. Authentication failure or cancellation arrives in the callback, not as a synchronous HTTP 402.

Approved callback

{
    "status": "success",
    "error": false,
    "message": "Payment completed successfully",
    "instrument": "CARD",
    "orderNumber": "ORD-1030",
    "webxOrderReference": "T64925...",
    "merchantProvidedOrderNumber": "ORD-1030",
    "paymentStatus": "APPROVED",
    "receipt": "016153...",
    "amount": "1500.00",
    "data": {
        "card": {
            "cardFirst": "400000",
            "cardLast": "2503",
            "cardExpiry": "0842",
            "scheme": "VISA"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        }
    }
}

Failed callback

{
    "status": "failure",
    "error": true,
    "code": "CARD_AUTHENTICATION_FAILED",
    "message": "3DS authentication failed or cancelled",
    "instrument": "CARD",
    "orderNumber": "ORD-1030",
    "merchantProvidedOrderNumber": "ORD-1030"
}

Pay — no customer present (MIT)

POST/api/v2/merchant/hc/cards/pay-mit

Requires merchant MIT enablement, an acquiring-bank recurring/installment agreement, MPGS or CyberSource routing, and a stored reference transaction. No browser redirect is possible.

FieldTypeRequirement / notes
cardIdstringRequired
amountstringRequired; up to two decimal places
orderNumberstringRequired; unique
currencystringRequired
bankMIDstringRequired
customer.idstringRequired; matches saved card
customer.emailstringRequired
mitReasonstringRequired: recurring, installment or unscheduled

Request example

{
    "cardId": "4000002503",
    "amount": "1500.00",
    "orderNumber": "ORD-1030",
    "currency": "LKR",
    "bankMID": "YOUR_BANK_MID",
    "customer": {
        "id": "2097",
        "email": "jane@example.com"
    },
    "mitReason": "recurring"
}
mitReasonUsage
recurringFixed schedule subscription
installmentAgreed split payment plan
unscheduledOccasional agreed card-on-file billing

Consent and subscription workflow

  1. Disclose billing terms and collect explicit consent before saving the card.
  2. Retain consent text, timestamp and contextual evidence; obtain renewed consent when terms change.
  3. Store the cardId from Save card or Save & pay.
  4. Submit a unique orderNumber for each renewal and the appropriate mitReason.
  5. Handle declines outside checkout; ask the customer to return for CIT or card re-saving if needed.

WEBXPAY retains reference transactions automatically after successful verification or charges. Older cards missing a reference must be saved again. Expired cards and issuer requests for interactive authentication can lead to failure. Paycorp is unsupported.

Synchronous approved response (same shape as CIT)

{
    "status": "success",
    "error": false,
    "message": "Payment completed successfully",
    "instrument": "CARD",
    "orderNumber": "ORD-1030",
    "webxOrderReference": "T64925...",
    "merchantProvidedOrderNumber": "ORD-1030",
    "paymentStatus": "APPROVED",
    "receipt": "016153...",
    "amount": "1500.00",
    "data": {
        "card": {
            "cardFirst": "400000",
            "cardLast": "2503",
            "cardExpiry": "0842",
            "scheme": "VISA"
        },
        "customer": {
            "id": "2097",
            "email": "jane@example.com"
        }
    }
}

Synchronous decline

{
    "status": "failure",
    "error": true,
    "code": "CARD_PAYMENT_DECLINED",
    "paymentStatus": "DECLINED",
    "message": "Payment declined"
}

List saved cards

POST/api/v2/merchant/cards/get
FieldTypeRequirement / notes
customer.idstringRequired
customer.emailstringRequired

Request example

{
    "customer": {
        "id": "2097",
        "email": "jane@example.com"
    }
}

Response example

{
    "status": "success",
    "error": false,
    "message": "Cards retrieved successfully",
    "instrument": "CARD",
    "customer": {
        "id": "2097",
        "email": "jane@example.com"
    },
    "data": {
        "cards": [
            {
                "bankMID": "YOUR_BANK_MID",
                "cardId": "4000002503",
                "cardFirst": "400000",
                "cardLast": "2503",
                "cardExpiry": "0842",
                "cardScheme": "VISA"
            }
        ]
    }
}

Expired cards may include an extra note field.

Delete a card

DELETE/api/v2/merchant/cards/delete
FieldTypeRequirement / notes
cardIdstringRequired
customerIdstringRequired; flat field
customerEmailstringRequired; flat field
bankMIDstringRequired when multiple matches exist

Request example

{
    "cardId": "4000002503",
    "customerId": "2097",
    "customerEmail": "jane@example.com"
}

Response example

{
    "status": "success",
    "error": false,
    "message": "Card deleted successfully",
    "instrument": "CARD",
    "customerId": "2097",
    "cardId": "4000002503"
}

Deletion is permanent. For CARD_MULTIPLE_MATCHES, specify bankMID.

Error codes

CodeHTTPMeaning
UNAUTHORIZED401Invalid or expired bearer token
VALIDATION_ERROR422Missing or malformed field
INVALID_MID422Invalid or inactive MID
CURRENCY_VALIDATION_FAILED422Currency does not match MID
MERCHANT_NOT_FOUND404Merchant unavailable
ORDER_NUMBER_DUPLICATE409Order reference already used
CARD_NOT_FOUND404No matching saved card
CARD_EXPIRED422Card expired
CARD_PAYMENT_DECLINED402Issuer decline
CARD_MULTIPLE_MATCHES409Specify bankMID on deletion
CARD_DELETE_FAILED422Gateway rejected deletion
CIT_AUTHENTICATION_UNSUPPORTED_GATEWAY422Token authentication unsupported
CARD_3DS_INITIATE_FAILED422Could not initiate 3DS
CARD_3DS_AUTHENTICATION_FAILED422Gateway rejected authentication
CARD_3DS_UNSUPPORTED_TOKEN422CyberSource card must be saved again
CARD_AUTHENTICATION_FAILEDCallbackChallenge failed or abandoned
MIT_NOT_ENABLED403Merchant MIT not enabled
MIT_UNSUPPORTED_GATEWAY422Unsupported gateway
MIT_NO_REFERENCE_TRANSACTION422Save card again to establish reference

Original integration reference →