function retrieveSession({ sessionId }) { return stripeInstance.checkout.sessions.retrieve(sessionId, { expand: ['payment_intent', 'payment_intent.payment_method'], }); }
function createSession({ userId, bookId, bookSlug, userEmail, redirectUrl }) { // console.log(`redirectUrl at createSession: ${redirectUrl}`); console.log(userId, bookId, bookSlug, userEmail, redirectUrl); return stripeInstance.checkout.sessions.create({ customer_email: userEmail, payment_method_types: ['card'], mode: 'payment', line_items: [{ price: getBookPriceId(bookSlug), quantity: 1 }], success_url: `${ROOT_URL}/stripe/checkout-completed/{CHECKOUT_SESSION_ID}`, cancel_url: `${ROOT_URL}${redirectUrl}?checkout_canceled=1`, metadata: { userId, bookId, redirectUrl }, }); }
When('I go to checkout', () => { I.checkout(); });
describe('#.checkout()', function () { it('should throw TypeError if duration is not a number', function () { expect(function () { return node.checkout(null); }).to.throw(TypeError); expect(function () { return node.checkout(NaN); }).to.throw(TypeError); expect(function () { return node.checkout('xx'); }).to.throw(TypeError); expect(function () { return node.checkout([]); }).to.throw(TypeError); expect(function () { return node.checkout({}); }).to.throw(TypeError); expect(function () { return node.checkout(true); }).to.throw(TypeError); expect(function () { return node.checkout(new Date()); }).to.throw(TypeError); expect(function () { return node.checkout(100); }).not.to.throw(TypeError); }); });
handleAddProductToCart(variant) { if (process.env.IS_BROWSER) window.ga('send', 'event', 'Page Interaction', 'click'); const checkoutId = this.props.checkout.id; const lineItems= [{ variantId: variant.variantId, quantity: parseInt(1, 10)}] this.props.fetchAddStoreCheckout(checkoutId, lineItems); const title = variant.title; const image = variant.image; // this.showModal(title, image); // redirect to cart via react-router or history so don't lose free shirt cart item this.props.handleClose(); }
ajaxRouter.put('/cart/checkout', (req, res, next) => { const order_id = req.signedCookies.order_id; if (order_id) { api.orders.checkout(order_id).then(cartResponse => fillCartItems(cartResponse)).then(({status, json}) => { res.clearCookie('order_id'); res.status(status).send(json); }) } else { res.end(); } });
const mapStateToProps = state => { return { totalPrice : state.totalPrice, checkout: state.checkout, subtotal: state.subtotal, dishes: state.dishes } }
const CartContainer = ({ products, total, checkout }) => ( <Cart products={products} total={total} onCheckoutClicked={() => checkout(products)} /> )
this.setState(prevState => ({ ...prevState, checkout: { ...prevState.checkout, cupom: cupomState } }));
handleAddProductToCart(variant) { if (process.env.IS_BROWSER) window.ga('send', 'event', 'Page Interaction', 'click'); const checkoutId = this.props.checkout.id; const lineItems= [{ variantId: variant.variantId, quantity: parseInt(1, 10)}] this.props.fetchAddStoreCheckout(checkoutId, lineItems); const title = variant.title; const image = variant.image; this.showModal(title, image); }
function retrieveSession({ sessionId }) { return stripeInstance.checkout.sessions.retrieve(sessionId, { expand: ['payment_intent', 'payment_intent.payment_method'], }); }
function createSession({ userId, bookId, bookSlug, userEmail, redirectUrl }) { // console.log(`redirectUrl at createSession: ${redirectUrl}`); console.log(userId, bookId, bookSlug, userEmail, redirectUrl); return stripeInstance.checkout.sessions.create({ customer_email: userEmail, payment_method_types: ['card'], mode: 'payment', line_items: [{ price: getBookPriceId(bookSlug), quantity: 1 }], success_url: `${ROOT_URL}/stripe/checkout-completed/{CHECKOUT_SESSION_ID}`, cancel_url: `${ROOT_URL}${redirectUrl}?checkout_canceled=1`, metadata: { userId, bookId, redirectUrl }, }); }
const CartContainer = ({ products, total, checkout }) => ( <Cart products={products} total={total} onCheckoutClicked={() => checkout(products)} /> )