Split Payouts
Record what the seller and the platform are each owed on every sale.
Split the sale
@app.get("/bought/<id:int>")
def bought(req):
lst = Listing.get(req.params["id"])
fee = int(lst.price_cents * 0.15) # 15% platform fee
app.money.split([(lst.seller, lst.price_cents - fee),
("platform", fee)], sku="listing:%d" % lst.id)
return "Thanks!"Each sale writes a ledger row per party. Guard it so a buyer refreshing the page doesn't double-record โ pass a unique ref and skip if it already exists.
Read the ledger
app.money.owed("seller:alice") # cents currently owed
app.money.payouts("seller:alice") # the rows
app.money.mark_paid(payout_id) # settle one when you pay outTakeaways
split()takes (party, amount) pairs โ dollars or integer cents.owed()sums pending payouts for a party.- This is the money-native core extended to marketplaces.