basir / amazona

Build Ecommerce Like Amazon By MERN Stack
https://www.udemy.com/course/build-ecommerce-website-like-amazon-react-node-mongodb
596 stars 483 forks source link

Continue Button On Payment Method Screen Not Working #87

Open ghost opened 3 years ago

ghost commented 3 years ago

The Continue button on Payment Method Screen (PayPal/Stripe) is not working or redirecting to Place Order Screen.

mohitshahu108 commented 3 years ago

check sumbithandler.

ghost commented 3 years ago

const submitHandler = (e) => { e.preventDefault(); dispatch(savePaymentMethod(paymentMethod)); props.history.push(‘/placeorder’); };

Sent from my iPhone

On May 5, 2021, at 8:16 PM, mohitshahu108 @.***> wrote:

check sumbithandler.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

mohitshahu108 commented 3 years ago

where did you have put that

on form or button if you have put it in form then use onSubmit event for button use onClick event

ghost commented 3 years ago

mohitshahu,

I appreciate your reply. I believe on form but I am not sure. Please take a look at my code if you can and thank you very much for your help.

import React, { useState } from 'react' import { useDispatch, useSelector } from 'react-redux'; import { savePaymentMethod } from '../actions/cartActions'; import CheckoutSteps from '../components/CheckoutSteps';

export default function PaymentMethodScreen(props) { const cart = useSelector((state) => state.cart); const { shippingAddress } = cart; if (!shippingAddress.address) { props.history.push('/shipping'); } const [paymentMethod, setPaymentMethod] = useState('PayPal'); const dispatch = useDispatch(); const submitHandler = (e) => { e.preventDefault(); dispatch(savePaymentMethod(paymentMethod)); props.history.push('/placeorder'); };

ghost commented 3 years ago

Do I need to have history as a prop?

mohitshahu108 commented 3 years ago

sorry for the late response buddy

Do I need to have history as a prop? :: no not at history is property of props object. we can assess it like props.history.

mohitshahu108 commented 3 years ago

After going through your code I didn't find any issue. After all, I am also a beginner 😂.

Here is my code, if it can help import React, { useState } from "react"; import CheckoutSteps from "../CheckoutSteps/CheckoutSteps"; import { useDispatch, useSelector } from "react-redux"; import { savePaymentMethod } from "../../../redux/actions/cartActions";

export default function PaymentMethodScreen(props) { const cart = useSelector((state) => state.cart); const { shippingAddress } = cart; if(!shippingAddress.address){ props.history.push('/shipping'); } const [paymentMethod, setPaymentMethod] = useState("PayPal"); const dispatch = useDispatch(); const submintHandler = (e) => { e.preventDefault(); dispatch(savePaymentMethod(paymentMethod)); props.history.push("/placeorder"); }; return (

Payment

setPaymentMethod(e.target.value)} />
setPaymentMethod(e.target.value)} />

); }

mohitshahu108 commented 3 years ago

Try it multiple times don't give up it will work

code didn't help then you should check savePaymentMethod did work properly

mohitshahu108 commented 3 years ago

i have completed that application

deployed over heruko https://tech360i.herokuapp.com/

GarvitSharma870 commented 3 years ago

Hllo mohitsahu I will also got error after deploying on heroku my products not showing after deploy on heroku in local host it will saw but when I connect with online MongoDB atlas it will not show please help me

GarvitSharma870 commented 3 years ago

i have completed that application

deployed over heruko https://tech360i.herokuapp.com/

Hllo please help me when I deploy it to heroku and when I will connect with MongoDB atlas it will not insert my sample users and product into online MongoDB atlas database so i will copy paste products data manually it will show product but when I click on product It will show error product not found can you help me to solve this. And when I register as newbuddy it insert data in online database and also signin works with that .

ghost commented 3 years ago

mohitshahu108,

I apologize for the very late response. I also have since completed the project and I really appreciate your help. Great job with the website!

Thank you

Sent from my iPhone

On May 23, 2021, at 3:13 AM, mohitshahu108 @.***> wrote:

i have completed that application

deployed over heruko https://tech360i.herokuapp.com/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

GarvitSharma870 commented 3 years ago

mohitshahu108, I apologize for the very late response. I also have since completed the project and I really appreciate your help. Great job with the website! Thank you Sent from my iPhone On May 23, 2021, at 3:13 AM, mohitshahu108 @.***> wrote: i have completed that application deployed over heruko https://tech360i.herokuapp.com/ — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Hey DmoniqueMCasteneda ,please help me when I deploy it to heroku and when I will connect with MongoDB atlas it will not insert my sample users and product into online MongoDB atlas database so i will copy paste products data manually it will show product but when I click on product It will show error product not found can you help me to solve this. And when I register as newbuddy it insert data in online database and also signin works with that .

ghost commented 3 years ago

GarvitSharma870,

Please make sure that you are creating the product from a profile that is a Seller and that the ID’s for the user and product match in MongoDB. If they do not match you will receive an error message.

Sent from my iPhone

On Aug 14, 2021, at 10:57 PM, GarvitSharma870 @.***> wrote:

mohitshahu108, I apologize for the very late response. I also have since completed the project and I really appreciate your help. Great job with the website! Thank you … Sent from my iPhone On May 23, 2021, at 3:13 AM, mohitshahu108 @.***> wrote: i have completed that application deployed over heruko https://tech360i.herokuapp.com/ — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Hey DmoniqueMCasteneda ,please help me when I deploy it to heroku and when I will connect with MongoDB atlas it will not insert my sample users and product into online MongoDB atlas database so i will copy paste products data manually it will show product but when I click on product It will show error product not found can you help me to solve this. And when I register as newbuddy it insert data in online database and also signin works with that .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.