1.15.4 • Published 6 days ago

@oatfi/react-js v1.15.4

Weekly downloads
-
License
MIT
Repository
-
Last release
6 days ago

Oatfi React-js

React JS components that enables OatFi flows to defer payments.

Requirements

The minimum supported version of React is v16.8. If you use an older version, upgrade React to use this library

Getting started

First Install OatFi-React-JS

npm install --save @oatfi/react-js

BNPL

Our package relies on our OatFiProvider that will handle our context for Oatfi transactions

Minimal example

import React from "react";
import ReactDOM from "react-dom";
import { BNPL, OatFiProvider } from "@oatfi/react-js";

// Obtain token authenticating in the api with your PK and Business Id
const partnerId = "629fe7c0f15794e7fe7e73d8";
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....";
const invoiceExternalId = "2260c633-56e6-482b-ae88-a54af97a8587";
const payorExternalId = "f89449d7-fdfb-4151-a5d9-20da5f5eae92";
const supportEmail="support@email.com"

const App = () => (
  <OatFiProvider token={token} partnerId={partnerId} supportEmail={supportEmail}>
    <BNPL
      payorExternalId={payorExternalId}
      invoiceExternalId={invoiceExternalId}
    />
  </OatFiProvider>
);

ReactDOM.render(<App />, document.body);

Stage example

OatFiProvider component accepts a sandbox prop to run the service over our stage environment

import React from "react";
import ReactDOM from "react-dom";
import { BNPL, OatFiProvider } from "@oatfi/react-js";

// Obtain token authenticating in the api with your PK and Business Id
const partnerId = "629fe7c0f15794e7fe7e73d8";
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....";
const invoiceExternalId = "2260c633-56e6-482b-ae88-a54af97a8587";
const payorExternalId = "f89449d7-fdfb-4151-a5d9-20da5f5eae92";

const App = () => (
  <OatFiProvider token={token} partnerId={partnerId} sandbox>
    <BNPL
      payorExternalId={payorExternalId}
      invoiceExternalId={invoiceExternalId}
    />
  </OatFiProvider>
);

ReactDOM.render(<App />, document.body);

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
underWritingNone
presentOfferunderWritting is required
fundpresentOffer is required

By default all steps are enabled.

Usage example

 <BNPL
  payorExternalId={payorExternalId}
  invoiceExternalId={invoiceExternalId}
  steps={{fund:false}}
/>

Theme example

OatFiProvider component accepts a theme prop to override some colors on the UI

import React from "react";
import ReactDOM from "react-dom";
import { BNPL, OatFiProvider } from "@oatfi/react-js";

// Obtain token authenticating in the api with your PK and Business Id
const partnerId = "629fe7c0f15794e7fe7e73d8";
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9....";
const invoiceExternalId = "2260c633-56e6-482b-ae88-a54af97a8587";
const payorExternalId = "f89449d7-fdfb-4151-a5d9-20da5f5eae92";

const theme = {
  colors: {
    primary: "blue",
  },
};

const App = () => (
  <OatFiProvider token={token} partnerId={partnerId} theme={theme}>
    <BNPL
      payorExternalId={payorExternalId}
      invoiceExternalId={invoiceExternalId}
    />
  </OatFiProvider>
);

ReactDOM.render(<App />, document.body);

Callback logic

BNPL component receives a prop name eventCallback this is a function that needs to have the signature eventCallback(event,data) the package exports a enum of possible events called BNPL_EVENTS. usage example:

import { BNPL, OatFiProvider, BNPL_EVENTS } from '@oatfi/react-js';

const eventCallback = (event: BNPL_EVENTS, data: any) => {
  switch (event) {
    case BNPL_EVENTS.CLOSE_DRAWER: //DO SOMETHING
      break;
    case BNPL_EVENTS.UNDER_WRITTING: //DO SOMETHING
      break;
    case BNPL_EVENTS.DEFER: //DO SOMETHING
      break;
    case BNPL_EVENTS.DEFER_ERROR: //DO SOMETHING
      break;
  }
};

