Paying for a good or service follows a simple path: a buyer pays a seller, so the payment is transferred from the buyer's bank account to the seller's. Ecommerce websites work this way. During checkout, the buyer adds their payment method, which is used to transfer funds to the merchant's bank account. An online payment gateway, such as Stripe or Adyen, facilitates the transaction.
However, there are times when the transaction isn't as straightforward. Depending on the scenario, the payment can be divided between more buyers, more sellers, or both. Marketplaces are a typical example. A buyer creates a shopping cart with items from different vendors. During checkout, there is only one payment, but both the order and the payment are split among the vendors who are responsible for fulfilling their parts of the order. In most cases, the marketplace platform charges an application fee, so the payment is split even more as each vendor pays a portion.
Merchants can also split payments if a third party seller makes the sale and is eligible to receive a commission. The US retail industry uses this model frequently, with sales assistants earning commissions for each sale they make. Another example is affiliate marketing, in which an affiliate earns commission by driving sales to a business. Think of all the influencers and creators who are defining a new economy based on this model.
Other scenarios involve splitting the payment among several buyers. An example is when a group of friends splits the bill of a restaurant dinner or buys a gift for a friend. A single buyer can also split payment across multiple cards or payment methods. This is useful in case a card does not have enough funds or they use store credit part way through the purchase.
Splitting payments between multiple sellers is relatively simple. Stripe Connect, for example, allows you to connect the vendors of a marketplace as connected accounts, and then use the transfer API to move funds between the accounts. Funds are already present when the transfers are created, so there is little chance for anything to go wrong. In case of refunds, reverse transfers can be used to return the amount.
In contrast, splitting payments between more buyers is more complex and can create edge cases that are difficult to manage. There can be some payment methods that are valid and others that are not. You need to define clear rules regarding which payment methods get refunded in the case of returns. Moreover, there can be more billing addresses that need to be handled differently from a financial perspective.
Essentially, a challenge can arise whenever non-atomic transactions are involved. It is for this reason that you will find more marketplaces online than ecommerce websites that accept multiple payment methods for a single order.
Some of Commerce Layer's customers deal with this scenario by implementing custom payment gateways that encapsulate multiple payments logic. As far as the platform is concerned, the payment is treated as an atomic transaction. The custom gateway determines how payments are split and how refunds are processed. The custom payment gateway operates as an independent microservice and can be modeled with any business logic, while Commerce Layer ensures consistency as if it were a standard gateway.