Skip to content

Commit

Permalink
Merge pull request #39 from iamshabell/edahab-web-support
Browse files Browse the repository at this point in the history
add: edahab web support
  • Loading branch information
iamshabell authored Dec 16, 2023
2 parents 934958d + a772d10 commit 996b5a6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ app.get('/purchase', async (req, res) => {
amount: 500,
currency: Currency.SLSH,
description: "Test purchase",
// for web handlers, you can optionally provide a return URL
returnUrl: "https://example.com/return",
});

res.send(paymentInfo);
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/pages/guide/purchase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ app.get('/purchase', async (req, res) => {
amount: 500,
currency: Currency.SLSH,
description: "Test purchase",
// for web handlers, you can optionally provide a return URL
returnUrl: "https://example.com/return",
});

res.send(paymentInfo);
Expand Down
2 changes: 2 additions & 0 deletions examples/express-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ app.get('/purchase', async (req, res) => {
amount: 500,
currency: Currency.SLSH,
description: "Test purchase",
// for web handlers, you can optionally provide a return URL
returnUrl: "https://example.com/return",
});

res.send(paymentInfo);
Expand Down
2 changes: 2 additions & 0 deletions packages/marupay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ app.get('/purchase', async (req, res) => {
amount: 500,
currency: Currency.SLSH,
description: "Test purchase",
// for web handlers, you can optionally provide a return URL
returnUrl: "https://example.com/return",
});

res.send(paymentInfo);
Expand Down
9 changes: 6 additions & 3 deletions packages/marupay/src/handlers/edahab/edahab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export const createEdahabHandler = defineHandler({
creditUrl: z.string(),
}),
}),
purchase: edahabPurchase,
purchase: z.object({
returnUrl: z.string().optional(),
...edahabPurchase.shape,
}),
credit: edahabPurchase,
},
defaultConfig: {
Expand All @@ -71,7 +74,7 @@ export const createEdahabHandler = defineHandler({
creditUrl: '/api/agentPayment?hash=',
},
},
purchase: async ({ ctx, options }: { ctx: PaymentCtx, options: PaymentOptions }) => {
purchase: async ({ ctx, options }) => {
const parsedData = safeParse(edahabPurchase.pick({ accountNumber: true }), { accountNumber: options.accountNumber });
const accountNumber = parsedData.accountNumber.replace(SO_ACCOUNT_NUMBER, '');
const { links } = ctx;
Expand All @@ -84,7 +87,7 @@ export const createEdahabHandler = defineHandler({

return await requestFn(requestUrl, requestData, referenceId);
},
credit: async ({ ctx, options }: { ctx: PaymentCtx, options: PaymentOptions }) => {
credit: async ({ ctx, options }) => {
const parsedData = safeParse(edahabPurchase.pick({ accountNumber: true }), { accountNumber: options.accountNumber });
const accountNumber = parsedData.accountNumber.replace(SO_ACCOUNT_NUMBER, '');
const { links } = ctx;
Expand Down

0 comments on commit 996b5a6

Please sign in to comment.