Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Payment module interface #6092

Merged
merged 41 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
824bcce
feat: Payment module package setup
fPolic Jan 11, 2024
c9f1858
fix: missing files
fPolic Jan 11, 2024
85e4e6c
fix: changesets
fPolic Jan 11, 2024
8a5888a
feat: Payment models
fPolic Jan 11, 2024
9e72d25
feat: migration
fPolic Jan 11, 2024
b601212
Merge branch 'develop' into feat/payment-module-models
fPolic Jan 11, 2024
1b882a9
feat: optional props, update fields
fPolic Jan 12, 2024
f2a4f45
fix: Refund/Capture delete, add indexes
fPolic Jan 12, 2024
00ee67c
chore: refactor
fPolic Jan 12, 2024
a7f74bd
fix: add missing indexes
fPolic Jan 12, 2024
aabe164
fix: partial feedback address
fPolic Jan 15, 2024
1d82294
fix: currency code
fPolic Jan 15, 2024
efdc59f
Merge branch 'develop' into feat/payment-module-models
fPolic Jan 15, 2024
5675203
wip: interface and types
fPolic Jan 15, 2024
fbd3fed
wip: service
fPolic Jan 15, 2024
89d6d7e
fix: add order_edit_id to Payment
fPolic Jan 15, 2024
66ec3d0
wip: session methods
fPolic Jan 15, 2024
1cc888d
feat: Sessions API update
fPolic Jan 16, 2024
fc6b177
chore: changeset
fPolic Jan 16, 2024
22254a2
fix: address feedback partial
fPolic Jan 16, 2024
bc7829d
fix: update models
fPolic Jan 16, 2024
eab0ca4
fix: serializer
fPolic Jan 16, 2024
67acdcd
Merge branch 'feat/payment-module-models' into feat/payment-module-in…
fPolic Jan 16, 2024
33e5b7f
fix: Payment merge
fPolic Jan 16, 2024
dcdb6df
fix: `listPaymentCollections` shape
fPolic Jan 16, 2024
ca0d6f5
fix: method overloads
fPolic Jan 16, 2024
ef7f51a
fix: remove is selected
fPolic Jan 17, 2024
e4438ae
Merge branch 'feat/payment-module-models' into feat/payment-module-in…
fPolic Jan 17, 2024
6341533
fix: region id
fPolic Jan 17, 2024
dfcb5e7
Merge branch 'feat/payment-module-models' into feat/payment-module-in…
fPolic Jan 17, 2024
57b8896
fix: update DTO
fPolic Jan 17, 2024
aa1585b
feat: add region index
fPolic Jan 17, 2024
e7d8c53
Merge branch 'feat/payment-module-models' into feat/payment-module-in…
fPolic Jan 17, 2024
d5af7cc
fix: add column type
fPolic Jan 18, 2024
a6aa09a
Merge branch 'feat/payment-module-models' into feat/payment-module-in…
fPolic Jan 18, 2024
8154408
fix: change type
fPolic Jan 18, 2024
c332375
chore: update fields to new convention
fPolic Jan 18, 2024
af61195
Merge branch 'develop' into feat/payment-module-models
fPolic Jan 18, 2024
491848b
Merge branch 'develop' into feat/payment-module-models
fPolic Jan 18, 2024
8e4e6b0
Merge branch 'feat/payment-module-models' into feat/payment-module-in…
fPolic Jan 18, 2024
16945f4
Merge branch 'develop' into feat/payment-module-interfaces
fPolic Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/forty-moons-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/types": patch
---

feat: Payment Module service interface
30 changes: 30 additions & 0 deletions packages/types/src/payment/common.ts
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
}
3 changes: 3 additions & 0 deletions packages/types/src/payment/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export * from "./common"
export * from "./mutations"
export * from "./service"

47 changes: 47 additions & 0 deletions packages/types/src/payment/mutations.ts
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
fPolic marked this conversation as resolved.
Show resolved Hide resolved
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
fPolic marked this conversation as resolved.
Show resolved Hide resolved
amount: number
session_id?: string
}
130 changes: 129 additions & 1 deletion packages/types/src/payment/service.ts
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>
fPolic marked this conversation as resolved.
Show resolved Hide resolved
createPayment(data: CreatePaymentDTO[]): Promise<PaymentDTO[]>

capturePayment(
paymentId: string,
amount: number,
sharedContext?: Context
): Promise<PaymentDTO>
refundPayment(
paymentId: string,
amount: number,
sharedContext?: Context
): Promise<PaymentDTO>

updatePayment(
fPolic marked this conversation as resolved.
Show resolved Hide resolved
data: UpdatePaymentDTO,
sharedContext?: Context
): Promise<PaymentDTO>
updatePayment(
data: UpdatePaymentDTO[],
sharedContext?: Context
): Promise<PaymentDTO[]>

/* ********** PAYMENT SESSION ********** */

createPaymentSession(
paymentCollectionId: string,
data: CreatePaymentSessionDTO,
sharedContext?: Context
): Promise<PaymentCollectionDTO>
fPolic marked this conversation as resolved.
Show resolved Hide resolved
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>
fPolic marked this conversation as resolved.
Show resolved Hide resolved
}