source: frontend/src/services/payment-service.jsx@ badbc79

Last change on this file since badbc79 was badbc79, checked in by Luka Cheshlarov <luka.cheshlarov@…>, 20 months ago

Initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import axios from "axios";
2
3const paymentRoute = "/payments";
4
5const PaymentType = {
6 Cash: 'Cash',
7 DebitCard: 'DebitCard',
8 CreditCard: 'CreditCard',
9}
10
11const PublishableStripeKey = 'pk_test_51HCrb4D91Y2Imm1bXKM17hthwdzbY5W8r3e2bCXFQY0ifZHPnbptfL2hEHL1g4EoxBu3SRU2E5W0yVg8sewXHBsQ00fRpqLFzM';
12
13const GetAllPayments = async () => {
14 try {
15 const response = await axios.get(paymentRoute);
16 return response.data;
17 } catch (error) {
18 console.error("Error fetching", error);
19 }
20};
21
22const GetPayment = async (id) => {
23 try {
24 const response = await axios.get(`${paymentRoute}/${id}`);
25 return response.data;
26 } catch (error) {
27 console.error("Error fetching", error);
28 }
29};
30
31const GetCustomerPayments = async (id) => {
32 try {
33 const response = await axios.get(`${paymentRoute}/customer/${id}`);
34 return response.data;
35 } catch (error) {
36 console.error("Error fetching", error);
37 }
38};
39
40const CreatePayment = async (formData) => {
41 try {
42 const response = await axios.post(`${paymentRoute}`, formData);
43 return response.data;
44 } catch (error) {
45 console.error("Error occured", error);
46 }
47};
48
49const UpdatePayment = async (id, formData) => {
50 try {
51 const response = await axios.post(`${paymentRoute}/${id}`, formData);
52 return response.data;
53 } catch (error) {
54 console.error("Error occured", error);
55 }
56};
57
58const DeletePayment = async (id) => {
59 try {
60 const response = await axios.delete(`${paymentRoute}/${id}`);
61 return response.data;
62 } catch (error) {
63 console.error("Error occured", error);
64 }
65};
66
67
68export {GetAllPayments, GetPayment, CreatePayment, UpdatePayment, DeletePayment, PaymentType, PublishableStripeKey, GetCustomerPayments}
Note: See TracBrowser for help on using the repository browser.