major claude changes

This commit is contained in:
2026-01-28 21:55:14 -05:00
parent f9d0e4c0fd
commit f9b5364c53
81 changed files with 11155 additions and 10086 deletions

View File

@@ -0,0 +1,111 @@
import api, { authorizeApi } from './api';
import {
PaymentTransaction,
CreditCard,
AuthorizeTransaction,
TransactionListResponse,
CardListResponse,
CreateCardRequest,
PaymentRequest,
ApiResponse,
TokenizeCardRequest,
UpdateTokenizedCardRequest,
ChargeSavedCardRequest,
ChargeDirectRequest,
CaptureRequest,
PreauthorizeSavedCardRequest,
AuthorizeNetTransactionResponse
} from '../types/models';
export const paymentService = {
// Card management (Main API)
getCard: (id: number): Promise<ApiResponse<CreditCard>> =>
api.get(`/payment/card/${id}`),
getCards: (customerId: number): Promise<ApiResponse<CreditCard[]>> =>
api.get(`/payment/cards/${customerId}`),
getCardsOnFile: (customerId: number): Promise<ApiResponse<CreditCard[]>> =>
api.get(`/payment/cards/onfile/${customerId}`),
getAllCards: (page: number = 1): Promise<CardListResponse> =>
api.get(`/payment/cards/all/${page}`),
createCard: (customerId: number, data: CreateCardRequest): Promise<ApiResponse<CreditCard>> =>
api.post(`/payment/card/create/${customerId}`, data),
updateCard: (id: number, data: Partial<CreditCard>): Promise<ApiResponse<CreditCard>> =>
api.put(`/payment/card/edit/${id}`, data),
removeCard: (id: number): Promise<ApiResponse<void>> =>
api.delete(`/payment/card/remove/${id}`),
removeCardAlt: (id: number): Promise<ApiResponse<void>> =>
api.delete(`/payment/cards/remove/${id}`),
updatePaymentProfile: (id: number, data: { profile_id: string }): Promise<ApiResponse<void>> =>
api.put(`/payment/card/update_payment_profile/${id}`, data),
// Authorization & capture (Main API)
authorizeDelivery: (id: number, data: PaymentRequest): Promise<ApiResponse<PaymentTransaction>> =>
api.put(`/payment/authorize/${id}`, data),
authorizeService: (id: number, data: PaymentRequest): Promise<ApiResponse<PaymentTransaction>> =>
api.put(`/payment/authorize/service/${id}`, data),
cleanupAuthorization: (id: number): Promise<ApiResponse<void>> =>
api.put(`/payment/authorize/cleanup/${id}`),
captureServicePayment: (id: number, data: { amount: number }): Promise<ApiResponse<PaymentTransaction>> =>
api.put(`/payment/capture/service/${id}`, data),
// Service payment
getServicePayment: (id: number, type: string): Promise<ApiResponse<{ amount: number }>> =>
api.get(`/payment/service/payment/${id}/${type}`),
// Transactions
getDeliveryTransaction: (id: number): Promise<ApiResponse<PaymentTransaction>> =>
api.get(`/payment/transaction/delivery/${id}`),
getAuthorizeTransactions: (): Promise<ApiResponse<AuthorizeTransaction[]>> =>
api.get('/payment/transactions/authorize/1'),
getCustomerTransactions: (customerId: number, page: number = 1): Promise<TransactionListResponse> =>
api.get(`/payment/transactions/customer/${customerId}/${page}`),
getServiceTransactions: (serviceId: number): Promise<ApiResponse<PaymentTransaction[]>> =>
api.get(`/payment/transactions/service/${serviceId}`),
// Authorize.net endpoints
authorize: {
tokenizeCard: (customerId: number, data: TokenizeCardRequest): Promise<ApiResponse<CreditCard>> =>
authorizeApi.post(`/api/payments/customers/${customerId}/cards`, data),
updateTokenizedCard: (customerId: number, cardId: number, data: UpdateTokenizedCardRequest): Promise<ApiResponse<CreditCard>> =>
authorizeApi.put(`/api/payments/customers/${customerId}/cards/${cardId}`, data),
authorizeSavedCard: (customerId: number, data: PreauthorizeSavedCardRequest): Promise<ApiResponse<AuthorizeNetTransactionResponse>> =>
authorizeApi.post(`/api/payments/authorize/saved-card/${customerId}`, data),
chargeSavedCard: (customerId: number, data: ChargeSavedCardRequest): Promise<ApiResponse<AuthorizeNetTransactionResponse>> =>
authorizeApi.post(`/api/payments/charge/saved-card/${customerId}`, data),
charge: (customerId: number, data: ChargeDirectRequest): Promise<ApiResponse<AuthorizeNetTransactionResponse>> =>
authorizeApi.post(`/api/charge/${customerId}`, data),
capture: (data: CaptureRequest): Promise<ApiResponse<AuthorizeNetTransactionResponse>> =>
authorizeApi.post('/api/capture/', data),
// Auto transaction endpoints
getAutoTransaction: (deliveryId: number): Promise<ApiResponse<AuthorizeNetTransactionResponse>> =>
authorizeApi.get(`/api/auto/transaction/delivery/${deliveryId}`),
updateAutoTransactionId: (deliveryId: number, newId: number, data?: Record<string, unknown>): Promise<ApiResponse<void>> =>
authorizeApi.put(`/api/auto/transaction/delivery/${deliveryId}/update/${newId}`, data ?? {}),
linkTransactionToAuto: (transactionId: number, autoId: number, data?: Record<string, unknown>): Promise<ApiResponse<void>> =>
authorizeApi.put(`/api/transaction/${transactionId}/update_auto_id/${autoId}`, data ?? {}),
},
};
export default paymentService;