2. Foreign exchange peer to peer currency exchange

Introduction

A peer-to-peer (p2p) currency exchange is where a profile sells currency A to another profile in exchange for currency B.

For example, profile 1 sells 100 GBP to profile 2 in exchange for 115 EUR.

  • Profile 1 GBP balance falls by 100 and profile 2 GBP balance increases by 100.
  • Profile 2 EUR balance falls by 115 and profile 1 EUR balance increases by 115.

It is, in essence, two wallet-to-wallet payments – one in currency A and one in currency B. Customate does not go to the foreign exchange market to exchange currencies.

Profile 2 is called the counterparty. The counterparty payee_id must be in currency B.

The counterparty_amount will be calculated from the amount and exchange_rate.

How to execute a peer to peer currency exchange

Call the p2p_currency_exchange endpoint.

Provide the following mandatory parameters:

  • amount
  • currency to sell
  • exchange rate
  • Payee_id being the counterpart that is being exchanged with

execution date, description and metadata are optional.

Example JSON create P2P Currency Exchange (request):
{
  "amount": 10000,
  "currency_to_sell": "GBP",
  "exchange_rate": 1.1890121,
  "payee_id": "cfcd44ad-12d5-4362-a669-2da49b9c6c52",
  "execution_date": "2022-08-31",
  "description": "Exchange 100 GBP for Euros",
  "metadata": {
    "sample_internal_id": "d2f148cf-901c-4fee-8792-21016da755a0"
  }
}

 

Example JSON Create P2P Currency Exchange (response):
{
  "id": "fa070d93-8cf3-4b2e-b7fc-c12454ea8087",
  "creation_datetime": "2022-09-22T10:23:24.921034Z",
  "status": "pending",
  "type": "p2p",
  "funding_source_id": "a9c7dfad-365f-43cc-805e-acd7ac9d939c",
  "amount": 10000,
  "currency_to_sell": "GBP",
  "exchange_rate": 1.1890121,
  "currency_to_buy": "EUR",
  "counterparty_amount": 118901,
  "payee_id": "f34708b4-2859-48d5-afb4-71842fb5791c",
  "execution_date": "2022-09-22T10:23:24.921034Z",
  "description": "Exchange 100 GBP for Euros",
  "metadata": {
    "sample_internal_id": "d2f148cf-901c-4fee-8792-21016da755a0"
  }
}