feat(payment): payment and session methods (#6138)

This commit is contained in:
Frane Polić
2024-02-06 13:40:22 +01:00
committed by GitHub
parent 5cabe9585f
commit 2104843826
13 changed files with 1239 additions and 319 deletions
+206 -1
View File
@@ -36,6 +36,76 @@ export interface PaymentCollectionDTO {
* The ID of the Payment Collection
*/
id: string
/**
* The currency of the payments/sessions associated with payment collection
*/
currency_code: string
/**
* The id of the region
*/
region_id: string
/**
* The amount
*/
amount: number
/**
* The amount authorized within associated payment sessions
*/
authorized_amount?: number
/**
* The amount refunded from associated payments
*/
refunded_amount?: number
/**
* When the payment collection was completed
*/
completed_at?: string | Date
/**
* When the payment collection was created
*/
created_at?: string | Date
/**
* When the payment collection was updated
*/
updated_at?: string | Date
/**
* Holds custom data in key-value pairs
*/
metadata?: Record<string, unknown> | null
/**
* The status of the payment collection
*/
status: PaymentCollectionStatus
/**
* The payment provider for the payments
*
* @expandable
*/
payment_providers: PaymentProviderDTO[]
/**
* The associated payment sessions
*
* @expandable
*/
payment_sessions?: PaymentSessionDTO[]
/**
* The associated payments
*
* @expandable
*/
payments?: PaymentDTO[]
}
export interface FilterablePaymentCollectionProps
@@ -52,7 +122,142 @@ export interface FilterablePaymentCollectionProps
export interface PaymentDTO {
/**
* The ID of the Payment Collection
* The ID of the Payment
*/
id: string
/**
* The payment amount
*/
amount: number
authorized_amount?: number
/**
* Payment currency
*/
currency_code: string
/**
* The ID of payment provider
*/
provider_id: string
cart_id?: string
order_id?: string
order_edit_id?: string
customer_id?: string
/**
* Payment provider data
*/
data?: Record<string, unknown>
/**
* When the payment collection was created
*/
created_at?: string | Date
/**
* When the payment collection was updated
*/
updated_at?: string | Date
/**
* When the payment was captured
*/
captured_at?: string | Date
/**
* When the payment was canceled
*/
canceled_at?: string | Date
/**
* The sum of the associated captures
*/
captured_amount?: number
/**
* The sum of the associated refunds
*/
refunded_amount?: number
/**
* The associated payment captures
*
* @expandable
*/
captures?: CaptureDTO[]
/**
* The associated refunds of the payment
*
* @expandable
*/
refunds?: RefundDTO[]
/**
* The payment collection the payment is associated with
*
* @expandable
*/
payment_collection?: PaymentCollectionDTO
/**
* The payment session from which the payment is created
*
* @expandable
*/
payment_session?: PaymentSessionDTO
}
export interface CaptureDTO {
/**
* The ID of the Capture
*/
id: string
/**
* Captured amount
*/
amount: number
created_at: Date
created_by?: string
payment: PaymentDTO
}
export interface RefundDTO {
/**
* The ID of the Refund
*/
id: string
/**
* Refunded amount
*/
amount: number
created_at: Date
created_by?: string
payment: PaymentDTO
}
/* ********** PAYMENT ********** */
export interface PaymentSessionDTO {
/**
* The ID of the Payment Session
*/
id: string
}
export interface PaymentProviderDTO {
id: string
is_enabled: string
}
+21 -1
View File
@@ -17,7 +17,6 @@ export interface UpdatePaymentCollectionDTO
authorized_amount?: number
refunded_amount?: number
completed_at?: number
status?: PaymentCollectionStatus
}
@@ -31,6 +30,9 @@ export interface CreatePaymentDTO {
provider_id: string
data: Record<string, unknown>
payment_session_id: string
payment_collection_id: string
cart_id?: string
order_id?: string
order_edit_id?: string
@@ -38,10 +40,28 @@ export interface CreatePaymentDTO {
}
export interface UpdatePaymentDTO {
id: string
cart_id?: string
order_id?: string
order_edit_id?: string
customer_id?: string
data?: Record<string, unknown>
}
export interface CreateCaptureDTO {
amount: number
payment_id: string
captured_by?: string
}
export interface CreateRefundDTO {
amount: number
payment_id: string
created_by?: string
}
/**
+28 -7
View File
@@ -1,9 +1,11 @@
import { IModuleService } from "../modules-sdk"
import { Context } from "../shared-context"
import {
CreateCaptureDTO,
CreatePaymentCollectionDTO,
CreatePaymentDTO,
CreatePaymentSessionDTO,
CreateRefundDTO,
SetPaymentSessionsDTO,
UpdatePaymentCollectionDTO,
UpdatePaymentDTO,
@@ -75,19 +77,38 @@ export interface IPaymentModuleService extends IModuleService {
/* ********** PAYMENT ********** */
createPayment(data: CreatePaymentDTO): Promise<PaymentDTO>
createPayment(data: CreatePaymentDTO[]): Promise<PaymentDTO[]>
createPayment(
data: CreatePaymentDTO,
sharedContext?: Context
): Promise<PaymentDTO>
createPayment(
data: CreatePaymentDTO[],
sharedContext?: Context
): Promise<PaymentDTO[]>
capturePayment(
paymentId: string,
amount: number,
data: CreateCaptureDTO,
sharedContext?: Context
): Promise<PaymentDTO>
capturePayment(
data: CreateCaptureDTO[],
sharedContext?: Context
): Promise<PaymentDTO[]>
refundPayment(
data: CreateRefundDTO,
sharedContext?: Context
): Promise<PaymentDTO>
refundPayment(
paymentId: string,
amount: number,
data: CreateRefundDTO[],
sharedContext?: Context
): Promise<PaymentDTO>
): Promise<PaymentDTO[]>
cancelPayment(paymentId: string, sharedContext?: Context): Promise<PaymentDTO>
cancelPayment(
paymentId: string[],
sharedContext?: Context
): Promise<PaymentDTO[]>
updatePayment(
data: UpdatePaymentDTO,