Skip to content
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

Stripe Setup #27

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ const config = {
img-src 'self' data: opencollective-production.s3.us-west-1.amazonaws.com opencollective-production.s3-us-west-1.amazonaws.com opencollective.com images.opencollective.com images-staging.opencollective.com blog.opencollective.com;
worker-src 'none';
style-src 'self' 'unsafe-inline';
connect-src 'self' opencollective.com api.opencollective.com api-staging.opencollective.com;
script-src 'self' 'unsafe-eval' 'unsafe-inline';
frame-src 'none';
connect-src 'self' api.stripe.com opencollective.com api.opencollective.com api-staging.opencollective.com;
script-src 'self' 'unsafe-eval' 'unsafe-inline' js.stripe.com;
frame-src js.stripe.com hooks.stripe.com;
`
: `
block-all-mixed-content;
default-src 'self';
img-src 'self' data: opencollective-production.s3.us-west-1.amazonaws.com opencollective-production.s3-us-west-1.amazonaws.com opencollective.com images.opencollective.com images-staging.opencollective.com blog.opencollective.com;
worker-src 'none';
style-src 'self' 'unsafe-inline';
connect-src 'self' opencollective.com api.opencollective.com api-staging.opencollective.com;
script-src 'self';
frame-src 'none';
connect-src 'self' api.stripe.com opencollective.com api.opencollective.com api-staging.opencollective.com;
script-src 'self' js.stripe.com;
frame-src js.stripe.com hooks.stripe.com;
`
)
.replace(/\s{2,}/g, ' ')
Expand Down
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"dependencies": {
"@apollo/client": "3.7.1",
"@opencollective/frontend-components": "0.3.8",
"@stripe/react-stripe-js": "^1.15.0",
"@stripe/stripe-js": "^1.44.1",
"@styled-system/prop-types": "^5.1.5",
"babel-plugin-formatjs": "^10.3.31",
"babel-plugin-react-remove-properties": "^0.3.0",
Expand Down
28 changes: 17 additions & 11 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { ApolloProvider } from '@apollo/client';
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe } from '@stripe/stripe-js';
import type { AppProps } from 'next/app';
import { SessionProvider } from 'next-auth/react';
import NextNProgress from 'nextjs-progressbar';
Expand All @@ -9,6 +11,8 @@ import { createGlobalStyle, ThemeProvider } from 'styled-components';
import { useApollo } from '../lib/apollo-client';
import theme from '@opencollective/frontend-components/lib/theme';

const stripePromise = loadStripe('pk_test_VgSB4VSg2wb5LdAkz7p38Gw8');

const GlobalStyles = createGlobalStyle`
@font-face {
font-family: 'Inter';
Expand Down Expand Up @@ -128,16 +132,18 @@ const GlobalStyles = createGlobalStyle`
export default function App({ Component, pageProps }: AppProps) {
const apolloClient = useApollo(pageProps);
return (
<SessionProvider session={pageProps['session']} refetchInterval={0}>
<IntlProvider locale="en">
<ApolloProvider client={apolloClient}>
<ThemeProvider theme={theme}>
<GlobalStyles />
<NextNProgress />
<Component {...pageProps} />
</ThemeProvider>
</ApolloProvider>
</IntlProvider>
</SessionProvider>
<Elements stripe={stripePromise}>
<SessionProvider session={pageProps['session']} refetchInterval={0}>
<IntlProvider locale="en">
<ApolloProvider client={apolloClient}>
<ThemeProvider theme={theme}>
<GlobalStyles />
<NextNProgress />
<Component {...pageProps} />
</ThemeProvider>
</ApolloProvider>
</IntlProvider>
</SessionProvider>
</Elements>
);
}