-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6092 from medusajs/feat/payment-module-interfaces
feat: Payment module interface
- Loading branch information
Showing
5 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@medusajs/types": patch | ||
--- | ||
|
||
feat: Payment Module service interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
export * from "./common" | ||
export * from "./mutations" | ||
export * from "./service" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
} |