Skip to content

Commit

Permalink
Stripe: add public key in global
Browse files Browse the repository at this point in the history
  • Loading branch information
falkodev committed Oct 9, 2024
1 parent 478f6cd commit ce03370
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ MONGO_INITDB_USER_PASSWORD=app_password_to_change
APOS_MONGODB_URI=mongodb://app-admin:app_password_to_change@pdl-db:27017/library
PORT=3000
APOS_BASE_URL=http://localhost:3000
STRIPE_SECRET_KEY=secret_key_to_change
# APOS_DEV=1 # activate this line to rebuild Apostrophe UI in dev mode
9 changes: 9 additions & 0 deletions server/modules/@apostrophecms/global/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ module.exports = {
},
},
},
stripePublicKey: {
type: 'string',
},
},
group: {
links: {
Expand All @@ -106,6 +109,12 @@ module.exports = {
'headerNav', 'footerNav', 'footerLegal', 'social',
],
},
stripe: {
label: 'Stripe',
fields: [
'stripePublicKey',
],
},
},
},
}
2 changes: 1 addition & 1 deletion server/modules/donate/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const url = require('url')
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY)

module.exports = {
extend: '@apostrophecms/module',
Expand All @@ -26,6 +25,7 @@ module.exports = {
}))
}

const stripe = require('stripe')(req.data.global.stripePublicKey)
const session = await stripe.checkout.sessions.create({
line_items: [
{
Expand Down

0 comments on commit ce03370

Please sign in to comment.