-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stripe): add stripe support to pay for different tier
- Loading branch information
Showing
47 changed files
with
691 additions
and
177 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
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
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 was deleted.
Oops, something went wrong.
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
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
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,46 @@ | ||
import { postCheckoutSession, postPortalSession, postWebhook } from './shared/commands'; | ||
|
||
jest.unmock('mongoose'); | ||
|
||
describe('Stripe', () => { | ||
describe('/POST Stripe Checkout', () => { | ||
it('redirect to checkout session', async () => { | ||
const res = await postCheckoutSession({ developerId: 'developerId', lookupKey: '123' }); | ||
expect(res.status).toEqual(303); | ||
expect(res.headers.location).toEqual('checkout_session_url'); | ||
}); | ||
|
||
it('fail to redirect to checkout session missing developerId', async () => { | ||
// @ts-expect-error lookupKey | ||
const res = await postCheckoutSession({ lookupKey: '123' }); | ||
expect(res.status).toEqual(400); | ||
}); | ||
|
||
it('fail to redirect to checkout session missing lookupKey', async () => { | ||
// @ts-expect-error developerId | ||
const res = await postCheckoutSession({ developerId: '123' }); | ||
expect(res.status).toEqual(400); | ||
}); | ||
}); | ||
describe('/POST Stripe Portal', () => { | ||
it('redirect to portal session', async () => { | ||
const res = await postPortalSession({ sessionId: 'sessionId' }); | ||
expect(res.status).toEqual(303); | ||
expect(res.headers.location).toEqual('portal_session_url'); | ||
}); | ||
|
||
it('fail to redirect to portal session missing sessionId', async () => { | ||
// @ts-expect-error sessionId | ||
const res = await postCheckoutSession({}); | ||
expect(res.status).toEqual(400); | ||
}); | ||
}); | ||
|
||
describe('/POST Stripe Webhook', () => { | ||
it('handle webhooks', async () => { | ||
const res = await postWebhook(); | ||
console.log(res.body); | ||
expect(res.status).toEqual(200); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -49,7 +49,7 @@ | |
"port": 8085 | ||
}, | ||
"hosting": { | ||
"port": 8080 | ||
"port": 8081 | ||
}, | ||
"ui": { | ||
"enabled": false | ||
|
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
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
Oops, something went wrong.