-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from barakamwakisha/api-ext
Add Shop API extensions
- Loading branch information
Showing
6 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"vendure-mpesa-plugin": patch | ||
--- | ||
|
||
add shop api extensions to check and verify payment status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import gql from "graphql-tag" | ||
|
||
export const shopApiExtensions = gql` | ||
extend type Mutation { | ||
verifyMpesaTransaction(transactionId: String!): Boolean! | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Args, Mutation, Resolver } from "@nestjs/graphql" | ||
import { Ctx, RequestContext } from "@vendure/core" | ||
|
||
import { MpesaService } from "../service/mpesa.service" | ||
|
||
@Resolver() | ||
export class MpesaShopResolver { | ||
constructor(private readonly mpesaService: MpesaService) {} | ||
|
||
@Mutation() | ||
async verifyMpesaTransaction( | ||
@Ctx() ctx: RequestContext, | ||
@Args() args: { transactionId: string } | ||
): Promise<boolean> { | ||
const isSuccessful = await this.mpesaService.verifyMpesaPayment( | ||
ctx, | ||
args.transactionId | ||
) | ||
return isSuccessful | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters