Skip to content

Commit

Permalink
Merge pull request #416 from flowforge/fix-existing-team-billing-0.3.x
Browse files Browse the repository at this point in the history
Fix existing team billing 0.3.x
  • Loading branch information
hardillb authored Mar 25, 2022
2 parents 012278d + 0af3596 commit 1180986
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#### 0.3.2: Maintence Release

- Fix setup of billing for existing project (#414) @hardillb

#### 0.3.1: Maintence Release

- Fix broken storage routes (creds/sessions) (#402) @hardillb
Expand Down
1 change: 1 addition & 0 deletions forge/ee/lib/billing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports.init = function (app) {
}
},
client_reference_id: team.hashid,
allow_promotion_codes: true,
payment_method_types: ['card'],
success_url: `${app.config.base_url}/team/${team.slug}/overview?billing_session={CHECKOUT_SESSION_ID}`,
cancel_url: `${app.config.base_url}/team/${team.slug}/overview`
Expand Down
11 changes: 9 additions & 2 deletions forge/ee/routes/billing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ module.exports = async function (app) {
*/
app.addHook('preHandler', async (request, response) => {
if (request.params.teamId) {
request.teamMembership = await request.session.User.getTeamMembership(request.params.teamId)
if (!request.teamMembership) {
response.code(404).type('text/html').send('Not Found')
}
request.team = await app.db.models.Team.byId(request.params.teamId)
if (!request.team) {
response.code(404).type('text/html').send('Not Found')
Expand Down Expand Up @@ -77,13 +81,16 @@ module.exports = async function (app) {
response.status(404).type('text/html').send('Not Found')
return
}
} else {
response.status(404).type('text/html').send('Not Found')
return
}

switch (event.type) {
case 'checkout.session.completed':
// console.log(event)
app.log.info(`Created Subscription for team ${team.hashid}`)
app.db.controllers.Subscription.createSubscription(team, subscription, customer)
await app.db.controllers.Subscription.createSubscription(team, subscription, customer)
// app.db.controllers.AuditLog.teamLog({
// team.id,
// user.id,
Expand Down Expand Up @@ -121,7 +128,7 @@ module.exports = async function (app) {
* @memberof forge.ee.billing
*/
app.get('/teams/:teamId', {
preHandler: app.needsPermission('team:create')
preHandler: app.needsPermission('team:edit')
}, async (request, response) => {
const team = request.team
const sub = await app.db.models.Subscription.byTeam(team.id)
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/team/Settings/Billing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export default {
// this.loading = false
} catch (err) {
// check for 404 and redirect if 404 returned
// this.loading = false
if (err.response.status === 404) {
this.loading = false
}
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flowforge/flowforge",
"version": "0.3.1",
"version": "0.3.2",
"description": "An open source low-code development platform",
"scripts": {
"start": "node forge/app.js",
Expand Down

0 comments on commit 1180986

Please sign in to comment.