Receive payments on a React App
This article guides us through the process of initializing Asyncpay checkout and receiving payments on a React Application.
Introduction
Before you begin
Set up the Next Project
npx create-next-app@latestCreate a form to collect payments
"use client";
import { useState } from "react";
export default function Home() {
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
const [email, setEmail] = useState("");
const [amount, setAmount] = useState("");
const handleCheckout = (e) => {
e.preventDefault()
};
return (
<section>
<h1>A Simple Asyncpay Checkout</h1>
<hr />
<form onSubmit={handleCheckout}>
<div>
<label htmlFor="firstName">First Name</label>
<input
name="firstName"
type="text"
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
/>
</div>
<div>
<label htmlFor="lastName">Last Name</label>
<input
name="lastName"
type="text"
value={lastName}
onChange={(e) => setLastName(e.target.value)}
/>
</div>
<div>
<label htmlFor="email">Email</label>
<input
name="email"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
<div>
<label htmlFor={"amount"}>Amount</label>
<input
type="number"
name={"amount"}
value={amount}
onChange={(e) => setAmount(e.target.value)}
/>
</div>
<div>
<button>Pay NGN {amount}</button>
</div>
</form>
</section>
);
}
Install Asyncpay CheckoutJS
Conclusion
Last updated