<BNPL
  payorExternalId={payorExternalId}
  invoiceExternalId={invoiceExternalId}
  eventCallback={eventCallback}
/>

BNPL Events

Eventdata
CLOSE_DRAWER (triggers on closing the drawer){}
UNDER_WRITTING (triggers on closing drawer after flow without running funding){}
DEFER (triggers on closing drawer after funding){ invoiceExternalId, amount, payInvoiceOnDate, totalAmount,repaymentDate }
DEFER_ERROR (triggers on closing drawer after funding with error){ error }

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)

<BNPL
  payorExternalId={payorExternalId}
  invoiceExternalId={invoiceExternalId}
  subtitle='Custom subt'
/>

THEMING

OatFiProvider component accepts a theme prop to override some colors on the UI

const theme = {
  colors: {
    primary: "blue"
  }
};

<OatFiProvider token={auth.accessToken} partnerId={auth.partnerId} theme={theme}>
  ...
</OatFiProvider>
  

Result:

blueTheme.png

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

TypeScript support

OatFi React JS is packaged with TypeScript declarations.

License

MIT License

Copyright (c) 2024 Oat Financial, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.15.3-alpha.2

7 days ago

1.15.3-alpha.3

7 days ago

1.15.4

6 days ago

1.15.3-beta.2

6 days ago

1.15.3-alpha.1

9 months ago

1.14.2

10 months ago

1.14.2-alpha.1

11 months ago

1.15.0-beta.1

10 months ago

1.15.1-beta.1

10 months ago

1.15.0

10 months ago

1.15.3

9 months ago

1.15.2

9 months ago

1.15.1

10 months ago

1.14.2-beta.1

11 months ago

1.15.0-alpha.2

10 months ago

1.15.0-alpha.1

10 months ago

1.15.1-alpha.1

10 months ago

1.15.1-alpha.2

10 months ago

1.15.3-beta.1

9 months ago

1.15.2-beta.1

9 months ago

1.15.2-alpha.2

9 months ago

1.15.2-alpha.1

9 months ago

1.14.1-alpha.3

11 months ago

1.14.1

11 months ago

1.14.1-alpha.2

11 months ago

1.14.1-alpha.1

11 months ago

1.14.1-beta.1

11 months ago

1.14.0

1 year ago

1.12.0-beta.1

1 year ago

1.12.0-beta.2

1 year ago

1.12.0-beta.3

1 year ago

1.12.3-alpha.1

1 year ago

1.13.0-alpha.2

1 year ago

1.13.0-alpha.3

1 year ago

1.13.0-alpha.1

1 year ago

1.14.0-beta.1

1 year ago

1.12.2-alpha.2

1 year ago

1.12.2-alpha.1

1 year ago

1.13.0-beta.1

1 year ago

1.13.1-beta.1

1 year ago

1.13.1-alpha.7

1 year ago

1.13.1-alpha.4

1 year ago

1.13.1-alpha.3

1 year ago

1.13.1-alpha.6

1 year ago

1.13.1-alpha.5

1 year ago

1.13.1-alpha.2

1 year ago

1.13.1-alpha.1

1 year ago

1.12.2

1 year ago

1.12.1

1 year ago

1.12.0

1 year ago

1.12.1-alpha.1

1 year ago

1.14.0-alpha.1

1 year ago

1.12.0-alpha.3

1 year ago

1.13.1

1 year ago

1.12.0-alpha.4

1 year ago

1.13.0

1 year ago

1.12.0-alpha.2

1 year ago

1.12.0-alpha.9

1 year ago

1.12.0-alpha.7

1 year ago

1.12.0-alpha.8

1 year ago

1.12.0-alpha.5

1 year ago

1.12.0-alpha.6

1 year ago

1.11.2-beta.1

1 year ago

1.11.1-alpha.2

1 year ago

1.11.1-alpha.1

1 year ago

1.11.3

1 year ago

1.11.2

1 year ago

1.11.1

1 year ago

1.11.2-alpha.2

1 year ago

1.11.2-alpha.3

