Skip to content

Commit 5a5bacb

Browse files
add support for subaccounts
1 parent 7f04840 commit 5a5bacb

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

example/src/App.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ export default function App() {
2020
description: 'Payment for items in cart',
2121
logo: 'https://assets.piedpiper.com/logo.png',
2222
},
23+
24+
subaccounts: [
25+
{
26+
// vendor A
27+
id: "RS_D87A9EE339AE28BFA2AE86041C6DE70E",
28+
transaction_split_ratio: 2,
29+
transaction_charge_type: "flat",
30+
transaction_charge: 100,
31+
},
32+
{
33+
// vendor B
34+
id: "RS_344DD49DB5D471EF565C897ECD67CD95",
35+
transaction_split_ratio: 3,
36+
transaction_charge_type: "flat",
37+
transaction_charge: 100,
38+
},
39+
{
40+
// vendor C
41+
id: "RS_839AC07C3450A65004A0E11B83E22CA9",
42+
transaction_split_ratio: 5,
43+
transaction_charge_type: "flat",
44+
transaction_charge: 100,
45+
},
46+
],
2347
};
2448

2549
const handleFlutterPayment = useFlutterwave(config);

src/types.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Check out {@link https://developer.flutterwave.com/docs/flutterwave-standard} for more information.
33
*/
44

5-
export interface FlutterWaveProps {
5+
export interface FlutterWaveProps {
66
/**
77
* Your transaction reference. This MUST be unique for every transaction
88
*/
@@ -66,12 +66,25 @@ export interface FlutterWaveProps {
6666
* function to be called when the payment is completed successfully
6767
*/
6868
callback: (data: FlutterWaveResponse) => void;
69-
69+
7070
/**
7171
* function to be called when the mono connection is closed
7272
*/
7373
onclose: () => void;
7474
public_key: string;
75+
/**
76+
* An array of objects containing the subaccount IDs to split the payment into.
77+
* e.g subaccounts: [
78+
{
79+
id: "RS_A8EB7D4D9C66C0B1C75014EE67D4D663",
80+
transaction_split_ratio: 2,
81+
transaction_charge_type: "flat_subaccount",
82+
transaction_charge: 4200,
83+
},
84+
]
85+
* Check out {@link https://developer.flutterwave.com/docs/collecting-payments/split-payments/} for more information on subaccounts.
86+
*/
87+
subaccounts?: Array<unknown>;
7588
}
7689

7790
export interface FlutterwaveConfig {
@@ -85,6 +98,7 @@ export interface FlutterwaveConfig {
8598
redirect_url?: FlutterWaveProps['redirect_url'];
8699
payment_plan?: FlutterWaveProps['payment_plan'];
87100
payment_options: FlutterWaveProps['payment_options'];
101+
subaccounts?: FlutterWaveProps['subaccounts'];
88102
}
89103

90104
export interface InitializeFlutterwavePayment {

0 commit comments

Comments
 (0)