@usemona/mona-consent-sdk
v1.1.17
Published
OyaMoney SDK for embedding consent flows
Maintainers
Readme
OyaMoney SDK
A JavaScript SDK for embedding OyaMoney consent flows into your web application.
Installation
npm install @oya-money/sdkUsage
Basic Usage
import OyaMoneySDK from '@oya-money/sdk';
const sdk = new OyaMoneySDK({
accessToken: 'your-access-token',
apiUrl: 'https://api.oyamoney.com', // optional, defaults to localhost:3002
clientId: 'your-client-id' // required for attest SDK branding
});
// Load a consent flow
await sdk.loadConsent('consent-id-here', {
theme: 'light', // 'light' or 'dark'
position: 'center', // 'center' or 'bottom'
width: '400px',
height: '600px',
backgroundColor: '#FF5733' // Optional: hex color for background
});Browser Usage
<script src="https://unpkg.com/@oya-money/sdk/dist/sdk.js"></script>
<script>
const sdk = new OyaMoneySDK({
accessToken: 'your-access-token'
});
sdk.loadConsent('consent-id-here');
</script>Features
Background Color Customization
You can customize the background color of the consent flow by passing a backgroundColor option:
// With hex color (with or without #)
await sdk.loadConsent('consent-id-here', {
backgroundColor: '#FF5733' // Orange background
});
await sdk.loadConsent('consent-id-here', {
backgroundColor: '00FF00' // Green background (without #)
});The SDK validates the hex color format and will fall back to the default gray background if an invalid color is provided.
Attest SDK Integration
The OyaMoney SDK integrates with the Mona Attest SDK for user authentication and biometric verification. When you provide a clientId in the SDK configuration, it will be passed through to the consent page, which will then use it to fetch merchant-specific branding for the attest flow.
const sdk = new OyaMoneySDK({
accessToken: 'your-access-token',
clientId: 'your-client-id' // This will be used for attest branding
});The clientId should correspond to an API user that is owned by a merchant user with configured branding colors and information.
API Reference
OyaMoneySDK
Constructor
new OyaMoneySDK(config: OyaMoneyConfig)config:
accessToken(string, required): Your OyaMoney access tokenapiUrl(string, optional): API base URL, defaults tohttp://localhost:3002clientId(string, required): Client ID for attest SDK branding integration
Methods
loadConsent(consentId, options?)
Loads a consent flow in a modal.
Parameters:
consentId(string): The ID of the consent to loadoptions(object, optional): Modal configurationtheme('light' | 'dark'): Modal theme, defaults to 'light'position('center' | 'bottom'): Modal position, defaults to 'center'width(string): Modal width, defaults to '400px'height(string): Modal height, defaults to '600px'backgroundColor(string, optional): Hex color for background (e.g., '#FF5733' or 'FF5733')
Development
# Install dependencies
npm install
# Build for production
npm run build
# Development mode with watch
npm run dev
# Clean build artifacts
npm run cleanLicense
MIT
