Dynamic Funding
Learn how to split payment funds across multiple processing accounts for marketplace and platform payment flows
Dynamic funding extends automated funding by allowing you to split funds from a single payment transaction across multiple processing accounts. This enables complex payment routing scenarios such as commission splitting, multi-vendor payments, and platform fee collection, all within a single payment operation.
Dynamic funding uses the transfers array on payment transactions to specify how funds should
be distributed across multiple processing accounts. Each transfer represents a portion of the
total payment amount being routed to a specific account.
Prerequisites
Before implementing dynamic funding, it's helpful to learn about the following topics.
Learn about automated funding
Understand how automated funding works for processing accounts, which forms the foundation for dynamic funding operations.
Learn about transfers
Understand how transfers represent fund movements between accounts and how they relate to transactions.
When to Use Dynamic Funding
Use dynamic funding when you need to split payment funds from a single transaction across multiple processing accounts, rather than manually creating separate transfers after the fact. This is essential for platforms and marketplaces that need to automatically route funds to multiple parties at the time of payment collection.
Common use cases
- Multi-Vendor Orders: Distribute a single customer payment across multiple vendors based on cart contents, with each vendor receiving their portion of the order total.
- Revenue Sharing: Implement revenue sharing models where multiple parties receive a percentage of each transaction, such as referral partners, service providers, and platform operators.
- Platform Fees: Automatically deduct platform fees, processing fees, or service charges from payments before routing the remaining funds to the primary recipient.
- Legal Trust Accounting: Split legal payments between an IOLTA trust account for reserve funds and an operating account for earned fees, ensuring compliance with attorney trust account regulations.
- Franchise Payments: Automatically split payments between the franchisee's operating account and the franchisor's account based on royalty agreements, with each party receiving their designated percentage.
Single Transaction: Dynamic funding allows you to implement complex payment routing within a single API call, eliminating the need for multiple separate transfer operations and simplifying reconciliation.
How Dynamic Funding Works
Dynamic funding uses the transfers array on a payment transaction to specify how funds should
be split across multiple processing accounts. Each transfer in the array defines an amount and a
destination account.
Transfer Amount Notation
Transfer amounts use a specific notation to indicate how funds flow:
- Negative amounts (
-90) indicate funds being deducted from the payment and sent to the specified account - The sum of all negative transfer amounts must not exceed the total payment amount
- Transfer amounts represent the actual dollar values being moved, not percentages
Basic Flow Example
Here's how a $100 payment with dynamic funding works:
Customer Initiates Payment
Customer initiates a $100 payment using their card. The payment is processed and authorized.
Define Transfer Split
The transfers array specifies how to split the funds:
- Transfer 1:
-$90to Merchant Processing Account - Transfer 2:
-$10to Platform Processing Account
Create Funding Transactions
Payload creates corresponding funding transactions:
- Deposit of $90 on the merchant's processing account
- Deposit of $10 on the platform's processing account
Distribute Funds
Each processing account receives funds according to its funding configuration.
Amount Validation: The sum of all negative transfer amounts cannot exceed the total transaction amount. If transfers total more than the payment, the transaction will not be accepted. Ensure your transfer amounts add up correctly.
Creating Payments with Dynamic Funding
To split payment funds across multiple accounts, include the transfers array in your payment
transaction request. Each transfer specifies an amount and a receiver account.
Split payment between merchant and platform
Collect a customer payment and automatically split funds between the merchant and platform commission.
This example creates a $100 payment with dynamic funding:
-
type='payment'initiates the payment collection -
sender.methodprovides inline card details (or use sender.method_id for saved cards) -
receiver.account_idspecifies the primary processing account -
transfersarray splits the funds:-
-$90to the merchant processing account -
-$10to the platform processing account as commission
-
The system automatically creates two deposit funding transactions, one for $90 to the merchant and one for $10 to the platform.
Split payment across multiple vendors
Distribute a single payment across three different vendor accounts based on order contents.
This example splits a $150 payment across three vendors:
-
transfersarray contains three entries - Each vendor receives their portion: $50, $60, and $40
- Total transfers ($150) equals the payment amount
- Each vendor's processing account receives a separate deposit funding transaction
This pattern is common for marketplace carts where a customer purchases from multiple vendors in a single checkout.
Deduct platform fee and route remaining funds
Collect a payment, deduct a platform fee, and send the remainder to the merchant.
This example processes a $200 payment with platform fee:
- Customer pays $200
- Platform deducts $15 processing fee
- Merchant receives $185
- Both amounts are specified as negative transfers
- Each account's funding happens according to its funding configuration
This approach ensures transparent fee collection while maintaining clean accounting for both parties.
Calculate and split based on percentages
Split payment dynamically based on percentage allocations calculated in your application.
This example demonstrates percentage-based splitting:
- Total payment is $500
- Calculate split amounts in your application logic
- Primary party receives 85% ($425)
- Secondary party receives 15% ($75)
- Pass calculated amounts as negative transfers
Percentage Calculation: The transfers array accepts only absolute dollar amounts, not percentages. Calculate percentage-based splits in your application code before creating the transaction.
Saved Payment Methods: Dynamic funding works seamlessly with saved payment methods.
Instead of providing inline payment details, reference a saved payment method using
sender.method_id. This is the most common approach for recurring marketplace payments or
subscriptions with revenue splitting.
Transfer Objects and Relationships
Each transfer in the transfers array creates a corresponding Transfer object that tracks the
fund movement between accounts. These Transfer objects are associated with the associated
transaction and provide detailed tracking of how funds were split.
Transfer Object Properties
Key properties of Transfer objects created from dynamic funding:
-
amount- The transfer amount (negative values represent debits/outgoing funds) -
sender.account_id- The account sending funds (typically the payment source) -
receiver.account_id- The account receiving the funds -
transaction_id- Reference to the parent payment transaction -
assoc_transaction_id- Reference to the associated funding transaction created for this transfer -
type- Automatically set based on the transfer context (typically "payment" or "deposit")
Querying Transfers
You can query transfers to understand how funds were split for a specific payment:
This retrieves all transfers associated with a specific payment transaction, showing exactly how funds were distributed across processing accounts.
Monitoring Dynamic Funding Events
Dynamic funding transactions trigger the same webhook events as standard automated funding, with additional transfer-specific events for tracking fund splits.
Webhook Events for Dynamic Funding
Monitor these webhook events to track dynamic funding operations:
-
payment- Triggered when the payment transaction is created -
processed- Triggered when the payment completes successfully -
deposit- Triggered for each deposit funding transaction created (one per transfer) -
decline- Triggered if the payment or any funding transaction fails
Multiple Deposits: With dynamic funding, a single payment transaction will trigger
multiple deposit webhook events—one for each processing account receiving funds. Ensure your
webhook handler can process multiple deposits for the same payment.
Example webhook handler for dynamic funding:
from flask import Flask, request
app = Flask(__name__)
@app.route("/webhooks/payload", methods=["POST"])
def handle_webhook():
webhook = request.json
# Handle successful payment with dynamic funding
if webhook["trigger"] == "processed" and webhook["triggered_on"]["type"] == "payment":
transaction_id = webhook["triggered_on"]["id"]
transaction = pl.Transaction.get(transaction_id)
print("Payment processed:", transaction.id)
print("Total amount:", transaction.amount)
print("Number of transfers:", len(transaction.transfers) if transaction.transfers else 0)
if webhook["trigger"] == "deposit":
transaction_id = webhook["triggered_on"]["id"]
transaction = pl.Transaction.get(transaction_id)
print("Deposit funding created:", transaction.id)
print("Amount deposited:", transaction.amount)
print("Receiver account:", transaction.receiver["account_id"])
return "OK", 200Reconciling Split Payments
To reconcile a payment with dynamic funding:
- Query the payment transaction to get the total amount and transfers array
- Query associated transfers to get detailed transfer records
- Query deposit funding transactions for each processing account
- Verify that the sum of all deposit amounts equals the payment amount
This reconciliation approach ensures all funds were distributed correctly and helps with financial reporting and auditing.
Schema Reference
The following fields are particularly relevant for implementing dynamic funding:
Transaction Schema - Transfers Array
The transfers array on payment transactions controls how funds are split:
transfersTransferTransfer Schema
Transfer objects created from the transfers array:
amountsenderaccountAccountaccount_id ID of Account^acct_[A-Za-z0-9]+$receiveraccountAccountaccount_id ID of Account^acct_[A-Za-z0-9]+$transaction_id ID of Transaction^txn_[A-Za-z0-9]+$assoc_transaction_id ID of Transaction^txn_[A-Za-z0-9]+$receiver=nullsender=nullBest Practices
Follow these best practices when implementing dynamic funding:
Validate Transfer Amounts
Always validate that the sum of all negative transfer amounts does not exceed the total payment amount before submitting the transaction. Implement client-side validation to catch errors early.
def validate_transfers(payment_amount, transfers):
total_transfers = sum(abs(t["amount"]) for t in transfers)
if total_transfers > payment_amount:
raise ValueError(
f"Transfer total (${total_transfers}) exceeds payment amount (${payment_amount})"
)
return TrueHandle Rounding Errors
When calculating percentage-based splits, be careful with rounding. Ensure the sum of calculated amounts exactly matches the payment total.
import math
def split_percentage(amount, percentages):
# Calculate each split, rounding down
splits = [math.floor(amount * pct * 100) / 100 for pct in percentages]
# Add any remainder to the first split to ensure exact total
total = sum(splits)
remainder = amount - total
splits[0] += remainder
return splitsMonitor Failed Transfers
Implement monitoring for failed dynamic funding transactions. If any transfer in the array fails, the entire payment may be declined. Alert on these failures and implement retry logic where appropriate.
Next Steps
Build comprehensive marketplace payment flows, manage complex revenue sharing, and create detailed financial reporting
Understand the Foundation of Dynamic Funding
Learn how Automated Funding works for processing accounts, configure funding payment methods with Default Payment Methods, and understand Processing Accounts capabilities.
Create Transactions with Dynamic Funding
Process payments with revenue splitting using Creating Payment Intents, understand transfer operations with Creating Transfers, and monitor the complete Payment Processing lifecycle and status.
Monitor and Reconcile Dynamic Funding
Track split funding and settlement with Reporting Overview, create custom revenue reports using Building Report Queries, and monitor fund distribution through Transfer Reports.