React Atlas Pay Library by Raven
React Atlas Pay by Raven bank allows you recieve payments and build powerful checkout experience on your react web apps, to use this you will need to create an account on raven atlas, visit, "Raven bank" for more.
Live Demo
✨ Features
- Card Payments. (Visa, MasterCard)
- USSD Payment.
- Bank Transfers.
- Pay with Raven.
Installation:
npm install react-atlas-pay
or
```bash
yarn add react-atlas-pay
Usage :
React Atlas Pay Uses normal react Conventions and Exposes for you a useAtlasPay
Hook, below is an example usage
import { useEffect, useState } from 'react'
import useAtlasPay from 'react-atlas-pay'
export default function App() {
const [pay, atlasEvent] = useAtlasPay()
const config = {
customer_email: 'john@example.com',
description: 'test payment',
merchant_ref: 'your_merchant_reference',
amount: 100,
redirect_url: '',
payment_methods: 'card,bank_transfer,ussd,raven',
public_key: 'your_atlas_public_key'
}
useEffect(() => {
if (atlasEvent.type === 'onClose') {
}
if (atlasEvent.type === 'onLoad') {
}
if (atlasEvent.type === 'onSuccess') {
pay({ shutdown: true })
}
}, [atlasEvent])
return (
<div
onClick={() => {
pay(config)
}}
className=""
>
Pay Button
{/* Clicking on this button will generate a payment request and initializes the payment window */}
</div>
)
}
If you don't need to generate a new payment request, 'i.e already have a payment reference', you can initialize the payment window directly py parsing the trx_ref
as shown below.
<div
onClick={() => {
pay({ trx_ref: 'your_payment_reference' })
}}
className=""
>
{}
</div>
React Atlas Pay Library can also be used in a NextJS Environment but requires extra configuration, AtlasPay offers AtlasNext
which is NextJS Wrapper for AtlasPay to make use of this you need to call it either within your _app.tsx
or _document.tsx
this can be found in your nextjs src
folder, below is an example usage;
import { Manrope } from "@next/font/google";
import type { AppProps } from "next/app";
import Head from "next/head";
import {AtlasNext} from "react-atlas-pay";
const manrope = Manrope({ subsets: ["latin"] });
export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<main className={manrope.className}>
<Component {...props.pageProps} />
</main>
<AtlasNext/> {/* Here we instantiate the AtlasNext Wrapper */}
);
}
License
AtlasPay by Raven bank is licensed under the MIT