SwiftPay Payment Gateway (SPG)

website·Indexed 30 days ago

https://docs.raisa.com.np

Documentation for the SwiftPay payment gateway, featuring guides on e-Payment Checkout implementation, Refund API processing, payment verification via SPG Lookups, and merchant signup procedures.

Tokens
4.3K
Snippets
29
Records
40
Agent score
50%

What's inside SwiftPay

  1. Overview of SwiftPay Payment Gateway (SPG)

    SwiftPay Payment Gateway (SPG) is a payment solution, digital wallet, and API provider for web and mobile applications operating in Nepal. It acts as a single integration point to accept payments from multiple sources, eliminating the need to integrate with individual banks. Supported payment sources include:

    • SwiftPay users
    • Partner bank eBanking users
    • Partner bank mobile banking users
    • SCT/VISA card holders
    • connectIPS users
  2. Transition SwiftPay integration from Sandbox to Production

    To go live with SwiftPay, follow these steps:

    1. Thoroughly test all flows in the sandbox environment.
    2. Submit the integration for technical review by the SwiftPay team.
    3. Upon approval, replace your sandbox API token with the production token.
    4. Update the x-swiftpay-environment header from sandbox to production.
    5. Perform at least one live test transaction to verify the production setup.
    # Production environment configuration
    curl --location 'https://pay.raisa.com.np/api/v1/initiate' \
      --header 'x-swiftpay-token: YOUR-PRODUCTION-PRIVATE-TOKEN' \
      --header 'x-swiftpay-environment: production'
  3. Develop and test features in SwiftPay

    Create a dedicated branch for your changes (using feature/ or fix/ prefixes). Use the development server to verify changes and run the test suite to ensure stability.
    # Create a new branch
    git checkout -b feature/your-feature-name
    # or
    git checkout -b fix/your-bug-fix
    
    # Start development server
    npm run dev   # or yarn dev
    
    # Run tests
    npm test      # or yarn test
  4. Initiate a new payment with SwiftPay

    To start a payment process, send a POST request to /api/v1/initiate. You must provide a callback URL, your website domain, the amount in Rupees, and a unique transaction identifier.

    Constraint: The hostname of the callback URL must match the domain URL (e.g., if domain is https://example.com, the callback cannot be https://api.example.com/callback).

    const payload = {
      callback: 'https://your-domain.com/callback',
      domain: 'https://your-domain.com',
      amount: 1000, // Amount in Rupees
      transaction: 'YOUR_UNIQUE_TRANSACTION_ID'
    };
    
    const response = await fetch('https://pay.raisa.com.np/api/v1/initiate', {
      method: 'POST',
      headers: headers,
      body: JSON.stringify(payload)
    });
  5. Check payment status using Transaction Lookup

    Verify the status of a payment by sending a POST request to /api/v1/lookup using the tnx (transaction ID) returned during the initiation phase.
    const response = await fetch('https://pay.raisa.com.np/api/v1/lookup', {
      method: 'POST',
      headers: headers,
      body: JSON.stringify({ tnx: 'TRANSACTION_ID' })
    });
  6. Process refunds using the SwiftPay Refund API

    The Refund API allows merchants to process full refunds for successfully completed transactions. Refunds return the full amount to the sender's wallet.

    Constraints and Requirements:

    • Only transactions with a status of 'Completed' can be refunded.
    • Refunds must be initiated within 30 days of the original transaction.
    • A transaction can only be refunded once.
    • The merchant must have a sufficient balance to cover the refund.
    • Merchants are required to refund the full amount to the customer (including deducted fees) and bear the service charges.
    • In the sandbox environment, refunds do not affect actual wallet balances.
  7. Provide required information for faster SwiftPay support resolution

    When contacting SwiftPay support, include the following details to ensure a faster resolution of your issue:
    1. Merchant ID
    2. Environment (Sandbox/Production)
    3. Transaction ID (if applicable)
    4. Error message or screenshots
    5. Steps to reproduce the issue
  8. Set up a local development environment for SwiftPay

    To contribute to SwiftPay, fork the repository and set up your local environment by cloning your fork, adding the original repository as an upstream remote, and installing dependencies.
    # Clone your fork
    git clone https://github.com/nb3n/swiftpay-docs
    cd swiftpay-docs
    
    # Add upstream remote
    git remote add upstream https://github.com/original/swiftpay-docs.git
    
    # Install dependencies
    npm install   # or yarn install
  9. Submit changes to SwiftPay via Pull Request

    After committing your changes, submit a Pull Request with a descriptive title, relevant issue numbers, and a detailed description. For UI changes, include screenshots. Maintainers typically review PRs within 3-5 business days.
    git add .
    git commit -m "feat(ui): add new payment button"