Skip to content

Commit

Permalink
cancel payment on cancelled stk push
Browse files Browse the repository at this point in the history
  • Loading branch information
barakamwakisha committed Feb 7, 2024
1 parent ad6094d commit 422bd4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vendure-mpesa-plugin",
"version": "0.0.10",
"version": "0.0.11",
"description": "Accept Mpesa payments on your Vendure store",
"repository": "[email protected]:barakamwakisha/vendure-mpesa-plugin.git",
"author": "Baraka Mwakisha <[email protected]>",
Expand Down
9 changes: 5 additions & 4 deletions src/service/mpesa.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,13 @@ export class MpesaService {
const isTransactionSuccessful =
await this.checkTransactionStatus(transactionId)

const payment = await this.getPaymentByTransactionId(ctx, transactionId)

if (isTransactionSuccessful) {
Logger.info(
`Transaction ${transactionId} was successful`,
loggerCtx
)
const payment = await this.getPaymentByTransactionId(
ctx,
transactionId
)

if (payment) {
await this.orderService.settlePayment(ctx, payment.id)
Expand All @@ -121,6 +119,9 @@ export class MpesaService {
`Transaction ${transactionId} was not successful`,
loggerCtx
)
if (payment) {
await this.orderService.cancelPayment(ctx, payment.id)
}
}
}

Expand Down

0 comments on commit 422bd4e

Please sign in to comment.