-
Notifications
You must be signed in to change notification settings - Fork 6
Subaccount Configuration in Flutterwave iOS SDK
This wiki page provides a detailed guide on configuring subaccounts in the Flutterwave iOS SDK. Subaccounts allow you to split payments between multiple entities, such as vendors, partners, or affiliates. You can create and configure subaccounts either via the Flutterwave API or the Flutterwave dashboard.
Note: To create a collection subaccount programmatically via the API, refer to the Flutterwave API documentation. Alternatively, you can also create subaccounts on the Flutterwave dashboard.
After creating a collection subaccount, you will receive an id
in the API response, for example:
"data": {
"id": 2181,
...
}
You will use this id when configuring subaccounts in your Flutterwave iOS SDK integration.
When configuring subaccounts in the SDK, you need to provide the following parameters:
- id: The unique identifier of the subaccount received from the API.
- ratio: The ratio defines how money is shared proportionally between subaccounts (excluding your commission and Flutterwave fees).
If you're not using ratio-based splitting, you can set it to nil.
charge_type: The type of split you want to use with this subaccount. Use "percentage" if you want to receive a percentage of each transaction, or "flat" if you want to receive a flat fee from each transaction.
charge: The amount you want to receive as commission on each transaction. The charge value should align with the charge_type.
Flat Fee Split To collect a flat fee from each transaction, you can configure a subaccount like this:
config.subAccounts = [
SubAccount(id: "RS_D582E53", ratio: nil, charge_type: .flat, charge: 500.00),
SubAccount(id: "RS_0BF478", ratio: nil, charge_type: .flat, charge: 100.00)
]
Percentage Split To collect a percentage of each transaction, configure the subaccount like this:
config.subAccounts = [
SubAccount(id: "RS_D582E53", ratio: nil, charge_type: .percentage, charge: 0.09),
SubAccount(id: "RS_0BF478", ratio: nil, charge_type: .percentage, charge: 0.05)
]
Ratio-Based Split If you're splitting a payment between multiple subaccounts based on a ratio, use the ratio parameter. For example, if you want to split a payment among three vendors with different proportions:
Vendor A gets 20% Vendor B gets 30% Vendor C gets the remaining 50%
Set the ratio parameter as follows:
config.subAccounts = [
SubAccount(id: "RS_D582E34", ratio: 2, charge_type: .flat, charge: 100.00),
SubAccount(id: "RS_0BF477", ratio: 3, charge_type: .flat, charge: 100.00),
SubAccount(id: "RS_0BF478", ratio: 5, charge_type: .flat, charge: 100.00)
]
Configuring subaccounts in the Flutterwave iOS SDK allows you to manage and distribute funds seamlessly among various entities. Ensure you have the necessary subaccount id and choose the appropriate charge_type and charge based on your requirements.