fa44e3f5a8
what: - enables a button to create a payment link when a payment delta is present - api to delete order payment collection - adds a pending amount to payment collections Note: Not the happiest with the decision on when to create a payment collection and when not to. The code should programatically create or delete payment collections currently to generate the right collection for the payment delta. Adding a more specific flow to create and manage a payment collection will help reduce this burden from the code path and onto CX/merchant. Another issue I found is that the payment collection status doesn't get updated when payment is complete as it still gets stuck to "authorized" state https://github.com/user-attachments/assets/037a10f9-3621-43c2-94ba-1ada4b0a041b
71 lines
1.7 KiB
TypeScript
71 lines
1.7 KiB
TypeScript
import { ModuleJoinerConfig } from "@medusajs/types"
|
|
import { LINKS, Modules } from "@medusajs/utils"
|
|
|
|
export const OrderPaymentCollection: ModuleJoinerConfig = {
|
|
serviceName: LINKS.OrderPaymentCollection,
|
|
isLink: true,
|
|
databaseConfig: {
|
|
tableName: "order_payment_collection",
|
|
idPrefix: "ordpay",
|
|
},
|
|
alias: [
|
|
{
|
|
name: ["order_payment_collection", "order_payment_collections"],
|
|
args: {
|
|
entity: "LinkOrderPaymentCollection",
|
|
},
|
|
},
|
|
],
|
|
primaryKeys: ["id", "order_id", "payment_collection_id"],
|
|
relationships: [
|
|
{
|
|
serviceName: Modules.ORDER,
|
|
primaryKey: "id",
|
|
foreignKey: "order_id",
|
|
alias: "order",
|
|
args: {
|
|
methodSuffix: "Orders",
|
|
},
|
|
},
|
|
{
|
|
serviceName: Modules.PAYMENT,
|
|
primaryKey: "id",
|
|
foreignKey: "payment_collection_id",
|
|
alias: "payment_collection",
|
|
args: {
|
|
methodSuffix: "PaymentCollections",
|
|
},
|
|
deleteCascade: true,
|
|
},
|
|
],
|
|
extends: [
|
|
{
|
|
serviceName: Modules.ORDER,
|
|
fieldAlias: {
|
|
payment_collections: {
|
|
path: "payment_collections_link.payment_collection",
|
|
isList: true,
|
|
},
|
|
},
|
|
relationship: {
|
|
serviceName: LINKS.OrderPaymentCollection,
|
|
primaryKey: "order_id",
|
|
foreignKey: "id",
|
|
alias: "payment_collections_link",
|
|
},
|
|
},
|
|
{
|
|
serviceName: Modules.PAYMENT,
|
|
fieldAlias: {
|
|
order: "order_link.order",
|
|
},
|
|
relationship: {
|
|
serviceName: LINKS.OrderPaymentCollection,
|
|
primaryKey: "payment_collection_id",
|
|
foreignKey: "id",
|
|
alias: "order_link",
|
|
},
|
|
},
|
|
],
|
|
}
|