May 2018
Intermediate to advanced
470 pages
13h 54m
English
The Place Order button is also placed in the PlaceOrder component after the CardElement.
mern-marketplace/client/cart/PlaceOrder.js:
<Button color="secondary" variant="raised" onClick={this.placeOrder}>Place Order</Button>
Clicking on the Place Order button will call the placeOrder method, which will attempt to tokenize the card details using stripe.createToken. If unsuccessful, the user will be informed of the error, but if successful, then the checkout details and generated card token will be sent to our server's create order API (covered in the next section).
mern-marketplace/client/cart/PlaceOrder.js:
placeOrder = ()=>{ this.props.stripe.createToken().then(payload => { if(payload.error){ this.setState({error: payload.error.message}) ...Read now
Unlock full access