1 year ago

1.11.2-alpha.1

1 year ago

1.11.2-alpha.4

1 year ago

1.11.2-alpha.5

1 year ago

1.11.3-alpha.1

1 year ago

1.11.0

1 year ago

1.12.0-alpha.1

1 year ago

1.11.3-beta.1

1 year ago

1.11.0-alpha.1

1 year ago

1.11.2-beta.2

1 year ago

1.11.1-beta.1

1 year ago

1.11.0-beta.1

1 year ago

1.10.3

1 year ago

1.10.3-beta.1

1 year ago

1.10.3-alpha.2

1 year ago

1.10.3-alpha.1

1 year ago

1.10.2

1 year ago

1.10.2-beta.1

1 year ago

1.10.1-alpha.6

1 year ago

1.10.1-alpha.5

1 year ago

1.10.1-alpha.4

1 year ago

1.10.1-alpha.3

1 year ago

1.10.1-alpha.2

1 year ago

1.10.1-beta.1

1 year ago

1.10.1-alpha.1

1 year ago

1.10.0

1 year ago

1.10.0-alpha.4

1 year ago

1.10.0-alpha.3

1 year ago

1.10.0-alpha.2

1 year ago

1.10.0-alpha.1

1 year ago

1.9.0

1 year ago

1.9.0-beta.2

1 year ago

1.9.0-alpha.11

1 year ago

1.9.0-beta.1

1 year ago

1.9.0-alpha.10

1 year ago

1.9.0-alpha.9

1 year ago

1.9.0-alpha.8

1 year ago

1.9.0-alpha.7

1 year ago

1.9.0-alpha.6

1 year ago

1.9.0-alpha.5

1 year ago

1.9.0-alpha.4

1 year ago

1.9.0-alpha.3

1 year ago

1.9.0-alpha.2

1 year ago

1.9.0-alpha.1

1 year ago

1.8.1-alpha.9

1 year ago

1.8.1-alpha.8

1 year ago

1.8.1-alpha.7

1 year ago

1.8.1-alpha.6

1 year ago

1.8.1-alpha.5

1 year ago

1.8.1-alpha.4

1 year ago

1.8.1-alpha.3

1 year ago

1.8.1-alpha.2

1 year ago

1.8.1-alpha.1

1 year ago

1.8.0

1 year ago

1.8.0-alpha.16

1 year ago

1.8.0-beta.1

1 year ago

1.8.0-alpha.15

1 year ago

1.8.0-alpha.14

1 year ago

1.8.0-alpha.13

1 year ago

1.8.0-alpha.12

1 year ago

1.8.0-alpha.11

1 year ago

1.8.0-alpha.10

1 year ago

1.8.0-alpha.9

1 year ago

1.8.0-alpha.8

1 year ago

1.8.0-alpha.7

1 year ago

1.8.0-alpha.6

1 year ago

1.8.0-alpha.5

1 year ago

1.8.0-alpha.4

1 year ago

1.8.0-alpha.3

1 year ago

1.8.0-alpha.2

1 year ago

1.8.0-alpha.1

1 year ago

1.7.0-beta.2

1 year ago

1.7.0-alpha.16

1 year ago

1.7.0

1 year ago

1.7.0-beta.1

1 year ago

1.7.0-alpha.15

1 year ago

1.7.0-alpha.14

1 year ago

1.7.0-alpha.13

1 year ago

1.7.0-alpha.12

1 year ago

1.7.0-alpha.11

1 year ago

1.7.0-alpha.10

1 year ago

1.7.0-alpha.9

1 year ago

1.7.0-alpha.8

1 year ago

1.7.0-alpha.7

1 year ago

1.7.0-alpha.6

1 year ago

1.7.0-alpha.5

1 year ago

1.7.0-alpha.4

1 year ago

1.7.0-alpha.3

1 year ago

1.7.0-alpha.2

1 year ago

1.7.0-alpha.1

1 year ago

1.6.0

2 years ago

1.6.0-beta.1

2 years ago

1.6.0-alpha.1

2 years ago