Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
silenaker committed Sep 2, 2024
1 parent 710ff38 commit 7e6e42d
Show file tree
Hide file tree
Showing 18 changed files with 1,125 additions and 955 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface StepInput {
currency_code: string
provider_token?: string
context?: PaymentProviderContext
data?: Record<string, unknown>
}

export const createPaymentSessionStepId = "create-payment-session"
Expand All @@ -31,7 +30,6 @@ export const createPaymentSessionStep = createStep(
provider_token: input.provider_token,
currency_code: input.currency_code,
amount: input.amount,
data: input.data ?? {},
context: input.context,
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export const deletePaymentSessionsStep = createStep(
provider_id: paymentSession.provider_id,
currency_code: paymentSession.currency_code,
amount: paymentSession.amount,
data: paymentSession.data ?? {},
context: paymentSession.context,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export const capturePaymentStep = createStep(
ModuleRegistrationName.PAYMENT
)

const payment = await paymentModule.capturePayment(input)
const payment = await paymentModule.capturePayment(input.payment_id, {
amount: input.amount,
captured_by: input.captured_by,
})

return new StepResponse(payment)
}
Expand Down
7 changes: 5 additions & 2 deletions packages/core/core-flows/src/payment/steps/refund-payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"

type StepInput = {
payment_id: string
created_by?: string
refunded_by?: string
amount?: BigNumberInput
}

Expand All @@ -16,7 +16,10 @@ export const refundPaymentStep = createStep(
ModuleRegistrationName.PAYMENT
)

const payment = await paymentModule.refundPayment(input)
const payment = await paymentModule.refundPayment(input.payment_id, {
amount: input.amount,
refunded_by: input.refunded_by,
})

return new StepResponse(payment)
}
Expand Down
13 changes: 9 additions & 4 deletions packages/core/types/src/payment/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ import { BigNumberValue } from "../totals"
/* ********** PAYMENT COLLECTION ********** */

export type PaymentCollectionStatus =
| "not_paid"
| "awaiting"
| "pending"
| "paid"
| "partially_paid"
| "authorized"
| "partially_authorized"
| "canceled"
| "refunded"
| "partially_refunded"

export type PaymentSessionStatus =
| "authorized"
| "captured"
| "partially_captured"
| "refunded"
| "partially_refunded"
| "pending"
| "requires_more"
| "error"
| "canceled"
| "processing"

/**
* The payment collection details.
Expand Down
38 changes: 14 additions & 24 deletions packages/core/types/src/payment/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ export interface CreateCaptureDTO {
*/
amount?: BigNumberInput

/**
* The associated payment's ID.
*/
payment_id: string

/**
* Who captured the payment. For example,
* a user's ID.
Expand All @@ -207,16 +202,11 @@ export interface CreateRefundDTO {
*/
amount?: BigNumberInput

/**
* The associated payment's ID.
*/
payment_id: string

/**
* Who refunded the payment. For example,
* a user's ID.
*/
created_by?: string
refunded_by?: string
}

/**
Expand All @@ -243,11 +233,6 @@ export interface CreatePaymentSessionDTO {
*/
amount: BigNumberInput

/**
* Necessary data for the associated payment provider to process the payment.
*/
data: Record<string, unknown>

/**
* Necessary context data for the associated payment provider.
*/
Expand All @@ -264,26 +249,31 @@ export interface UpdatePaymentSessionDTO {
id: string

/**
* Necessary data for the associated payment provider to process the payment.
*/
data: Record<string, unknown>

/**
* The ISO 3 character currency code.
* The provider's payment method token
*/
currency_code: string
provider_token?: string

/**
* The amount to be authorized.
*/
amount: BigNumberInput
amount?: BigNumberInput

/**
* Necessary context data for the associated payment provider.
*/
context?: PaymentProviderContext
}

/**
* The attributes to authorize in a payment session.
*/
export interface AuthorizePaymentSessionDTO {
/**
* The provider token to authorize payment session
*/
provider_token?: string
}

/**
* The payment provider to be created.
*/
Expand Down
Loading

0 comments on commit 7e6e42d

Please sign in to comment.