Taking two payments in one purchase

Two Parallel freeway bridges

Awhile back I consulted on a project that needed to take two separate payments from two separate payment gateways in one checkout, made to be as simple and streamlined as possible.

There’s two workable solutions. Either (1) take two separate orders in one flow, whereby the second order is repopulated with all the same information as the first except the different line item, total and payment status; or (2) take one order with two line items and receive two payments, to be marked paid only after the second payment.

The approach to pick depends on how the two transactions are communicated. If the purchases are for separate parties then separate orders makes more sense, as one can be refunded while the other not, and separate order numbers can make sense to the purchaser, Order 1 for A service and Order 2 for B service. This is an easier approach since each payment gateway has its own order to mark as paid. The trick here is to connect from the Order Confirmation of the first order into the second order. A customer account is essential in order to connect them with their individual receipts and statuses.

While the above approach seems workable for many cases, it’s cleaner and saves on order numbers and emails to consolidate the two purchases into one order. To consolidate into one order we must accept credit onto the order. Administrators typically do this using a Fee line item and setting it to a negative value with a description. Payment gateways don’t do this naturally, so custom code is necessary to bypass the primary payment gateway’s success function and apply the negative Fee line item in its place, then redirect the user to their Order Pay Page to complete the remainder of the order total, showing there that the initial payment was successful.