fix: address feedback partial

This commit is contained in:
fPolic
2024-01-16 10:30:52 +01:00
parent 89d6d7e846
commit 22254a22c0
8 changed files with 67 additions and 61 deletions

View File

@@ -11,7 +11,7 @@ import {
import { generateEntityId } from "@medusajs/utils"
import Payment from "./payment"
type OptionalCaptureProps = "created_by" | "created_at" | "completed_at"
type OptionalCaptureProps = "created_by" | "created_at"
@Entity({ tableName: "capture" })
export default class Capture {

View File

@@ -14,44 +14,21 @@ import {
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import { DALUtils, generateEntityId } from "@medusajs/utils"
import {
DALUtils,
generateEntityId,
PaymentCollectionStatus,
} from "@medusajs/utils"
import PaymentProvider from "./payment-provider"
import PaymentSession from "./payment-session"
import Payment from "./payment"
/**
* @enum
*
* The payment collection's status.
*/
export enum PaymentCollectionStatus {
/**
* The payment collection isn't paid.
*/
NOT_PAID = "not_paid",
/**
* The payment collection is awaiting payment.
*/
AWAITING = "awaiting",
/**
* The payment collection is authorized.
*/
AUTHORIZED = "authorized",
/**
* Some of the payments in the payment collection are authorized.
*/
PARTIALLY_AUTHORIZED = "partially_authorized",
/**
* The payment collection is canceled.
*/
CANCELED = "canceled",
}
type OptionalPaymentCollectionProps =
| "authorized_amount"
| "refunded_amount"
| "region_id"
| "completed_at"
| "status"
| DAL.SoftDeletableEntityDateColumns
@Entity({ tableName: "payment_collection" })
@@ -120,7 +97,7 @@ export default class PaymentCollection {
items: () => PaymentCollectionStatus,
default: PaymentCollectionStatus.NOT_PAID,
})
status: PaymentCollectionStatus = PaymentCollectionStatus.NOT_PAID
status?: PaymentCollectionStatus = PaymentCollectionStatus.NOT_PAID
@ManyToMany(() => PaymentProvider)
payment_providers = new Collection<PaymentProvider>(this)

View File

@@ -10,39 +10,11 @@ import {
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import { generateEntityId } from "@medusajs/utils"
import { generateEntityId, PaymentSessionStatus } from "@medusajs/utils"
import PaymentCollection from "./payment-collection"
import Payment from "./payment"
/**
* @enum
*
* The status of a payment session.
*/
export enum PaymentSessionStatus {
/**
* The payment is authorized.
*/
AUTHORIZED = "authorized",
/**
* The payment is pending.
*/
PENDING = "pending",
/**
* The payment requires an action.
*/
REQUIRES_MORE = "requires_more",
/**
* An error occurred while processing the payment.
*/
ERROR = "error",
/**
* The payment is canceled.
*/
CANCELED = "canceled",
}
type OptionalPaymentSessionProps =
| "data"
| "is_selected"

View File

@@ -11,7 +11,7 @@ import {
import { generateEntityId } from "@medusajs/utils"
import Payment from "./payment"
type OptionalRefundProps = "created_by" | "completed_at"
type OptionalRefundProps = "created_by"
@Entity({ tableName: "refund" })
export default class Refund {

View File

@@ -5,6 +5,7 @@ export * from "./decorators"
export * from "./event-bus"
export * from "./feature-flags"
export * from "./modules-sdk"
export * from "./payment"
export * from "./pricing"
export * from "./product"
export * from "./promotion"

View File

@@ -0,0 +1,2 @@
export * from "./payment-collection"
export * from "./payment-session"

View File

@@ -0,0 +1,27 @@
/**
* @enum
*
* The payment collection's status.
*/
export enum PaymentCollectionStatus {
/**
* The payment collection isn't paid.
*/
NOT_PAID = "not_paid",
/**
* The payment collection is awaiting payment.
*/
AWAITING = "awaiting",
/**
* The payment collection is authorized.
*/
AUTHORIZED = "authorized",
/**
* Some of the payments in the payment collection are authorized.
*/
PARTIALLY_AUTHORIZED = "partially_authorized",
/**
* The payment collection is canceled.
*/
CANCELED = "canceled",
}

View File

@@ -0,0 +1,27 @@
/**
* @enum
*
* The status of a payment session.
*/
export enum PaymentSessionStatus {
/**
* The payment is authorized.
*/
AUTHORIZED = "authorized",
/**
* The payment is pending.
*/
PENDING = "pending",
/**
* The payment requires an action.
*/
REQUIRES_MORE = "requires_more",
/**
* An error occurred while processing the payment.
*/
ERROR = "error",
/**
* The payment is canceled.
*/
CANCELED = "canceled",
}