1.7.0 • Published 1 year ago

@oatfi/web-js v1.7.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

oatfi-web

A framework-free OatFi Web Components library that provides drop in components, written in TypeScript.

Installation

Use npm to install the Oatfi-Web-JS module:

npm install --save @oatfi/web-js

or you can add our cdn script into your website like this:

<script
  src="https://d1h8jcgjihlgjp.cloudfront.net/index.umd.min.js"
  type="text/javascript"
></script>

When imported this will create the custom-elements that will be available on your website for usage.

<oatfi-bnpl /> <oatfi-factoring /> <oatfi-onboarding />

Env overrides

On the components the prop sandbox is available in case the developer wants to hit the sandbox environment this can be used by adding the prop as true.

<oatfi-bnpl sandbox="true" ...></oatfi-bnpl>
<oatfi-factoring sandbox="true" ...></oatfi-factoring>
<oatfi-onboarding sandbox="true" ...></oatfi-onboarding>

CTA text

A attribute ctaText is available in order to customize the text shown in the main CTA of the elements.

Example:

<oatfi-onboarding ctaText="true" ... />

BNPL

<oatfi-bnpl
  token="yourAuthToken"
  partnerId="partnerId"
  supportEmail="supportEmail"
  payorExternalId="payorExternalId"
  invoiceExternalId="invoiceExternalId"
/>

Callback logic

BNPL component will trigger events according to what happened in the flow. In order to listen to these events a document event listener is required.

document.addEventListener('OATFI_BNPL', function (event) {
  switch (event.detail.event) {
    case OATFI_EVENTS.CLOSE_DRAWER:
      console.log(event.detail.data, 'Close');
      break;
    case OATFI_EVENTS.UNDERWRITING:
      console.log(event.detail.data, 'Underwriting');
      break;
    case OATFI_EVENTS.UNDERWRITING_ERROR:
      console.log(event.detail.data, 'Underwriting error');
      break;
    case OATFI_EVENTS.DEFER:
      console.log(event.detail.data, 'Defer');
      break;
    case OATFI_EVENTS.DEFER_ERROR:
      console.log(event.detail.data, 'Defer error');
      break;
    case OATFI_EVENTS.ERROR:
      console.log(event.detail.data, 'General error');
      break;
  }
});

Note: event triggered will have the prop detail that contains event and data

BNPL Events

EventData
CLOSE_DRAWER (triggers on closing the drawer){}
UNDERWRITING (triggers after underwriting was executed){ creditLimit: number }
UNDERWRITING_ERROR (triggers after underwriting was executed but it was an error){ creditLimit?: number, error: string }
DEFER (triggers after funding is executed){ businessExternalId: string, loanId: string, amount: number, availableCredit: number, type: "BNPL"}
DEFER_ERROR (triggers after funding is executed but it was an error){ error: string }
ERROR (triggers after a general error occurs){ error: string }

Subtitle prop

A prop subtitle is available to override the text below the cta for BNPL. (to not display a subtitle send a "" empty text)

<oatfi-bnpl
  token="yourAuthToken"
  partnerId="partnerId"
  supportEmail="supportEmail"
  payorExternalId="payorExternalId"
  invoiceExternalId="invoiceExternalId"
  subtitle="Custom subt"
/>

Steps configuration

BNPL component support steps configuration (in a form of a JSON object) to adapt the flow to the requirements of the client the options are:

StepPre-requisite
onboardingNone
contactInfoNone
underWritingNone
presentOfferunderWritting is required
fundpresentOffer is required

By default all steps are enabled.

Usage example

<oatfi-bnpl
  token="yourAuthToken"
  partnerId="partnerId"
  supportEmail="supportEmail"
  payorExternalId="payorExternalId"
  invoiceExternalId="invoiceExternalId"
  steps='{"onboarding":false}'
/>

Factoring

<oatfi-factoring token="yourAuthToken" partnerId="partnerId" payeeExternalId="payeeExternalId" />

Factoring Managed Marketpplace

If managed marketplace flag is indicated managedMarketplace="true", then payorExternalId is used instead of payeeExternalId

<oatfi-factoring
  token="yourAuthToken"
  partnerId="partnerId"
  managedMarketplace="true"
  payorExternalId="payorExternalId"
/>

Callback logic

Factoring component will trigger events according to what happened in the flow. In order to listen to these events a document event listener is required.

