Merge pull request #6092 from medusajs/feat/payment-module-interfaces
feat: Payment module interface
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/types": patch
|
||||
---
|
||||
|
||||
feat: Payment Module service interface
|
||||
@@ -0,0 +1,30 @@
|
||||
import { BaseFilterable } from "../dal"
|
||||
import { OperatorMap } from "../dal/utils"
|
||||
|
||||
/* ********** PAYMENT COLLECTION ********** */
|
||||
|
||||
export interface PaymentCollectionDTO {
|
||||
/**
|
||||
* The ID of the Payment Collection
|
||||
*/
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface FilterablePaymentCollectionProps
|
||||
extends BaseFilterable<PaymentCollectionDTO> {
|
||||
id?: string | string[]
|
||||
|
||||
region_id?: string | string[] | OperatorMap<string>
|
||||
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
/* ********** PAYMENT ********** */
|
||||
|
||||
export interface PaymentDTO {
|
||||
/**
|
||||
* The ID of the Payment Collection
|
||||
*/
|
||||
id: string
|
||||
}
|
||||
@@ -1 +1,4 @@
|
||||
export * from "./common"
|
||||
export * from "./mutations"
|
||||
export * from "./service"
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
|
||||
export interface CreatePaymentCollectionDTO {
|
||||
region_id: string
|
||||
currency_code: string
|
||||
amount: number
|
||||
}
|
||||
|
||||
export interface UpdatePaymentCollectionDTO
|
||||
extends Partial<CreatePaymentCollectionDTO> {}
|
||||
|
||||
export interface CreatePaymentDTO {
|
||||
amount: number
|
||||
currency_code: string
|
||||
provider_id: string
|
||||
data: Record<string, unknown>
|
||||
|
||||
cart_id?: string
|
||||
order_id?: string
|
||||
order_edit_id?: string
|
||||
customer_id?: string
|
||||
}
|
||||
|
||||
export interface UpdatePaymentDTO {
|
||||
cart_id?: string
|
||||
order_id?: string
|
||||
order_edit_id?: string
|
||||
customer_id?: string
|
||||
}
|
||||
|
||||
export interface CreatePaymentSessionDTO {
|
||||
amount: number
|
||||
currency_code: string
|
||||
provider_id: string
|
||||
|
||||
cart_id?: string
|
||||
resource_id?: string
|
||||
customer_id?: string
|
||||
}
|
||||
|
||||
export interface SetPaymentSessionsDTO {
|
||||
provider_id: string
|
||||
amount: number
|
||||
session_id?: string
|
||||
}
|
||||
@@ -1,3 +1,131 @@
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import {
|
||||
CreatePaymentCollectionDTO,
|
||||
CreatePaymentDTO,
|
||||
CreatePaymentSessionDTO,
|
||||
SetPaymentSessionsDTO,
|
||||
UpdatePaymentCollectionDTO,
|
||||
UpdatePaymentDTO,
|
||||
} from "./mutations"
|
||||
import {
|
||||
FilterablePaymentCollectionProps,
|
||||
PaymentCollectionDTO,
|
||||
PaymentDTO,
|
||||
} from "./common"
|
||||
import { FindConfig } from "../common"
|
||||
|
||||
export interface IPaymentModuleService extends IModuleService {}
|
||||
export interface IPaymentModuleService extends IModuleService {
|
||||
/* ********** PAYMENT COLLECTION ********** */
|
||||
|
||||
createPaymentCollection(
|
||||
data: CreatePaymentCollectionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO[]>
|
||||
createPaymentCollection(
|
||||
data: CreatePaymentCollectionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
retrievePaymentCollection(
|
||||
paymentCollectionId: string,
|
||||
config?: FindConfig<PaymentCollectionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
listPaymentCollections(
|
||||
filters?: FilterablePaymentCollectionProps,
|
||||
config?: FindConfig<PaymentCollectionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO[]>
|
||||
|
||||
listAndCountPaymentCollections(
|
||||
filters?: FilterablePaymentCollectionProps,
|
||||
config?: FindConfig<PaymentCollectionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[PaymentCollectionDTO[], number]>
|
||||
|
||||
updatePaymentCollection(
|
||||
data: UpdatePaymentCollectionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO[]>
|
||||
updatePaymentCollection(
|
||||
data: UpdatePaymentCollectionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
deletePaymentCollection(
|
||||
paymentCollectionId: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
deletePaymentCollection(
|
||||
paymentCollectionId: string,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
authorizePaymentCollection(
|
||||
paymentCollectionId: string,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
completePaymentCollection(
|
||||
paymentCollectionId: string,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
/* ********** PAYMENT ********** */
|
||||
|
||||
createPayment(data: CreatePaymentDTO): Promise<PaymentDTO>
|
||||
createPayment(data: CreatePaymentDTO[]): Promise<PaymentDTO[]>
|
||||
|
||||
capturePayment(
|
||||
paymentId: string,
|
||||
amount: number,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentDTO>
|
||||
refundPayment(
|
||||
paymentId: string,
|
||||
amount: number,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentDTO>
|
||||
|
||||
updatePayment(
|
||||
data: UpdatePaymentDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentDTO>
|
||||
updatePayment(
|
||||
data: UpdatePaymentDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentDTO[]>
|
||||
|
||||
/* ********** PAYMENT SESSION ********** */
|
||||
|
||||
createPaymentSession(
|
||||
paymentCollectionId: string,
|
||||
data: CreatePaymentSessionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
createPaymentSession(
|
||||
paymentCollectionId: string,
|
||||
data: CreatePaymentSessionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
authorizePaymentSessions(
|
||||
paymentCollectionId: string,
|
||||
sessionIds: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
completePaymentSessions(
|
||||
paymentCollectionId: string,
|
||||
sessionIds: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
|
||||
setPaymentSessions(
|
||||
paymentCollectionId: string,
|
||||
data: SetPaymentSessionsDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<PaymentCollectionDTO>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user