Flutterwave / React-Native

React Native library for Flutterwave for Business (F4B) v2 and v3 APIs.
https://developer.flutterwave.com/
MIT License
6 stars 13 forks source link

How to make payment to subaccount #45

Closed Goldtek closed 2 years ago

Goldtek commented 2 years ago

I want to make payment to subaccount how do i go about it.

thecodecafe commented 2 years ago

Hi @Goldtek, to pay to a sub-account you can pass your sub-accounts to the PayWithFlutterwave component like so.

const mySubAccounts = [
  {
     id: "RS_A8EB7D4D9C66C0B1C75014EE67D4D663",
     transaction_split_ratio: 0.1, // optional, it defaults to the one set when creating the subaccount
     transaction_charge_type: "percentage", // optional, it defaults to the one set when creating the subaccount
     transaction_charge: 0.09, // optional, it defaults to the one set when creating the subaccount
  }
];

<PayWithFlutterwave
  ...
  onRedirect={handleOnRedirect}
  options={{
    tx_ref: generateTransactionRef(10)
    authorization: '[merchant public key]',
    customer: {
      email: 'customer-email@example.com'
    },
    amount: 2000,
    currency: 'NGN',
    payment_options: 'card',
    subaccounts={mySubAccounts}
  }}
/>

Prior to this, you would have already created your sub-accounts using the API or SDK, find information about that here.

You can also find out more about using sub-accounts here.

I'll be closing the issue with this comment but feel free to open with a follow-up question if this does not satisfy your initial question.

Hope this helps, happy coding! 🤝