Repository navigation
feat(core): provider-managed payout account onboarding - #103
alexasomba wants to merge 8 commits into
Conversation
moset15
left a comment
There was a problem hiding this comment.
The three methods map onto Paystack too: listPayoutBanks to GET /bank, resolvePayoutAccount to GET /bank/resolve, createPayoutAccount to POST /subaccount (business_name, settlement_bank, account_number, percentage_charge).
Two things in the Vendors form:
- Verification is required even when the provider can't verify.
resolvePayoutAccountis optional on the interface, but the form'svalidneedsaccountName !== null, so a provider without it, or a country where account lookup isn't supported, can never create an account. Suggest requiring verification only when the provider implements it, and storing the account unverified otherwise. In Kenya the lookup does work: in Paystack test mode it returned the account name for a Kenyan bank account and for an M-PESA number. South Africa is the case to allow for, where Paystack checks accounts withPOST /bank/validateand an ID document instead. - The form starts on Nigeria (
useState("NG")). Starting on the shop's default country (or the provider's first country) saves Kenyan, Ghanaian and South African merchants a step.
M-PESA payouts fit the seam as is. Paystack lists M-PESA as a payout channel (GET /bank?currency=KES&type=mobile_money), and a subaccount can settle to an M-PESA number; I created one in test mode. So the Paystack package can return M-PESA alongside the banks from listPayoutBanks, and Kenyan vendors can be paid to M-PESA with no core change. One mapping question for providers: Paystack creates subaccounts as unverified (is_verified: false) but active: true. Should a provider report that as "active" (#101 refuses anything else), or is there a status for "usable but not yet verified"?
createVendor stored stripeAccountId: "" and the field has a unique index, so the second vendor failed. The field is now optional and omitted when there is no Stripe account; a missing field is NULL. Also documents the coupon rule for split allocations (the platform absorbs a cart-wide discount; a larger one is a 409) and makes the allocation comments generic for Paystack.
|
@moset15 thanks — both form points are in, and the status question has a separate flag rather than a new status.
Pushed in 5ceb2e4; #107 is merged forward. The Paystack mapping you described ( |
|
Follow-up on the replace caveat I raised: onboarding is now idempotent in #107 (0ed388b). If Flutterwave answers a create with 400/409, the package lists |
Part of the Flutterwave set described in #97. Item 6. Builds on #101 (vendor payout accounts). Generic core; no Flutterwave code.
Why
The Flutterwave create-subaccount API takes the bank, account number, country, business details and a default split, and returns the
RS_…id. Asking the merchant to create that in the Flutterwave dashboard and paste the id is a v1. This adds the seam so a provider can do it from Vendors, with the account name verified when the provider supports it.What
VendorPaymentAccountgainsaccountName,verified,bankName,bankCode,country,maskedAccountNumber,metadataandcreatedAt. The full account number is never stored.verified: falsemeans the provider created a usable account it has not verified; core still accepts it for splits.PaymentProvidergains three optional methods:listPayoutBanks(ctx, country, credentials)resolvePayoutAccount(ctx, { accountNumber, bankCode }, credentials)createPayoutAccount(ctx, { accountNumber, bankCode, country, businessName, businessEmail, businessMobile, splitType, splitValue, … }, credentials)GET admin/vendors/payout-banks,POST admin/vendors/payout-account/resolve,POST admin/vendors/payout-account. They load the provider's saved credentials, validate the input, create the account, and store the masked result on the vendor. A second create is refused unlessreplace: true; replacing still depends on the provider accepting the new account.unverifiedmarker when applicable. The manual account id remains for providers without onboarding._providersexposespayoutOnboardingandpayoutVerification, so the UI only renders the form when the provider can create an account, and only requires verification when the provider can resolve names.API facts this is built on (checked, not assumed)
GET /v3/banks/{country}returns{ code, name };POST /v3/accounts/resolvewithaccount_number+account_bankreturnsaccount_name;POST /v3/subaccountsrequiresaccount_bank,account_number,business_name,country,business_mobile,split_value(andbusiness_emailin practice), withsplit_typeoptional.percentageorflat; DashCommerce still overrides it per payment with the exact vendor amount, so the default is only a fallback.Tests
payoutOnboarding/payoutVerificationin_providers, an account created without a resolver, and an active-but-unverified account.Review response (moset15)
_providersexposespayoutVerification; the form requires the resolved name only when the provider implementsresolvePayoutAccount. Otherwise it saves the account unverified and says so. The core route only rejects a missing name when the provider can verify.status: "active"plusverified: falseonVendorPaymentAccount/CreatedPayoutAccount. Core's split check still only requiresactive, so Paystack'sis_verified: false, active: trueis usable, and the Vendors page showsunverified. No new status value.listPayoutBanksmay return mobile-money channels; the bank picker is searchable and labelled "Bank or mobile money", and the account field is "Account or mobile number". No core change is needed for Paystack to pay a vendor to M-PESA.Next
The Flutterwave package (#107) implements the three methods using the endpoints above and ships the form in Vendors. Paystack can implement the same three methods for its subaccounts without another core change.