Created
June 5, 2022 17:22
-
-
Save NeoHBz/532b0301c31153089ed31e9829937981 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback } from "react"; | |
import { Button } from "@chakra-ui/react"; | |
import useRazorpay from "react-razorpay"; | |
export default function Pay() { | |
const Razorpay = useRazorpay(); | |
const handlePayment = useCallback(async () => { | |
const order = { | |
id: "order_JZtmToLbdp5p2F", | |
entity: "order", | |
amount: 315000, | |
amount_paid: 0, | |
amount_due: 315000, | |
currency: "INR", | |
receipt: null, | |
offer_id: null, | |
status: "created", | |
attempts: 0, | |
notes: { | |
orderId: "11", | |
}, | |
created_at: 1653577390, | |
}; | |
const options = { | |
key: "rzp_test_geb28z2BjD98tb", | |
amount: "3000", | |
currency: "INR", | |
name: "Acme Corp", | |
description: "Test Transaction", | |
image: "https://example.com/your_logo", | |
order_id: order.id, | |
handler: (res) => { | |
console.log(res); | |
}, | |
prefill: { | |
name: "Piyush Garg", | |
email: "youremail@example.com", | |
contact: "9999999999", | |
}, | |
notes: { | |
service: "123", | |
type: "onboarding", | |
}, | |
theme: { | |
color: "#3399cc", | |
}, | |
}; | |
const rzpay = new Razorpay(options); | |
rzpay.open(); | |
}, [Razorpay]); | |
return ( | |
<> | |
Pay | |
<Button onClick={handlePayment}>Pay</Button> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment