Skip to content

Commit

Permalink
fix: add companyPrefix to refundWorker mollie getRefunds
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanvanherwijnen committed Oct 15, 2024
1 parent 95a1e36 commit 896e945
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 29 deletions.
6 changes: 4 additions & 2 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
"@fastify/cors": "^10.0.1",
"@fastify/middie": "9.0.2",
"@fastify/static": "8.0.1",
"@modular-api/api": "^0.5.2",
"@modular-api/api": "^0.5.3",
"@modular-api/fastify-cart": "^0.3.0",
"@modular-api/fastify-checkout": "^0.4.2",
"@modular-api/fastify-checkout": "^0.4.3",
"@modular-api/fastify-oidc": "^0.6.0",
"@mollie/api-client": "^4.0.0",
"@slimfact/app": "^0.1.0",
Expand All @@ -77,6 +77,7 @@
"@faker-js/faker": "^9.0.2",
"@playwright/test": "1.47.2",
"@types/bcrypt": "^5.0.2",
"@types/oidc-provider": "^8.5.2",
"@types/pg": "^8.11.10",
"@vitejs/plugin-vue": "5.1.4",
"critters": "0.0.24",
Expand All @@ -87,6 +88,7 @@
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "9.28.0",
"kysely-codegen": "^0.16.8",
"oidc-provider": "^8.5.1",
"quasar": "2.17.0",
"typescript": "5.6.2",
"typescript-eslint": "^8.7.0",
Expand Down
32 changes: 25 additions & 7 deletions packages/api/src/pgboss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,40 @@ const createRefundWorker = ({ fastify }: { fastify: FastifyInstance }) =>
async function refundWorker() {
const refunds = await db
.selectFrom('checkout.refunds')
.innerJoin(
'checkout.payments',
'checkout.payments.id',
'checkout.refunds.paymentId'
)
.innerJoin(
'checkout.invoices',
'checkout.invoices.id',
'checkout.payments.invoiceId'
)
.where((web) =>
web.or([
web('status', '=', RefundStatus.PENDING),
web('status', '=', RefundStatus.PROCESSING),
web('status', '=', RefundStatus.QUEUED)
web('checkout.refunds.status', '=', RefundStatus.PENDING),
web('checkout.refunds.status', '=', RefundStatus.PROCESSING),
web('checkout.refunds.status', '=', RefundStatus.QUEUED)
])
)
.where('checkout.refunds.paymentServiceProvider', '=', 'mollie')
.select('id')
.select((seb) => [
'checkout.refunds.id',
seb
.ref('checkout.invoices.companyDetails', '->>')
.key('prefix')
.as('companyPrefix')
])
.execute()

for (const refund of refunds) {
if (fastify.checkout?.paymentHandlers?.mollie) {
await fastify.checkout.paymentHandlers.mollie().getRefund({
id: refund.id
})
await fastify.checkout.paymentHandlers
.mollie(refund.companyPrefix)
.getRefund({
id: refund.id
})
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
},
"devDependencies": {
"@modular-api/fastify-cart": "^0.3.0",
"@modular-api/fastify-checkout": "^0.4.2",
"@modular-api/quasar-components": "^0.3.0",
"@modular-api/fastify-checkout": "^0.4.3",
"@modular-api/quasar-components": "^0.3.1",
"@quasar/extras": "1.16.12",
"@quasar/quasar-ui-qcalendar": "4.0.0-beta.16",
"@simsustech/quasar-components": "^0.10.5",
Expand Down
103 changes: 85 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 896e945

Please sign in to comment.