feat: add razorpay
This commit is contained in:
@@ -80,19 +80,29 @@ const ShoppingCart = () => {
|
||||
return <EmptyCart />;
|
||||
}
|
||||
|
||||
const handlePaymentSuccess = async (order) => {
|
||||
console.log("Payment SuccessFul", order);
|
||||
const response = await authAxios.post("/orders/payment/", {
|
||||
orderId: order.id,
|
||||
payer_mail: order.payer.email_address,
|
||||
address: order.purchase_units[0].shipping.address,
|
||||
name: order.purchase_units[0].shipping.name.full_name,
|
||||
cartId: cartItems[0].id,
|
||||
});
|
||||
router.push('/accounts/profile/orders')
|
||||
toast.success('You Order Is Successfull!')
|
||||
console.log(response);
|
||||
const handlePaymentSuccess = async (response) => {
|
||||
console.log("Payment Successful", response);
|
||||
|
||||
const { razorpay_payment_id, razorpay_order_id, razorpay_signature } = response;
|
||||
|
||||
try {
|
||||
const paymentData = {
|
||||
paymentId: razorpay_payment_id,
|
||||
orderId: razorpay_order_id,
|
||||
signature: razorpay_signature,
|
||||
cartId: cartItems[0].id,
|
||||
};
|
||||
|
||||
const apiResponse = await authAxios.post("/orders/payment/", paymentData);
|
||||
router.push("/accounts/profile/orders");
|
||||
toast.success("Your Order Is Successful!");
|
||||
console.log(apiResponse);
|
||||
} catch (error) {
|
||||
console.error("Error processing payment:", error);
|
||||
toast.error("Payment processing failed. Please try again.");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="w-full bg-white">
|
||||
<div className="w-full px-4 md:px-8 max-w-[1600px] mx-auto font-['Inter']">
|
||||
|
||||
Reference in New Issue
Block a user