Finswich Public APIs
  • INTEGRATING via CHECKOUT
    • Getting Started/Overview
    • Integrating the Checkout on your App (Frontend)
      • Integrating Finswich checkout via NPM or Yarn
      • Integrating the Finswich Checkout on your Vanilla Javascript app
      • Steps for integrating Finswich Checkout via Flutter
      • Pseudocode for Integrating Finswich Checkout in Application (Native iOS & Android)
    • Authentication
    • User Onboarding
    • Error Handling
    • Integrating the Services (Backend)
      • Interwallet Transfer
      • Bank Transfer
      • Funding
      • Utility Purchases
Powered by GitBook
On this page
  • FOR INCOMING TRANSACTIONS/FUNDING
  • TRANSACTION FLOW EVENTS
  1. INTEGRATING via CHECKOUT
  2. Integrating the Services (Backend)

Funding

PreviousBank TransferNextUtility Purchases

Last updated 1 year ago

This page describes the how funding works and how to set up your app to be funded using the Finswich Checkout

FOR INCOMING TRANSACTIONS/FUNDING

An incoming transaction is a kind of transaction where users on your platform receives money between into wallet from other wallets, banks or other countries or a funding activity. This is what we refer to as an incoming transactions.

BEFORE INTEGRATION - DO THIS

Before you begin any integration you need to have created an incoming URL endpoint where all request between Finswich & your application will take place for interactions and notifications of incoming transactions. See Below for Image reference

TRANSACTION FLOW EVENTS

  1. User Category: this is used to ensure that the recipient user has the right policy setup to receive the incoming transaction

Req Body

{"event":"USER_CATEGORY","data":{"user_reference":"saudiemcode001","mode":"LIVE"}}

Sample Code on third party

      if (body.event === 'USER_CATEGORY') {

          const user = await this.user_repository.FindById(
            body.data.user_reference,
            [
              '-permissions',
              '-settings',
              '-recovery_keys',
              '-contigency_lock_expires',
              '-contigency_level',
              '-verification_code',
            ],
          );

          return {
            status: 'success',
            message: 'User category sent!',
            data: {
              user_category: body.data.user_reference,
              user,
            },
          };
        }

Credit Transactions Events -Once there is a credit to your Finswich wallet, the notifications will be posted to your incoming webhook URL. you can use the data to update your user’s wallet balance on your application.

Req Body

{"event":"CREDIT_TRANSACTION","data":{"user_reference":"saudiemcode001","amount"10,"currency":"sar","transaction_reference":"FIN-DXVb1CpC6jnTXkqJ1682607236","quarantine":false,"mode":"LIVE"}}
 if (body.event === 'CREDIT_TRANSACTION') {
          //! consider crediting your wallet here
          const credit_model = {
            txn_reference: body.data.txn_reference,
            user_reference: body.data.user_reference,
            amount: body.data.amount,
            currency: body.data.currency,
          };

          const wallet = await this.wallet_repository.FindByUserId(
            credit_model.user_reference,
          );

          if (!wallet) {
            throw new notFoundException(en['wallet-not-found']);
          }

          await this.finswich_txn_logs_repository.CreateTxnLogs({
            txn_reference: credit_model.txn_reference,
            amount: credit_model.amount,
            currency: credit_model.currency,
            user: credit_model.user_reference,
            wallet_id: wallet.id,
            type: 'incoming',
            status: 'success',
          });

          await this.wallet_repository.IncreaseBalance(
            credit_model.user_reference,
            credit_model.amount,
          );

          await this.wallet_repository.UpdateById(
            wallet.id,
            {},
            { total_incoming: credit_model.amount },
          );

          return {
            status: 'success',
            message: en['user-account-credited-success'],
          };
        } else {
          throw badRequestException(en['user-account-credited-failure']);
        }

Setting up the incoming webhook URL