Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue Button On Payment Method Screen Not Working #87

Open
ghost opened this issue May 5, 2021 · 14 comments
Open

Continue Button On Payment Method Screen Not Working #87

ghost opened this issue May 5, 2021 · 14 comments

Comments

@ghost
Copy link

ghost commented May 5, 2021

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

@mohitshahu108
Copy link

check sumbithandler.

@ghost
Copy link
Author

ghost commented May 6, 2021 via email

@mohitshahu108
Copy link

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
Copy link
Author

ghost commented May 7, 2021

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
Copy link
Author

ghost commented May 7, 2021

Do I need to have history as a prop?

@mohitshahu108
Copy link

mohitshahu108 commented May 23, 2021

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
Copy link

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





<input
type="radio"
id="paypal"
value="PayPal"
name="paymentMethod"
required
checked
onChange={(e) => setPaymentMethod(e.target.value)}
/>
Paypal


<input
type="radio"
id="stripe"
value="Stripe"
name="paymentMethod"
required
onChange={(e) => setPaymentMethod(e.target.value)}
/>
Stripe



Continue



);
}

@mohitshahu108
Copy link

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

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

@mohitshahu108
Copy link

i have completed that application

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

@GarvitSharma870
Copy link

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
Copy link

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
Copy link
Author

ghost commented Aug 15, 2021 via email

@GarvitSharma870
Copy link

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
Copy link
Author

ghost commented Aug 15, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants