1 import { model, PaymentSessionStatus } from "@medusajs/framework/utils"
2 import Payment from "./payment"
3 import PaymentCollection from "./payment-collection"
4
5 const PaymentSession = model
6 .define("PaymentSession", {
7 id: model.id({ prefix: "payses" }).primaryKey(),
8 currency_code: model.text(),
9 amount: model.bigNumber(),
10 provider_id: model.text(),
11 data: model.json().default({}),
12 context: model.json().nullable(),
13 status: model
14 .enum(PaymentSessionStatus)
15 .default(PaymentSessionStatus.PENDING),
16 authorized_at: model.dateTime().nullable(),
17 payment_collection: model.belongsTo<() => typeof PaymentCollection>(
18 () => PaymentCollection,
19 {
20 mappedBy: "payment_sessions",
21 }
22 ),
23 payment: model
24 .hasOne(() => Payment, {
25 mappedBy: "payment_session",
26 })
27 .nullable(),
28 metadata: model.json().nullable(),
29 })
30 .indexes([
31 {
32 name: "IDX_payment_session_payment_collection_id",
33 on: ["payment_collection_id"],
34 },
35 ])
36
37 export default PaymentSession