| 1 | import axios from "axios";
|
|---|
| 2 |
|
|---|
| 3 | const paymentRoute = "/payments";
|
|---|
| 4 |
|
|---|
| 5 | const PaymentType = {
|
|---|
| 6 | Cash: 'Cash',
|
|---|
| 7 | DebitCard: 'DebitCard',
|
|---|
| 8 | CreditCard: 'CreditCard',
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | const PublishableStripeKey = 'pk_test_51HCrb4D91Y2Imm1bXKM17hthwdzbY5W8r3e2bCXFQY0ifZHPnbptfL2hEHL1g4EoxBu3SRU2E5W0yVg8sewXHBsQ00fRpqLFzM';
|
|---|
| 12 |
|
|---|
| 13 | const 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 |
|
|---|
| 22 | const 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 |
|
|---|
| 31 | const 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 |
|
|---|
| 40 | const 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 |
|
|---|
| 49 | const 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 |
|
|---|
| 58 | const 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 |
|
|---|
| 68 | export {GetAllPayments, GetPayment, CreatePayment, UpdatePayment, DeletePayment, PaymentType, PublishableStripeKey, GetCustomerPayments} |
|---|