feat(medusa): manage payment sessions from payment collection (#2402)
* feat: manage payment sessions from payment collection
This commit is contained in:
@@ -50,6 +50,9 @@ export class PaymentCollection extends SoftDeletableEntity {
|
||||
@Column({ type: "int", nullable: true })
|
||||
authorized_amount: number
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
captured_amount: number
|
||||
|
||||
@Column({ type: "int", nullable: true })
|
||||
refunded_amount: number
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export enum PaymentSessionStatus {
|
||||
@Entity()
|
||||
export class PaymentSession extends BaseEntity {
|
||||
@Index()
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
cart_id: string
|
||||
|
||||
@ManyToOne(() => Cart, (cart) => cart.payment_sessions)
|
||||
@@ -51,6 +51,11 @@ export class PaymentSession extends BaseEntity {
|
||||
@Column({ nullable: true })
|
||||
idempotency_key: string
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
Column({ type: "integer", nullable: true }),
|
||||
])
|
||||
amount: number
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
Column({ type: resolveDbType("timestamptz"), nullable: true }),
|
||||
])
|
||||
|
||||
@@ -5,12 +5,16 @@ import {
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToOne,
|
||||
} from "typeorm"
|
||||
|
||||
import { BaseEntity } from "../interfaces/models/base-entity"
|
||||
import { DbAwareColumn } from "../utils/db-aware-column"
|
||||
import { Order } from "./order"
|
||||
import { generateEntityId } from "../utils/generate-entity-id"
|
||||
import { Payment } from "./payment"
|
||||
import { FeatureFlagDecorators } from "../utils/feature-flag-decorators"
|
||||
import OrderEditingFeatureFlag from "../loaders/feature-flags/order-editing"
|
||||
|
||||
export enum RefundReason {
|
||||
DISCOUNT = "discount",
|
||||
@@ -23,13 +27,25 @@ export enum RefundReason {
|
||||
@Entity()
|
||||
export class Refund extends BaseEntity {
|
||||
@Index()
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
order_id: string
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
Index(),
|
||||
Column({ nullable: true }),
|
||||
])
|
||||
payment_id: string
|
||||
|
||||
@ManyToOne(() => Order, (order) => order.payments)
|
||||
@JoinColumn({ name: "order_id" })
|
||||
order: Order
|
||||
|
||||
@FeatureFlagDecorators(OrderEditingFeatureFlag.key, [
|
||||
OneToOne(() => Payment, { nullable: true }),
|
||||
JoinColumn({ name: "payment_id" }),
|
||||
])
|
||||
payment: Payment
|
||||
|
||||
@Column({ type: "int" })
|
||||
amount: number
|
||||
|
||||
|
||||
Reference in New Issue
Block a user