Skip to main content

Payment Verification

After a callback is received, You can use the tnx provided earlier, to lookup and reassure the payment status.

SPG Lookups​

Learn how to verify the status of a payment transaction using the SwiftPay API. You can look up a transaction using the tnx (transaction ID) returned from the initiation request.

Base URL​

https://pay.raisa.com.np

Verification Endpoint​

URLMethodAuthorizationFormat
api/v1/lookupPOSTRequiredapplication/json

Headers Required​

  • x-swiftpay-token: Your SwiftPay API token
  • x-swiftpay-environment: API environment (production or sandbox)
  • Content-Type: application/json

Request Data​

{
"tnx": "SWIFTPAY-8AC2389A-ACF2-47A9-8D4B-CEA68E931DD8-EWP"
}

Implementation Examples​

curl --location 'https://pay.raisa.com.np/api/v1/lookup' \
--header 'x-swiftpay-token: YOUR_SWIFTPAY_TOKEN' \
--header 'x-swiftpay-environment: production' \
--header 'Content-Type: application/json' \
--data '{
"tnx": "SWIFTPAY-8AC2389A-ACF2-47A9-8D4B-CEA68E931DD8-EWP"
}'

Response Example​

{
"tnx": "SWIFTPAY-8AC2389A-ACF2-47A9-8D4B-CEA68E931DD8-EWP",
"amount": "500.00",
"status": "preparing",
"transaction": "YOUR_TRANSACTION_ID",
"environment": "production",
"fee": "14.50",
"refunded": false
}

Payment Status Code​

StatusStatus Code
Completed200
Pending200
Expired400
Initiated200
Refunded200
User canceled400
Partially refunded400

Lookup Payload Details​

StatusDescription
tnxThis is the payment id of the transaction.
amountThis is the total amount of the transaction
statusCompleted - Transaction is success
Pending - Transaction is failed or is in pending state
Refunded - Transaction has been refunded
Expired - This payment link has expired
User canceled - Transaction has been canceled by the user
Partially refunded - Transaction has been partially refunded by the user
transactionThis is the transaction id for the transaction from merchant.
This is the unique identifier.
feeThe fee that has been set for the merchant.
refundedTrue - The transaction has been refunded.
False - The transaction has not been refunded.

Lookup status​

FieldDescription
CompletedProvide service to user.
PendingHold, do not provide service. And contact SwiftPay team.
RefundedTransaction has been refunded to user. Do not provide service.
ExpiredUser have not made the payment, Do not provide the service.
User canceledUser have canceled the payment, Do not provide the service.
Important note
  • Only the status with Completed must be treated as success.
  • Status Canceled , Expired , Failed must be treated as failed.
  • If any negative consequences occur due to incomplete API integration or providing service without checking lookup status, SwiftPay won’t be accountable for any such losses.
  • For status other than these, hold the transaction and contact SwiftPay team.
  • Payment link expires in 30 minutes in production and sandbox.

Error Handling​

The API may return the following status codes:

  • 200: Success
  • 400: Bad Request
  • 401: Unauthorized
  • 404: Transaction not found
  • 500: Server Error

Make sure to implement proper error handling in your code to handle these responses appropriately.

Generic Errors​

This document outlines the possible error responses you may encounter when using the SwiftPay API. All error responses follow a consistent format and include appropriate HTTP status codes.

Error Response Format​

{
"error": "Error message description",
"code": 4XX
}

Error Types​

Environment Errors (400 Bad Request)​

{
"error": "Invalid environment. Must be production or sandbox.",
"code": 400
}

Occurs when the x-swiftpay-environment header value is neither 'production' nor 'sandbox'.

Authentication Errors (401 Unauthorized)​

Invalid Token​

{
"error": "Invalid or missing token.",
"code": 401
}

Occurs when the provided x-swiftpay-token is invalid or missing.

Merchant Verification​

{
"error": "Unverified Merchant",
"code": 401
}

Occurs when the merchant's business status is not verified.

Authorization Errors​

Private Token Issues​

{
"error": "User does not have the required private attribute.",
"code": 403
}
{
"error": "Invalid private token.",
"code": 403
}

Occurs during payment initiation when there are issues with the private token.

Public Token Issues​

{
"error": "User does not have the required public attribute.",
"code": 403
}
{
"error": "Invalid public token.",
"code": 403
}

Occurs during payment verification when there are issues with the public token.