для оплаты
This commit is contained in:
@@ -25,9 +25,12 @@ export function CheckoutForm() {
|
|||||||
const { items, clearCart } = useCart()
|
const { items, clearCart } = useCart()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
|
// Log the cart items to make sure they are correct
|
||||||
|
console.log("Cart items:", items)
|
||||||
|
|
||||||
// Define the getTotalPrice function inside the component
|
// Define the getTotalPrice function inside the component
|
||||||
const getTotalPrice = () => {
|
const getTotalPrice = () => {
|
||||||
return items.reduce((total, item) => total + item.price * item.quantity, 0)
|
return items.reduce((total, item) => total + item.price * item.quantity, 0).toFixed(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAddressSubmit = (e: React.FormEvent) => {
|
const handleAddressSubmit = (e: React.FormEvent) => {
|
||||||
@@ -40,7 +43,9 @@ export function CheckoutForm() {
|
|||||||
const handlePayment = async () => {
|
const handlePayment = async () => {
|
||||||
setIsProcessing(true)
|
setIsProcessing(true)
|
||||||
const totalPrice = getTotalPrice() // Calculate total price here
|
const totalPrice = getTotalPrice() // Calculate total price here
|
||||||
const paymentSuccess = await processYooMoneyPayment(totalPrice)
|
console.log("Total Price:", totalPrice) // Log the total price to check
|
||||||
|
|
||||||
|
const paymentSuccess = await processYooMoneyPayment(Number(totalPrice))
|
||||||
|
|
||||||
if (paymentSuccess) {
|
if (paymentSuccess) {
|
||||||
setIsOrderPlaced(true)
|
setIsOrderPlaced(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user