0.3.0 • Published 10 months ago

@farayolaj/react-remita-inline v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

React Remita Inline

This is a wrapper around Remita Inline SDK for React projects.

Install

NPM

npm install @farayolaj/react-remita-inline

Yarn

yarn add @farayolaj/react-remita-inline

PNPM

pnpm add @farayolaj/react-remita-inline

Usage

  1. Imperative API.
import { useRemitaInline } from "@farayolaj/react-remita-inline";

function Example() {
  const { initPayment } = useRemitaInline({
    isLive: false,
    onClose() {
      console.log("Remita closed");
    },
    onError(response) {
      console.log("Remita Error: ", response);
    },
    onSuccess(response) {
      console.log("Remita Success: ", response);
    },
  });

  return (
    <button
      onClick={() =>
        initPayment({
          key: config.remita.publicKey,
          transactionId: String(Math.floor(Math.random() * 1101233)),
          amount: 10000,
          customerId: "johndoe@gmail.com",
          narration: "Payment for groceries.",
          email: "johndoe@gmail.com",
          firstName: "John",
          lastName: "Doe",
        })
      }
    >
      Checkout
    </button>
  );
}
  1. Declarative API.
import { useRemitaInline } from "@farayolaj/react-remita-inline";

function Example() {
  const { RemitaInlineButton } = useRemitaInline({
    isLive: false,
    onClose() {
      console.log("Remita closed");
    },
    onError(response) {
      console.log("Remita Error: ", response);
    },
    onSuccess(response) {
      console.log("Remita Success: ", response);
    },
  });

  return (
    <RemitaInlineButton
      data={{
        key: config.remita.publicKey,
        transactionId: String(Math.floor(Math.random() * 1101233)),
        amount: 10000,
        customerId: "johndoe@gmail.com",
        narration: "Payment for groceries.",
        email: "johndoe@gmail.com",
        firstName: "John",
        lastName: "Doe",
      }}
      className="button-primary"
      text="Checkout"
    />
  );
}

Types

UseRemitaInlineProps

useRemitaInline(UseRemitaInlineProps)

PropertyTypeDefaultDescriptionRequired
isLivebooleanUse demo or live SDK.true
onSuccessFunctionCallback for successful payment.false
onErrorFunctionCallback for error during payment.false
onCloseFunctionCallback for payment modal close.false

RemitaInlineButtonProps

<RemitaInlineButton {...RemitaInlineButtonProps} />

PropertyTypeDefaultDescriptionRequired
dataRemitaInlineDataOptions needed by Remita.true
classNamestringClass names for styling.false
textstring"Pay"Text to show in button.false

RemitaInlineData

Options needed by Remita Inline SDK. More information about this here.

0.3.0

10 months ago

0.2.0

10 months ago

0.1.0

10 months ago