Skip to main content

Payment Refund

The Refund API enables merchants to process refunds for completed transactions. Refunds are applicable exclusively to transactions that have been successfully completed. The refund will return the full amount to the sender's wallet.

Prerequisites​

  • Refunds are only allowed within 30 days of the original transaction
  • You must have sufficient balance to process the refund
  • A transaction can only be refunded once
  • Refunds in sandbox environment won't affect actual wallet balances
  • Only completed transactions can be refunded

Integration Steps​

Base URL​

https://pay.raisa.com.np

Verification Endpoint​

URLMethodAuthorizationFormat
api/v1/refundPOSTRequiredapplication/json

Headers Required​

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

Request Parameters​

ParameterTypeRequiredDescription
tnxstringYesThe transaction ID to refund

Request Data​

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

Implementation Examples​

curl --location 'https://pay.raisa.com.np/api/v1/refund' \
--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"
}'
Important

The merchant is required to refund the full amount to the customer, including any deducted fees, and bear the service charges on their end.

Response Examples​

{
"tnx": "TXN123456789",
"amount": 100.00,
"status": "refunded",
"transaction": "Payment for order #123",
"environment": "production",
"fee": 2.50,
"refunded": true
}

Response Codes​

CodeDescription
200Refund successful
400Invalid request or business validation failed
401Authentication token missing
403Invalid token or merchant not found
404Transaction not found
422Validation failed
500Server error

Refund 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.
Important note
  • Only the status with Completed or Refunded 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, refund 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 transaction when there are issues with the public token.