feat(medusa,medusa-react): PaymentCollection support (#2659)

* chore: medusa react, order edit complete fix and single payment session
This commit is contained in:
Carlos R. L. Rodrigues authored and GitHub committed 2022-12-07 12:39:35 -03:00
1 parent 42d9c7222b
commit 15c667fbd3
54 files changed
+2001 -261

No files matched your search

@@ -2104,4 +2104,103 @@ export const adminHandlers = [
})
)
}),
rest.get("/admin/payment-collections/:id", (req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(200),
ctx.json({
payment_collection: {
...fixtures.get("payment_collection"),
id,
},
})
)
}),
rest.delete("/admin/payment-collections/:id", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
id: req.params.id,
object: "payment_collection",
deleted: true,
})
)
}),
rest.post("/admin/payment-collections/:id", (req, res, ctx) => {
const { id } = req.params
const { description, metadata } = req.body as any
return res(
ctx.status(200),
ctx.json({
payment_collection: {
...fixtures.get("payment_collection"),
description,
metadata,
id,
},
})
)
}),
rest.post("/admin/payment-collections/:id/authorize", (req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(200),
ctx.json({
payment_collection: {
...fixtures.get("payment_collection"),
id,
},
})
)
}),
rest.get("/admin/payments/:id", (req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(200),
ctx.json({
payment: {
...fixtures.get("payment"),
id,
},
})
)
}),
rest.post("/admin/payments/:id/capture", (req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(200),
ctx.json({
payment: {
...fixtures.get("payment"),
id,
},
})
)
}),
rest.post("/admin/payments/:id/refund", (req, res, ctx) => {
const { id } = req.params
const { amount, reason, note } = req.body as any
return res(
ctx.status(200),
ctx.json({
refund: {
...fixtures.get("refund"),
payment_id: id,
amount,
reason,
note,
},
})
)
}),
]
@@ -446,4 +446,100 @@ export const storeHandlers = [
})
)
}),
rest.get("/store/payment-collections/:id", (req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(200),
ctx.json({
payment_collection: {
...fixtures.get("payment_collection"),
id,
},
})
)
}),
rest.post(
"/store/payment-collections/:id/sessions/batch",
(req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(200),
ctx.json({
payment_collection: {
...fixtures.get("payment_collection"),
id,
},
})
)
}
),
rest.post(
"/store/payment-collections/:id/sessions/batch/authorize",
(req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(207),
ctx.json({
payment_collection: {
...fixtures.get("payment_collection"),
id,
},
})
)
}
),
rest.post("/store/payment-collections/:id/sessions", (req, res, ctx) => {
const { id } = req.params
return res(
ctx.status(200),
ctx.json({
payment_collection: {
...fixtures.get("payment_collection"),
id,
},
})
)
}),
rest.post(
"/store/payment-collections/:id/sessions/:session_id",
(req, res, ctx) => {
const { id, session_id } = req.params
const payCol: any = { ...fixtures.get("payment_collection") }
payCol.payment_sessions[0].id = `new_${session_id}`
const session = {
payment_session: payCol.payment_sessions[0],
}
return res(
ctx.status(200),
ctx.json({
...session,
})
)
}
),
rest.post(
"/store/payment-collections/:id/sessions/:session_id/authorize",
(req, res, ctx) => {
const { session_id } = req.params
const session = fixtures.get("payment_collection").payment_sessions[0]
return res(
ctx.status(200),
ctx.json({
payment_session: {
...session,
id: session_id,
},
})
)
}
),
]