release: next (#315)

Co-authored-by: Sebastian Mateos Nicolajsen <sebastian.m.nicolajsen@gmail.com>
Co-authored-by: Abraham Ugbeshe <abrahamugbeshe@gmail.com>
Co-authored-by: olivermrbl <oliver@mrbltech.com>
This commit is contained in:
committed 2021-07-15 09:37:27 +02:00
1 parent 44d31b4d83
commit 2585e958de
144 files changed
+2554 -240

No files matched your search

@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.0.21](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.20...medusa-payment-paypal@1.0.21) (2021-07-15)
### Bug Fixes
* paypal order ([1f6ee0f](https://github.com/medusajs/medusa/commit/1f6ee0fc00024c25d6628e6531097f93f54f8a1b))
* support for hook completion of swap carts ([fca29cc](https://github.com/medusajs/medusa/commit/fca29cc5cc0d6f20d01fada7445d32da85291cd8))
## [1.0.20](https://github.com/medusajs/medusa/compare/medusa-payment-paypal@1.0.19...medusa-payment-paypal@1.0.20) (2021-07-02)
**Note:** Version bump only for package medusa-payment-paypal
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-payment-paypal",
"version": "1.0.20",
"version": "1.0.21",
"description": "Paypal Payment provider for Meduas Commerce",
"main": "index.js",
"repository": {
@@ -26,8 +26,8 @@
"cross-env": "^5.2.1",
"eslint": "^6.8.0",
"jest": "^25.5.2",
"medusa-interfaces": "^1.1.17",
"medusa-test-utils": "^1.1.19"
"medusa-interfaces": "^1.1.18",
"medusa-test-utils": "^1.1.20"
},
"scripts": {
"build": "babel src -d . --ignore **/__tests__,**/__mocks__",
@@ -42,7 +42,7 @@
"@paypal/checkout-server-sdk": "^1.0.2",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.1.16"
"medusa-core-utils": "^1.1.17"
},
"gitHead": "db9d6c0cf55ff60a90415b16bc7582cc4795768f"
}
@@ -22,7 +22,8 @@ export default async (req, res) => {
}
try {
const authId = req.body.resource.id
const body = req.body
const authId = body.resource.id
const auth = await paypalService.retrieveAuthorization(authId)
const order = await paypalService.retrieveOrderFromAuth(auth)
@@ -37,18 +38,44 @@ export default async (req, res) => {
const manager = req.scope.resolve("manager")
const cartService = req.scope.resolve("cartService")
const swapService = req.scope.resolve("swapService")
const orderService = req.scope.resolve("orderService")
await manager.transaction(async (m) => {
const order = await orderService
.withTransaction(m)
.retrieveByCartId(cartId)
.catch((_) => undefined)
const cart = await cartService.withTransaction(m).retrieve(cartId)
if (!order) {
await cartService.withTransaction(m).setPaymentSession(cartId, "paypal")
await cartService.withTransaction(m).authorizePayment(cartId)
await orderService.withTransaction(m).createFromCart(cartId)
switch (cart.type) {
case "swap": {
const swap = await swapService
.withTransaction(m)
.retrieveByCartId(cartId)
.catch((_) => undefined)
if (swap && swap.confirmed_at === null) {
await cartService
.withTransaction(m)
.setPaymentSession(cartId, "paypal")
await cartService.withTransaction(m).authorizePayment(cartId)
await swapService.withTransaction(m).registerCartCompletion(swap.id)
}
break
}
default: {
const order = await orderService
.withTransaction(m)
.retrieveByCartId(cartId)
.catch((_) => undefined)
if (!order) {
await cartService
.withTransaction(m)
.setPaymentSession(cartId, "paypal")
await cartService.withTransaction(m).authorizePayment(cartId)
await orderService.withTransaction(m).createFromCart(cartId)
}
break
}
}
})