# Transfer Funds Between Accounts

A transfer is the action of moving funds from the platfrom's account to any of it's vendors accounts.\
Funds will be available to transfer only if they are in the payable balance of the platform's account. The transferred funds will be available to the vendor immediately.

**Creating a transfer consist of 2 phases:**

1. Create the transfer 
2. Commit / Cancel the transfer 

> 🚧 Trasfers work only in one direction (from platform to vendor) and are not reversable once commited.

## Before You Begin

* Make sure you have the relevant account ID 
* Make sure you have the correct Vendor ID 

## Create transfer

Make a [POST /transfer ](https://docs.unipaas.com/reference#transfercontroller_createtransfer)request: 

```curl
curl --request POST \
  --url 'https://sandbox.unipaas.com/platform/transfers' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <PLATFORM_SECRET_KEY>' \
  --data-raw '{
         "ewalletId": "123456",
         "amount": 100,
         "currency": "GBP",
         "creditedVendorId": "abcdefg"
}'
```

In the response, you'll get the created transfer object: 

## Transfer object

<table>
  <thead>
    <tr>
      <th>
        Parameter
      </th>

      <th>
        Type
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        'id'
      </td>

      <td>
        Number
      </td>

      <td>
        Unique id of transfer object
      </td>
    </tr>

    <tr>
      <td>
        'ewallet\_id'
      </td>

      <td>
        String
      </td>

      <td>
        Account id of the transfer destination
      </td>
    </tr>

    <tr>
      <td>
        'amount'
      </td>

      <td>
        Number
      </td>

      <td>
        The amount of funds you wish to transfer
      </td>
    </tr>

    <tr>
      <td>
        'currency'
      </td>

      <td>
        Enum
      </td>

      <td>
        The currency in which the transfer is made
      </td>
    </tr>

    <tr>
      <td>
        'creditedVendorId'
      </td>

      <td>
        string
      </td>

      <td>
        The vendot ID to which you wish to transfer monay
      </td>
    </tr>

    <tr>
      <td>
        'status'
      </td>

      <td>
        Enum
      </td>

      <td>
        Payout's status: 'Pending', 'Succeeded', 'Failed'.  ?
      </td>
    </tr>

    <tr>
      <td>
        merchantId
      </td>

      <td>
        string
      </td>

      <td>
        The ID of the platform, from which the transfer is made
      </td>
    </tr>

    <tr>
      <td>
        vendorId
      </td>

      <td>
        string
      </td>

      <td>
        ?
      </td>
    </tr>
  </tbody>
</table>

## Commit or Cancel Transfer

Once the transfer was created, you should make a commit transfer call, to trigger the actual transfer of funds. If you do not want to proceed with the created transfer, you can cancel it by making a cancel transfer call.

## Commit Transfer

Make a [POST /transfer/commit ](https://docs.unipaas.com/reference#transfercontroller_committransfer) request:

```curl
curl --request POST \
  --url 'https://sandbox.unipaas.com/transfers/{transferId}/commit' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <PLATFORM_SECRET_KEY>' \
```

in the response, you'll get the [committed Transfer object](https://docs.unipaas.com/docs/transfer-between-ewallets#transfer-object).

## Cancel Transfer

Make a [POST /transfers/cancel ](https://docs.unipaas.com/reference#transfercontroller_canceltransfer)request:

```curl
curl --request POST \
  --url 'https://sandbox.unipaas.com/platform/transfers/{transferId}/cancel
' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <PLATFORM_SECRET_KEY>' \
```

in the response, you'll get the cancelled [Transfer object](https://docs.unipaas.com/docs/transfer-between-ewallets#transfer-object).
