Skip to main content

Providers

Before a customer can send or receive payments through a specific provider, they must be registered with that provider. The provider service handles this onboarding — fetch the required fields for a given provider, submit a registration, and check its approval status. Each provider (Stripe, PagarMe, MercadoPago, Bridge, Avenia) has its own registration schema and approval flow.

import { createOakClient, createProviderService } from '@oaknetwork/api';

const client = createOakClient({ ... });
const providers = createProviderService(client);

Supported providers

ProviderValueDescription
Stripe"stripe"Card payments, transfers, connected accounts
PagarMe"pagar_me"Card payments and transfers (Brazil)
MercadoPago"mercado_pago"Card payments (Colombia)
Bridge"bridge"Crypto on-ramp, bank accounts, Plaid
Avenia"avenia"Crypto off-ramp, PIX (Brazil)

Methods

MethodDescription
getSchema(request)Get the registration schema for a provider
getRegistrationStatus(customerId)Check registration status for a customer
submitRegistration(customerId, request)Submit a provider registration

Get a provider schema

Retrieve the JSON schema that defines what fields are required to register a customer with a provider:

const result = await providers.getSchema({ provider: 'stripe' });

if (result.ok) {
const schema = result.value.data;
console.log('Required fields:', schema.required);
console.log('Properties:', Object.keys(schema.properties));
}

Check registration status

const result = await providers.getRegistrationStatus('cus_abc123');

if (result.ok) {
for (const reg of result.value.data) {
console.log(`${reg.provider} — status: ${reg.status} — role: ${reg.target_role}`);
}
}

Registration status fields

FieldTypeDescription
providerstringProvider name
statusstringRegistration status (e.g., "created", "approved")
target_rolestring | nullRole the customer is registered as
provider_responseanyRaw provider response
rejection_reasonstring | nullReason for rejection, if applicable
readinessanyProvider readiness data
created_atstringISO timestamp
updated_atstringISO timestamp

Submit a registration

const result = await providers.submitRegistration('cus_abc123', {
provider: 'stripe',
target_role: 'connected_account',
provider_data: {
account_type: 'express',
transfers_requested: true,
card_payments_requested: true,
},
});

if (result.ok) {
for (const reg of result.value.data) {
console.log(`Status: ${reg.status}`);
}
}

Registration request fields

FieldTypeRequiredDescription
providerProvider.NameYesProvider to register with
target_role"subaccount" | "customer" | "connected_account"YesRole for the registration
provider_dataobjectNoProvider-specific registration data

Provider data fields (Stripe example)

FieldTypeDescription
callback_urlstringOAuth callback URL
account_typestringAccount type (e.g., "express")
transfers_requestedbooleanRequest transfer capability
card_payments_requestedbooleanRequest card payment capability
tax_reporting_us_1099_k_requestedbooleanRequest US tax reporting
payouts_debit_negative_balancesbooleanAllow debit on negative balances
external_account_collection_requestedbooleanRequest external account collection