fixing stripe context
This commit is contained in:
parent
d6086829fc
commit
5f0003b7e2
1 changed files with 5 additions and 5 deletions
|
|
@ -2,7 +2,7 @@ import React, { createContext, useContext, useEffect, useState } from 'react';
|
|||
import { loadStripe } from '@stripe/stripe-js';
|
||||
import { Elements } from '@stripe/react-stripe-js';
|
||||
import config from '../config';
|
||||
import apiClient from '@services/api';
|
||||
import apiClient from '@services';
|
||||
|
||||
// Create the context
|
||||
const StripeContext = createContext();
|
||||
|
|
@ -20,7 +20,7 @@ export const StripeProvider = ({ children }) => {
|
|||
// If not found, fetch from API
|
||||
if (!publicKey) {
|
||||
// Fetch Stripe public key from backend
|
||||
apiClient.get('/api/payment/config')
|
||||
apiClient.get('/payment/config')
|
||||
.then(response => {
|
||||
if (response.data.stripePublicKey) {
|
||||
loadStripeInstance(response.data.stripePublicKey);
|
||||
|
|
@ -54,7 +54,7 @@ export const StripeProvider = ({ children }) => {
|
|||
// Create a checkout session
|
||||
const createCheckoutSession = async (cartItems, orderId, shippingAddress, userId) => {
|
||||
try {
|
||||
const response = await apiClient.post('/api/payment/create-checkout-session', {
|
||||
const response = await apiClient.post('/payment/create-checkout-session', {
|
||||
cartItems,
|
||||
orderId,
|
||||
shippingAddress,
|
||||
|
|
@ -71,7 +71,7 @@ export const StripeProvider = ({ children }) => {
|
|||
// Check session status
|
||||
const checkSessionStatus = async (sessionId) => {
|
||||
try {
|
||||
const response = await apiClient.get(`/api/payment/session-status/${sessionId}`);
|
||||
const response = await apiClient.get(`/payment/session-status/${sessionId}`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
console.error('Error checking session status:', err);
|
||||
|
|
@ -82,7 +82,7 @@ export const StripeProvider = ({ children }) => {
|
|||
// Complete the order after successful payment
|
||||
const completeOrder = async (orderId, sessionId, userId) => {
|
||||
try {
|
||||
const response = await apiClient.post('/api/cart/complete-checkout', {
|
||||
const response = await apiClient.post('/cart/complete-checkout', {
|
||||
orderId,
|
||||
sessionId,
|
||||
userId
|
||||
|
|
|
|||
Loading…
Reference in a new issue