fix: mobile pay support

This commit is contained in:
Sebastian Rindom committed 2021-06-08 10:56:35 +02:00
1 parent 024251b5d2
commit 91511cbdf8
15 files changed
+75 -499

No files matched your search

@@ -1,7 +1,7 @@
import { MedusaError } from "medusa-core-utils"
/**
* @oas [post] /carts/{id}/complete-cart
* @oas [post] /carts/{id}/complete
* summary: "Complete a Cart"
* operationId: "PostCartsCartComplete"
* description: "Completes a cart. The following steps will be performed. Payment
@@ -24,6 +24,12 @@ export default (app, container) => {
route.post("/:id", middlewares.wrap(require("./update-cart").default))
route.post(
"/:id/complete",
middlewares.wrap(require("./complete-cart").default)
)
// DEPRECATION
route.post(
"/:id/complete-cart",
middlewares.wrap(require("./complete-cart").default)
@@ -55,7 +61,7 @@ export default (app, container) => {
)
route.post(
"/:id/payment-session/update",
"/:id/payment-sessions/:provider_id",
middlewares.wrap(require("./update-payment-session").default)
)
@@ -2,12 +2,13 @@ import { Validator, MedusaError } from "medusa-core-utils"
import { defaultFields, defaultRelations } from "./"
/**
* @oas [post] /carts/{id}/payment-session/update
* @oas [post] /carts/{id}/payment-sessions/{provider_id}
* operationId: PostCartsCartPaymentSessionUpdate
* summary: Update a Payment Session
* description: "Updates a Payment Session with additional data."
* parameters:
* - (path) id=* {string} The id of the Cart.
* - (path) provider_id=* {string} The id of the payment provider.
* - (body) provider_id=* {string} The id of the Payment Provider responsible for the Payment Session to update.
* - (body) data=* {object} The data to update the payment session with.
* tags:
@@ -23,10 +24,10 @@ import { defaultFields, defaultRelations } from "./"
* $ref: "#/components/schemas/cart"
*/
export default async (req, res) => {
const { id } = req.params
const { id, provider_id } = req.params
const schema = Validator.object().keys({
session: Validator.object().required(),
data: Validator.object().required(),
})
const { value, error } = schema.validate(req.body)
@@ -37,7 +38,8 @@ export default async (req, res) => {
try {
const cartService = req.scope.resolve("cartService")
await cartService.updatePaymentSession(id, value.session)
await cartService.setPaymentSession(id, provider_id)
await cartService.updatePaymentSession(id, value.data)
const cart = await cartService.retrieve(id, {
select: defaultFields,
+3 -3
View File
@@ -461,9 +461,9 @@ class OrderService extends BaseService {
)
}
const paymentStatus = await this.paymentProviderService_.getStatus(
payment
)
const paymentStatus = await this.paymentProviderService_
.withTransaction(manager)
.getStatus(payment)
// If payment status is not authorized, we throw
if (paymentStatus !== "authorized" && paymentStatus !== "succeeded") {
@@ -27,6 +27,7 @@ class PaymentProviderService extends BaseService {
const cloned = new PaymentProviderService(this.container_)
cloned.transactionManager_ = manager
cloned.manager_ = manager
return cloned
}