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 registration schema for a provider. The response describes the available roles and the fields required for each:

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

if (result.ok) {
const { schema } = result.value.data;
console.log('Provider:', schema.provider);
console.log('Allowed roles:', schema.allowed_roles);

for (const [role, config] of Object.entries(schema.roles)) {
console.log(`\nRole: ${role}`);
console.log(' Required fields:', config.required_fields);
console.log(' Provider data required:', config.provider_data_required);
if (Object.keys(config.provider_data_schema).length > 0) {
console.log(' Provider data fields:', Object.keys(config.provider_data_schema));
}
}

console.log('\nGlobal required fields:', Object.keys(schema.global_required_fields));
}

Schema response structure

FieldTypeDescription
schema.providerstringProvider name
schema.allowed_rolesstring[]Roles the provider supports (e.g., ["customer", "connected_account"])
schema.rolesobjectPer-role configuration (see below)
schema.global_required_fieldsobjectFields required across all roles (e.g., email, country_code)

Each role in schema.roles contains:

FieldTypeDescription
required_fieldsstring[]Fields required for this role
provider_data_schemaobjectField definitions for provider_data
provider_data_requiredbooleanWhether provider_data must be supplied

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

For Stripe connected_account, the customer must have a country_code set. Create or update the customer with country_code before registering.

Stripe connected account

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

if (result.ok) {
console.log('Status:', result.value.data.status);
console.log('Provider:', result.value.data.provider);
console.log('Role:', result.value.data.target_role);
}

Stripe customer

const result = await providers.submitRegistration(customerId, {
provider: 'stripe',
target_role: 'customer',
});

if (result.ok) {
console.log('Status:', result.value.data.status);
}

Bridge customer

const result = await providers.submitRegistration(customerId, {
provider: 'bridge',
target_role: 'customer',
});

Registration request fields

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

Registration response

FieldTypeDescription
statusstringRegistration status (e.g., "awaiting_confirmation", "submitted")
providerstringProvider name
target_rolestringRole the customer was registered as
provider_dataobjectSubmitted provider data (if any)
provider_responseobjectRaw provider response (e.g., Stripe keys, Bridge KYC/TOS URLs)
readinessobjectCapability readiness per payment type
created_atstringISO timestamp
updated_atstringISO timestamp

Provider data fields (Stripe connected account)

FieldTypeRequiredDescription
account_typestringYesAccount type ("standard", "express", "custom")
transfers_requestedbooleanYesRequest transfer capability
card_payments_requestedbooleanYesRequest card payment capability
tax_reporting_us_1099_k_requestedbooleanYesRequest US tax reporting
payouts_debit_negative_balancesbooleanYesAllow debit on negative balances
external_account_collection_requestedbooleanYesRequest external account collection
callback_urlstringNoOAuth callback URL