An open-source TransferWise API client for Node.JS
The TransferWise Node library provides convient access to the TransferWise API from applications written in server-side JavaScript.
See the TransferWise API docs for the offical docs, below is a list of methods supported by this library.
Install the package with:
npm install @fightmegg/transferwise
NB: Requires Node >= 12
import TransferWise from '@fightmegg/transferwise';
const tw = new TransferWise({ token: ..., sandbox: true });
const profiles = await tw.profiles();
Currently only supports methods listed below. Aim to support all API methods soon.
profiles
await tw.profiles();
borderlessAccounts
await tw.borderlessAccounts("<profileId>");
recipientAccounts
await tw.recipientAccounts.create("<accounts object>");
await tw.recipientAccounts.get("<accountId>");
await tw.recipientAccounts.delete("<accountId>");
await tw.recipientAccounts.list("<account url params>");
quotes
await tw.quotes.temporary("<quote url params>");
await tw.quotes.create("<quote object>");
await tw.quotes.get("<quoteId>");
transfers
await tw.transfers.create("<transfer object>");
await tw.transfers.cancel("<transfer object>");
await tw.transfers.get("<transferId>");
await tw.transfers.issues("<transferId>");
await tw.transfers.fund("<profileId>", "<transferId>");
await tw.transfers.deliveryEstimate("<transferId>");
await tw.transfers.list("<transfer url params>");
simulation
await tw.simulation.transfers.processing("<transferId>");
await tw.simulation.transfers.fundsConverted("<transferId>");
await tw.simulation.transfers.outgoingPaymentSent("<transferId>");
await tw.simulation.transfers.bouncedBack("<transferId>");
await tw.simulation.transfers.fundsRefunded("<transferId>");
TransferWise signs all Webhook events, and it is recommended that you verify this signature . Luckily this library can do that for you.
Similarly to how stripe node
works, you should only use the event returned from the method below.
const event = tw.webhooks.constructEvent("<webhookMsg>", "<signature>");
Please note that you must pass the raw request body, exactly as recieved from TransferWise to the constructEvent()
function; this will not work with a parsed (i.e., JSON) request body.
You can find an example of how to use this with Express below:
app.post("/", bodyParser.raw({ type: "application.json" }), (req, res) => {
const sig = req.headers["x-signature"];
const event = tw.webhooks.constructEvent(req.body, sig);
// ...
});
Below is a series of issues that l have found out through various email chains with TransferWise API team.
1. Create a Transfer
When creating a transfer, the field targetValue will always be populated as 0
regardless, therefore you should only rely on this field in production.
2. Simulate a Transfer
When funding a transfer, the transfer state might show processing
, however this state is misleading. When simulating, you will still need to simulate from incoming_payment_waiting
to processing
.
Run all tests:
$ npm test
This library is published to both the NPM and GitHub package registrys.