Hosted/Token Integration
Hosted card entry, one-time payments and saved-card transactions.
Start integration →Overview
| Environment | Base URL |
|---|---|
| Sandbox | https://{sandbox-host}/api |
| Production | https://{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
/api/authRequest 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/..."
}| HTTP | Meaning |
|---|---|
| 200 | Success or redirect required |
| 402 | Issuer decline |
| 400 / 401 / 403 / 404 / 409 / 422 | Request error |
Key concepts
| Term | Meaning |
|---|---|
| bankMID | Acquirer, currency and gateway routing |
| cardId | First six and last four card digits; actual token remains with WEBXPAY |
| customer.id | Merchant customer identifier; use consistent ID and email |
| CIT | Customer actively initiates the payment |
| MIT | Merchant 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
/api/v2/merchant/hc/cards/saveVerify and tokenize a card through hosted checkout. The verification hold is reversed automatically.
| Field | Type | Requirement / notes |
|---|---|---|
| currency | string | Required; matches bankMID |
| bankMID | string | Required; issued MID |
| secure3dResponseURL | string | Required; browser return URL |
| customer.id | string | Required |
| customer.email | string | Required |
| customer.firstName | string | Required |
| customer.lastName | string | Required |
| customer.contactNumber | string | Required |
| orderNumber | string | Optional 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
- Send the API request.
- Navigate the customer browser to paymentPageUrl.
- Complete hosted card entry and applicable 3-D Secure.
- 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
/api/v2/merchant/hc/cards/saveandpay| Field | Type | Requirement / notes |
|---|---|---|
| currency | string | Required; matches bankMID |
| bankMID | string | Required; issued MID |
| secure3dResponseURL | string | Required; browser return URL |
| customer.id | string | Required |
| customer.email | string | Required |
| customer.firstName | string | Required |
| customer.lastName | string | Required |
| customer.contactNumber | string | Required |
| orderNumber | string | Required; unique |
| amount | string | Required; 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
- Send the API request.
- Navigate the customer browser to paymentPageUrl.
- Complete hosted card entry and applicable 3-D Secure.
- 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)
/api/v2/merchant/hc/cards/pay-onetime| Field | Type | Requirement / notes |
|---|---|---|
| currency | string | Required; matches bankMID |
| bankMID | string | Required; issued MID |
| secure3dResponseURL | string | Required; browser return URL |
| customer.id | string | Required |
| customer.email | string | Required |
| customer.firstName | string | Required |
| customer.lastName | string | Required |
| customer.contactNumber | string | Required |
| orderNumber | string | Required; unique |
| amount | string | Required; 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
- Send the API request.
- Navigate the customer browser to paymentPageUrl.
- Complete hosted card entry and applicable 3-D Secure.
- 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)
/api/v2/merchant/hc/cards/pay| Field | Type | Requirement / notes |
|---|---|---|
| cardId | string | Required |
| amount | string | Required; up to two decimal places |
| orderNumber | string | Required; unique |
| currency | string | Required |
| bankMID | string | Required |
| customer.id | string | Required; matches saved card |
| customer.email | string | Required |
| secure3dResponseURL | string | Required even without authenticated CIT |
| authenticationRequired | boolean | Optional; 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)
/api/v2/merchant/hc/cards/pay-mitRequires merchant MIT enablement, an acquiring-bank recurring/installment agreement, MPGS or CyberSource routing, and a stored reference transaction. No browser redirect is possible.
| Field | Type | Requirement / notes |
|---|---|---|
| cardId | string | Required |
| amount | string | Required; up to two decimal places |
| orderNumber | string | Required; unique |
| currency | string | Required |
| bankMID | string | Required |
| customer.id | string | Required; matches saved card |
| customer.email | string | Required |
| mitReason | string | Required: 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"
}| mitReason | Usage |
|---|---|
| recurring | Fixed schedule subscription |
| installment | Agreed split payment plan |
| unscheduled | Occasional agreed card-on-file billing |
Consent and subscription workflow
- Disclose billing terms and collect explicit consent before saving the card.
- Retain consent text, timestamp and contextual evidence; obtain renewed consent when terms change.
- Store the cardId from Save card or Save & pay.
- Submit a unique orderNumber for each renewal and the appropriate mitReason.
- 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
/api/v2/merchant/cards/get| Field | Type | Requirement / notes |
|---|---|---|
| customer.id | string | Required |
| customer.email | string | Required |
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
/api/v2/merchant/cards/delete| Field | Type | Requirement / notes |
|---|---|---|
| cardId | string | Required |
| customerId | string | Required; flat field |
| customerEmail | string | Required; flat field |
| bankMID | string | Required 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
| Code | HTTP | Meaning |
|---|---|---|
| UNAUTHORIZED | 401 | Invalid or expired bearer token |
| VALIDATION_ERROR | 422 | Missing or malformed field |
| INVALID_MID | 422 | Invalid or inactive MID |
| CURRENCY_VALIDATION_FAILED | 422 | Currency does not match MID |
| MERCHANT_NOT_FOUND | 404 | Merchant unavailable |
| ORDER_NUMBER_DUPLICATE | 409 | Order reference already used |
| CARD_NOT_FOUND | 404 | No matching saved card |
| CARD_EXPIRED | 422 | Card expired |
| CARD_PAYMENT_DECLINED | 402 | Issuer decline |
| CARD_MULTIPLE_MATCHES | 409 | Specify bankMID on deletion |
| CARD_DELETE_FAILED | 422 | Gateway rejected deletion |
| CIT_AUTHENTICATION_UNSUPPORTED_GATEWAY | 422 | Token authentication unsupported |
| CARD_3DS_INITIATE_FAILED | 422 | Could not initiate 3DS |
| CARD_3DS_AUTHENTICATION_FAILED | 422 | Gateway rejected authentication |
| CARD_3DS_UNSUPPORTED_TOKEN | 422 | CyberSource card must be saved again |
| CARD_AUTHENTICATION_FAILED | Callback | Challenge failed or abandoned |
| MIT_NOT_ENABLED | 403 | Merchant MIT not enabled |
| MIT_UNSUPPORTED_GATEWAY | 422 | Unsupported gateway |
| MIT_NO_REFERENCE_TRANSACTION | 422 | Save card again to establish reference |