document.addEventListener('OATFI_FACTORING', function (event) {
  switch (event.detail.event) {
    case OATFI_EVENTS.CLOSE_DRAWER:
      console.log(event.detail.data, 'Close');
      break;
    case OATFI_EVENTS.UNDERWRITING:
      console.log(event.detail.data, 'Underwriting');
      break;
    case OATFI_EVENTS.UNDERWRITING_ERROR:
      console.log(event.detail.data, 'Underwriting error');
      break;
    case OATFI_EVENTS.PRESENT_LOAN_OFFER:
      console.log(event.detail.data, 'Present loan offer');
      break;
    case OATFI_EVENTS.FUNDING_LOAN:
      console.log(event.detail.data, 'Funding loan');
      break;
    case OATFI_EVENTS.SUMMARY_OFFER:
      console.log(event.detail.data, 'Summary offer');
      break;
    case OATFI_EVENTS.ERROR:
      console.log(event.detail.data, 'General error');
      break;
  }
});

Note: event triggered will have the prop detail that contains event and data

Factoring Events

EventData
CLOSE_DRAWER (triggers on closing the drawer){}
UNDERWRITING (triggers after underwriting was executed){ creditLimit: number }
UNDERWRITING_ERROR (triggers after underwriting was executed but it was an error){ creditLimit?: number, error: string }
PRESENT_LOAN_OFFER (triggers after an offer is presented)
{ businessExternalId: string, totalAvailableToFactor: number, invoices: [{ externalId: string, invoiceAmount: number, paidAmount: number, invoiceDate: number, dueDate: number, termsLink: string, payor: string, principalAmount: number, feeAmount: number, totalAmount: number }] }
FUNDING_LOAN (triggers after all funding attemps are executed){ funding: [{ businessExternalId: string, loanId: string, amount: number, availableCredit: number, type: 'FACTORING', transactionId: string }], total: number }
SUMMARY_OFFER (triggers after all funding is confirmed by the user){ funding: [{ businessExternalId: string, loanId: string, amount: number, availableCredit: number, type: 'FACTORING', transactionId: string }], total: number }
ERROR (triggers after a general error occurs){ error: string }

Subtitle prop

A prop confirmationMessages is available to override the text on the confirmation page. It accepts an array of strings with the template var {{amount}} will be replaced with total to factor formatted as currency value

<oatfi-factoring
  token="yourAuthToken"
  partnerId="partnerId"
  payeeExternalId="payeeExternalId"
  confirmationMessages='["You will receive <b>{{amount}}</b> deposited to your bank account on the next business day.", "We will schedule an ACH debit of <b>{{amount}}</b> from your bank account 30 days after the invoice due date to repay the factored amount plus fees."]'
/>

Onboarding

<oatfi-onboarding token="yourAuthToken" partnerid="partnerId" supportemail="supportEmail" />

The onboarding element offers 2 options, updating an existing business or creating one here are the examples of bot scenarios:

Updating

<oatfi-onboarding
  token="yourAuthToken"
  partnerid="partnerId"
  payorExternalId="payorExternalId"
  supportemail="supportEmail"
/>

Creating

In order to be able to create the business the token should be generated using the body (with the identifier set as partner)

{
  "businessExternalId": "externalId",
  "identifier": "partner"
}
<oatfi-onboarding token="yourAuthToken" partnerid="" supportemail="supportEmail" />

Product onboarding

In order to onboard a business for a specific product, it should be indicated with parameter productType="BNPL", possible values are "BNPL", "AR", "FACTORING", and "EWC", default value remains EWC

<oatfi-onboarding
  token="yourAuthToken"
  partnerid=""
  supportemail="supportEmail"
  productType="BNPL"
/>

Business General Info Conditional Fields

Approximate Monthly Spend

In order to make the field Approximate Monthly Spend required in Business form, you should pass the prop monthlySpendRequired="true"

<oatfi-onboarding
  token="yourAuthToken"
  partnerid=""
  supportemail="supportEmail"
  monthlySpendRequired="true"
/>

Annual Revenue

In order to make the field Annual Revenue required in Business form, you should pass the prop annualRevenueRequired="true"

<oatfi-onboarding
  token="yourAuthToken"
  partnerid=""
  supportemail="supportEmail"
  annualRevenueRequired="true"
/>

Underwriting at the end of the process

Onboarding has the option to execute underwriting at the end of the process, simply by setting the flag underwriting="true"

<oatfi-onboarding
  token="yourAuthToken"
  partnerid=""
  supportemail="supportEmail"
  underwriting="true"
/>

NOTE: Use with React and Typescript

If you are using custom-components with React along with Typescript, you should declare the incorporation of the custom-components into JSX IntrinsicElements interface

import * as React from 'react';

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'oatfi-factoring': React.DetailedHTMLProps<any>;
      'oatfi-bnpl': React.DetailedHTMLProps<any>;
    }
  }
}

