-
Notifications
You must be signed in to change notification settings - Fork 0
Stripe Link creation support in manage.acm #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2505d44
basic setup
devksingh4 3f5dd37
basic setup
devksingh4 1a6b4ba
use the stripe plink ID as the normal ID
devksingh4 db53533
fix vitest resolution
devksingh4 1b3ff85
fix vitest module resolution part 2
devksingh4 7a49d2a
try a basic test
devksingh4 a2a6019
update mobile wallet test timeout
devksingh4 c2a9f20
add unit tests for the stripe routes
devksingh4 b2e9f08
update tests and utils
devksingh4 ab50ef4
update live tests to have auth in gh env
devksingh4 c298140
fix live test
devksingh4 daf0246
update event tests
devksingh4 7c3fd98
fix linter warnings
devksingh4 79fc76e
build the create panel
devksingh4 37111e6
basic create link panel tests
devksingh4 0354ca2
some cleanup
devksingh4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,36 +1,36 @@ | ||
| import jwt from 'jsonwebtoken'; | ||
| import jwt from "jsonwebtoken"; | ||
| import * as dotenv from "dotenv"; | ||
| dotenv.config(); | ||
|
|
||
| const username = process.env.JWTGEN_USERNAME || '[email protected]' | ||
| const username = process.env.JWTGEN_USERNAME || "[email protected]" | ||
| const payload = { | ||
| aud: "custom_jwt", | ||
| iss: "custom_jwt", | ||
| iat: Math.floor(Date.now() / 1000), | ||
| nbf: Math.floor(Date.now() / 1000), | ||
| exp: Math.floor(Date.now() / 1000) + (3600 * 24), // Token expires after 24 hour | ||
| acr: "1", | ||
| aio: "AXQAi/8TAAAA", | ||
| amr: ["pwd"], | ||
| appid: "your-app-id", | ||
| appidacr: "1", | ||
| email: username, | ||
| groups: ["0"], | ||
| idp: "https://login.microsoftonline.com", | ||
| ipaddr: "192.168.1.1", | ||
| name: "Doe, John", | ||
| oid: "00000000-0000-0000-0000-000000000000", | ||
| rh: "rh-value", | ||
| scp: "user_impersonation", | ||
| sub: "subject", | ||
| tid: "tenant-id", | ||
| unique_name: username, | ||
| uti: "uti-value", | ||
| ver: "1.0" | ||
| aud: "custom_jwt", | ||
| iss: "custom_jwt", | ||
| iat: Math.floor(Date.now() / 1000), | ||
| nbf: Math.floor(Date.now() / 1000), | ||
| exp: Math.floor(Date.now() / 1000) + 3600 * 24, // Token expires after 24 hour | ||
| acr: "1", | ||
| aio: "AXQAi/8TAAAA", | ||
| amr: ["pwd"], | ||
| appid: "your-app-id", | ||
| appidacr: "1", | ||
| email: username, | ||
| groups: ["0"], | ||
| idp: "https://login.microsoftonline.com", | ||
| ipaddr: "192.168.1.1", | ||
| name: "Doe, John", | ||
| oid: "00000000-0000-0000-0000-000000000000", | ||
| rh: "rh-value", | ||
| scp: "user_impersonation", | ||
| sub: "subject", | ||
| tid: "tenant-id", | ||
| unique_name: username, | ||
| uti: "uti-value", | ||
| ver: "1.0", | ||
| }; | ||
|
|
||
| const secretKey = process.env.JwtSigningKey; | ||
| const token = jwt.sign(payload, secretKey, { algorithm: 'HS256' }); | ||
| console.log(`USERNAME=${username}`) | ||
| console.log('=====================') | ||
| console.log(token) | ||
| const token = jwt.sign(payload, secretKey, { algorithm: "HS256" }); | ||
| console.log(`USERNAME=${username}`); | ||
| console.log("====================="); | ||
| console.log(token); | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -81,4 +81,4 @@ | |
| "resolutions": { | ||
| "pdfjs-dist": "^4.8.69" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,56 @@ | ||
| import { FastifyBaseLogger } from "fastify"; | ||
| import Stripe from "stripe"; | ||
|
|
||
| export type StripeLinkCreateParams = { | ||
| invoiceId: string; | ||
| invoiceAmountUsd: number; | ||
| contactName: string; | ||
| contactEmail: string; | ||
| createdBy: string; | ||
| stripeApiKey: string; | ||
| }; | ||
|
|
||
| /** | ||
| * Create a Stripe payment link for an invoice. Note that invoiceAmountUsd MUST IN CENTS!! | ||
| * @param {StripeLinkCreateParams} options | ||
| * @returns {string} A stripe link that can be used to pay the invoice | ||
| */ | ||
| export const createStripeLink = async ({ | ||
| invoiceId, | ||
| invoiceAmountUsd, | ||
| contactName, | ||
| contactEmail, | ||
| createdBy, | ||
| stripeApiKey, | ||
| }: StripeLinkCreateParams): Promise<{ | ||
| linkId: string; | ||
| priceId: string; | ||
| productId: string; | ||
| url: string; | ||
| }> => { | ||
| const stripe = new Stripe(stripeApiKey); | ||
| const description = `Created For: ${contactName} (${contactEmail}) by ${createdBy}.`; | ||
| const product = await stripe.products.create({ | ||
| name: `Payment for Invoice: ${invoiceId}`, | ||
| description, | ||
| }); | ||
| const price = await stripe.prices.create({ | ||
| currency: "usd", | ||
| unit_amount: invoiceAmountUsd, | ||
| product: product.id, | ||
| }); | ||
| const paymentLink = await stripe.paymentLinks.create({ | ||
| line_items: [ | ||
| { | ||
| price: price.id, | ||
| quantity: 1, | ||
| }, | ||
| ], | ||
| }); | ||
| return { | ||
| url: paymentLink.url, | ||
| linkId: paymentLink.id, | ||
| productId: product.id, | ||
| priceId: price.id, | ||
| }; | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.