Transactions

Transactions represent money flows resulting from bookings on your marketplace.

They help you track:

  • how much must be paid for bookings
  • where/when the money comes from and goes
  • how much your marketplace earns if there is a subscription or fees applied.

The simplest way to create a transaction is to reference existing bookings:

stelace.transactions.create({
  bookingsIds: ['bkg_a3BfQps1I3a1gJYz2I3a']
})

That will automatically fill the transaction with bookings information.

Transaction line

Transaction lines represent theoretical payments and money transfers and make it easy to ensure your users know exactly what and whom they have to pay.

stelace.transactionLines.create({
  transactionId: 'txn_eP0hwes1jwf1gxMLCjwf',
  bookingId: 'bkg_a3BfQps1I3a1gJYz2I3a',
  reversal: false,
  senderAmount: 1177,
  receiverId: null,
  receiverAmount: null,
  platformAmount: 177,
  currency: 'USD'
})

Providing the lines is the other way to create a transaction.

stelace.transactions.create({
  lines: [
    ... // multiple transaction lines can be provided here
  ]
})

Note: Only reversed transaction lines can be created after a payment has been attempted. Please refer to the reversal section.

Transaction move

Transaction moves represent effective payments and money transfers.

stelace.transactionMoves.create({
  transactionId: 'txn_eP0hwes1jwf1gxMLCjwf',
  bookingId: 'bkg_a3BfQps1I3a1gJYz2I3a',
  reversal: false,
  senderAmount: 1177,
  receiverId: null,
  receiverAmount: null,
  platformAmount: 177,
  currency: 'USD',

  // you can optionally provide real amounts if multiple currencies are involved
  real: {
    senderAmount: 1038,
    platformAmount: 156,
    currency: 'EUR'
  }
})

Reversal

In ideal situations, all works well and money goes from sender to receivers. But in reality, cancellations can happen for various reasons. In that case, you have to reverse the transaction to represent the refund.

stelace.transactionLines.create({
  transactionId: 'txn_eP0hwes1jwf1gxMLCjwf',
  bookingId: 'bkg_a3BfQps1I3a1gJYz2I3a',
  reversal: true,
  senderAmount: -1177,
  receiverId: null,
  receiverAmount: null,
  platformAmount: -177,
  currency: 'USD'
})