Files
medusa-store/packages/modules/payment/src/models/payment-session.ts
Carlos R. L. Rodrigues 0264294ab5 chore(payment): Payment module DML (#10553)
* chore(payment): Payment module DML

* rm log

* migration
2024-12-11 13:09:10 -03:00

38 lines
1.0 KiB
TypeScript

import { model, PaymentSessionStatus } from "@medusajs/framework/utils"
import Payment from "./payment"
import PaymentCollection from "./payment-collection"
const PaymentSession = model
.define("PaymentSession", {
id: model.id({ prefix: "payses" }).primaryKey(),
currency_code: model.text(),
amount: model.bigNumber(),
provider_id: model.text(),
data: model.json().default({}),
context: model.json().nullable(),
status: model
.enum(PaymentSessionStatus)
.default(PaymentSessionStatus.PENDING),
authorized_at: model.dateTime().nullable(),
payment_collection: model.belongsTo<() => typeof PaymentCollection>(
() => PaymentCollection,
{
mappedBy: "payment_sessions",
}
),
payment: model
.hasOne(() => Payment, {
mappedBy: "payment_session",
})
.nullable(),
metadata: model.json().nullable(),
})
.indexes([
{
name: "IDX_payment_session_payment_collection_id",
on: ["payment_collection_id"],
},
])
export default PaymentSession