THEMING

Our component accepts a theme prop to override some colors on the UI, this needs to be pased as a stringify JSON object.

<oatfi-bnpl
  token="yourAuthToken"
  partnerId="partnerId"
  supportEmail="supportEmail"
  payorExternalId="payorExternalId"
  invoiceExternalId="invoiceExternalId"
  theme='{"colors":{"primary":"green"}}'
/>

Theme options

Property NameUsage
primaryUsed as the primary color, main CTA background and primary buttons
primaryHoverUsed to set the background on hover of the primary elements
primaryPressedUsed to set the background on pressed of the primary elements
textPrimaryUsed to set the color of the overall app text
textSecondaryUsed to set the color of the subtitle of the cta
successUsed to set the color of success icon
successBackgroundUsed to set the color of success background Feedback card
warningUsed to set the color of warning icon
warningBackgroundUsed to set the color of warning background Feedback card
dangerUsed to set the color of danger icon
dangerBackgroundUsed to set the color of danger background Feedback card
neutral300Used to set the color of the disabled button
neutral200Used to set the background of the disabled button
infoUsed to set the background of the defered tag
tooltipColorUsed to set font color of the tooltips
tooltipBackgroundUsed to set the background of the tooltips
1.7.0-beta.1

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.7.0-alpha.1

1 year ago

1.7.0-alpha.2

1 year ago

1.4.4-beta.1

1 year ago

1.7.0

1 year ago

1.6.0-alpha.1

1 year ago

1.5.0

1 year ago

1.6.0-alpha.2

1 year ago

1.5.0-beta.1

1 year ago

1.5.0-alpha.1

1 year ago

1.5.0-alpha.2

1 year ago

1.6.0-beta.1

1 year ago

1.4.4-alpha.1

1 year ago

1.6.1-beta.1

1 year ago

1.6.1-alpha.1

1 year ago

1.5.0-alpha.3

1 year ago

1.5.0-alpha.4

1 year ago

1.5.0-alpha.5

1 year ago

1.5.0-alpha.6

1 year ago

1.4.0-alpha.1

2 years ago

1.4.0-alpha.2

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.2-alpha.1

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.4.2-alpha.3

2 years ago

1.4.2-alpha.2

2 years ago

1.4.3-alpha.2

2 years ago

1.4.3-alpha.1

2 years ago

1.4.0-beta.1

2 years ago

1.4.2-beta.1

2 years ago

1.4.1-beta.1

2 years ago

1.3.0-alpha.1

2 years ago

1.4.3-beta.1

2 years ago

1.4.1-alpha.1

2 years ago

1.4.1-alpha.2

2 years ago

1.3.0

2 years ago

1.4.1-alpha.3

2 years ago

1.4.1-alpha.4

2 years ago

1.4.1-alpha.5

2 years ago

1.4.1-alpha.6

2 years ago

1.3.0-beta.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-alpha.9

2 years ago

0.0.1-alpha.8

2 years ago

1.0.0-alpha.8

2 years ago

0.0.1-alpha.9

2 years ago

1.0.1-alpha.2

2 years ago

0.0.1-alpha.6

2 years ago

1.0.0-alpha.7

2 years ago

1.0.1-alpha.1

2 years ago

0.0.1-alpha.7

2 years ago

1.0.0-alpha.6

2 years ago

1.0.0-alpha.10

2 years ago

1.0.0-alpha.5

2 years ago

1.0.0-alpha.4

2 years ago

0.0.1-alpha.5

2 years ago

1.0.0-alpha.3

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.1-alpha.3

2 years ago

1.2.1-beta.1

2 years ago

1.2.0-beta.1

2 years ago

1.2.1-alpha.1

2 years ago

1.2.0-alpha.1

2 years ago

0.0.1-alpha.11

2 years ago

1.0.0-beta.2

2 years ago

1.0.1-beta.1

2 years ago

1.0.0-beta.3

2 years ago

1.0.0-beta.4

2 years ago

0.0.1-alpha.10

2 years ago

1.0.0-beta.1

2 years ago

1.1.0-alpha.1

2 years ago

1.1.0-beta.1

2 years ago

1.1.0-alpha.2

2 years ago

1.1.0-alpha.3

2 years ago

1.1.0-alpha.4

2 years ago

1.1.1-alpha.2

2 years ago

1.1.1-alpha.1

2 years ago

0.0.1-alpha.4

2 years ago

0.0.1-alpha.3

2 years ago

0.0.1-alpha.2

2 years ago

0.0.1-alpha.1

2 years ago