Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Project] TransferWise Automated Payout #2836

Open
kewitz opened this issue Jan 21, 2020 · 7 comments
Open

[Project] TransferWise Automated Payout #2836

kewitz opened this issue Jan 21, 2020 · 7 comments
Assignees
Milestone

Comments

@kewitz
Copy link

@kewitz kewitz commented Jan 21, 2020

TransferWise has a straight-forward API implementation that allows Business Accounts to quote, create and fund transfer to anyone in the supported countries. For Europe, it already uses SEPA for supported countries.

They use quotes because their fee varies a bit, depending on the country of source and destiny. Quotes also contain the exchange rate, if you're transferring to another currency. Quotes can be created with the outgoing amount or the received amount target, which makes it easier to guarantee the expense is being paid in full to the user (or to put the charge on the user side).

The API also includes endpoints for listing required fields for each destination country (used to generate forms for the user submitting expenses) and another endpoint for validating those accounts.

The transfer process is async, which means the transfer is not confirmed when we request the API. Although we receive an ETA for completing the transfer, we should have a worker on our side updating the status of our transfers.

This opens up for implementing features that should be interesting for the platform and hosts like further automation of payout (fully automatic/recurring payout) and/or collecting fees on the payout.

MVP

Overall the implementation of an MVP for hosts that already have a TransferWiser business account seems straightforward:

  1. Create PaymentMethods (or PayoutMethods) for the user who's sending the invoice/expense.
    • We can generate the form with necessary information based on the country. Otherwise, we can start the MVP in selected countries like Europe's SEPA countries that only require name and IBAN.
    • The data varies with the country, so we'll need to store this as JSON using the data field.
    • The data is generic, you save it once and use it with every host.
  2. Connect TransferWise account to the Host account.
    • The token is manually generated, this means a text input to paste it.
    • (Optional) Boolean to set if the transfer costs are charged on the collective or the user.
  3. Create a "Pay Expense with TransferWise" button.
    • Creates a quote. (Optional: Creating quotes is synchronous, we can also ask for confirmation.)
    • Create the Recipient Account in Host's TransferWise account.
    • Create a Transfer and adds funds to it and update the Expense status to "Processing".
    • A worker will check the status of pending transfers, update the DB and trigger all other business logic we might have.
      • A Webhook can also be configured to provide real-time updates.

Implementation Details

There are a few differences related to how we pay the expense using depending on the currencies involved.

Between the same currencies

Requires host to have a Borderless Account.

  1. Create a temporary quote to get the fees
  2. Use the temporary fee to verify if the collective has funds
  3. Create a transaction using { targetAmount: expense.amount }
    • In this scenario, the collective is paying for the fees.
  4. Update/persist expense, transaction and activity details using the fee created for the expense quote

Cross currency with expense submitted in the host currency

Apparently any account can do this.

  1. Create a temporary quote to get the fx rate and fees
  2. Verify if the collective has funds
  3. Create a transaction using the target amount calculated through quote.rate * expense.amount
    • In this scenario, the collective is paying for the fees but the user is paying for any eventual spread in converting the currency.
  4. Update/persist expense, transaction and activity details using the fee created for the expense quote

Metrics

What metrics will be used to measure impact?

  • The number of hosts connecting to TransferWise.
  • The number of expenses being paid with TransferWise.
  • The volume of money being paid with TransferWise.
  • Qualitative/Subjective: overall time spent by Hosts on paying out expenses.

Documentation

@piamancini

This comment has been minimized.

Copy link
Contributor

@piamancini piamancini commented Jan 21, 2020

Love it!

@Betree

This comment has been minimized.

Copy link
Member

@Betree Betree commented Jan 21, 2020

Although we receive an ETA for completing the transfer, we should have a worker on our side updating the status of our transfers.

Seems like they also have webhooks that we may want to implement to react faster. But we should definitely have a worker, as a webhook can eventually fail.

@kewitz

This comment has been minimized.

Copy link
Author

@kewitz kewitz commented Jan 21, 2020

@Betree and @znarf, related to the security of TransferWise tokens:
TransferWise allows you to protect a token by whitelisting IP's, I suggest we use https://elements.heroku.com/addons/fixie on production for TransferWise requests but will add to fixed monthly costs.
Any opinions on this?

@znarf

This comment has been minimized.

Copy link
Member

@znarf znarf commented Jan 21, 2020

@kewitz Good to know for the IP, but not sure yet we want to have a dedicated IP for our backend API.

@kewitz

This comment has been minimized.

Copy link
Author

@kewitz kewitz commented Jan 21, 2020

@znarf it is a fixed IP proxy service, it is only used for specific outbound traffic.

@znarf

This comment has been minimized.

Copy link
Member

@znarf znarf commented Jan 21, 2020

@kewitz oh, sorry, makes more sense then!

@kewitz

This comment has been minimized.

Copy link
Author

@kewitz kewitz commented Feb 3, 2020

Added Implementation Details to description.

@kewitz kewitz added this to In progress in Transferwise Feb 6, 2020
@kewitz kewitz changed the title TransferWise automated payouts TransferWise automated payouts POC Feb 6, 2020
@kewitz kewitz changed the title TransferWise automated payouts POC [Project] TransferWise Automated Payout Feb 6, 2020
@kewitz kewitz moved this from In progress to Context/Overview in Transferwise Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Transferwise
  
Context/Overview
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.