-
Notifications
You must be signed in to change notification settings - Fork 8
Stripe initial impl #27
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b2713dc
stripe iniitial implementation
davidcheung dc91a58
fixup! stripe iniitial implementation
davidcheung a141075
fixup! fixup! stripe iniitial implementation
davidcheung 15d2afe
fixup! fixup! fixup! stripe iniitial implementation
davidcheung 3926f4b
fixup! fixup! fixup! fixup! stripe iniitial implementation
davidcheung 1d55c76
fixup! fixup! fixup! fixup! fixup! stripe iniitial implementation
davidcheung 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script runs only when billingEnabled = "yes", invoked from makefile | ||
| # modify the kubernetes application secret and appends STRIPE_API_SECRET_KEY | ||
| # the deployment by default will pick up all key-value pairs as env-vars from the secret | ||
|
|
||
| if [[ "$ENVIRONMENT" == "" ]]; then | ||
| echo "Must specify \$ENVIRONMENT to create stripe secret ">&2; exit 1; | ||
| elif [[ "$ENVIRONMENT" == "stage" ]]; then | ||
| PUBLISHABLE_API_KEY=$stagingStripePublicApiKey | ||
| SECRET_API_KEY=$stagingStripeSecretApiKey | ||
| elif [[ "$ENVIRONMENT" == "prod" ]]; then | ||
| PUBLISHABLE_API_KEY=$productionStripePublicApiKey | ||
| SECRET_API_KEY=$productionStripeSecretApiKey | ||
| fi | ||
|
|
||
| CLUSTER_NAME=${PROJECT_NAME}-${ENVIRONMENT}-${REGION} | ||
| NAMESPACE=${PROJECT_NAME} | ||
|
|
||
| BASE64_TOKEN=$(printf ${SECRET_API_KEY} | base64) | ||
| ## Modify existing application secret to have stripe api key | ||
| kubectl --context $CLUSTER_NAME -n $NAMESPACE get secret ${PROJECT_NAME} -o json | \ | ||
| jq --arg STRIPE_API_SECRET_KEY $BASE64_TOKEN '.data["STRIPE_API_SECRET_KEY"]=$STRIPE_API_SECRET_KEY' \ | ||
| | kubectl apply -f - | ||
|
|
||
| sh ${PROJECT_DIR}/scripts/stripe-example-setup.sh | ||
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,6 +1,6 @@ | ||
| DATABASE_ENGINE= | ||
| DATABASE_ENGINE=<% index .Params `database` %> | ||
| DATABASE_HOST= | ||
| DATABASE_PORT= | ||
| DATABASE_PORT=<%if eq (index .Params `database`) "postgres" %>5432<% else if eq (index .Params `database`) "mysql" %>3306<% end %> | ||
| DATABASE_PASSWORD= | ||
| DATABASE_USERNAME= | ||
| DATABASE_NAME= |
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
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 |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| #!/bin/bash | ||
|
davidcheung marked this conversation as resolved.
|
||
| set -e | ||
|
|
||
| # Creates stripe example for frontend/backend for checkout and subscription | ||
| # the script uses the token and creates the following for the end-to-end example to work | ||
| # - 1 product | ||
| # - 3 plans | ||
| # - 1 webhook | ||
| # | ||
| # If you want to recreate this you can use the curl requests as an example below. | ||
|
|
||
| PROJECT_NAME=<% .Name %> | ||
| RANDOM_SEED=<% index .Params `randomSeed` %> | ||
| REGION=<% index .Params `region` %> | ||
|
|
||
| echo "Running on ${ENVIRONMENT}" | ||
| if [[ "$ENVIRONMENT" == "" ]]; then | ||
| exit 1; | ||
| elif [[ "$ENVIRONMENT" == "stage" ]]; then | ||
| BACKEND_API_WEBHOOK_ENDPOINT="https://<% index .Params `stagingBackendSubdomain` %><% index .Params `stagingHostRoot` %>/webhook/stripe" | ||
| PUBLISHABLE_API_KEY=$stagingStripePublicApiKey | ||
| SECRET_API_KEY=$stagingStripeSecretApiKey | ||
| elif [[ "$ENVIRONMENT" == "prod" ]]; then | ||
| BACKEND_API_WEBHOOK_ENDPOINT="https://<% index .Params `productionBackendSubdomain` %><% index .Params `productionHostRoot` %>/webhook/stripe" | ||
| PUBLISHABLE_API_KEY=$productionStripePublicApiKey | ||
| SECRET_API_KEY=$productionStripeSecretApiKey | ||
| fi | ||
|
|
||
| TOKEN=$(echo $SECRET_API_KEY | base64) | ||
| AUTH_HEADER="Authorization: Basic ${TOKEN}" | ||
|
|
||
| ## Create Product | ||
| PRODUCT_ID=$(curl -XPOST \ | ||
| --url https://api.stripe.com/v1/products \ | ||
| --header "${AUTH_HEADER}" \ | ||
| -d "name"="$PROJECT_NAME" | jq -r ".id") | ||
|
|
||
| curl https://api.stripe.com/v1/prices \ | ||
| --header "${AUTH_HEADER}" \ | ||
| -d "product"="$PRODUCT_ID" \ | ||
| -d "unit_amount"=5499 \ | ||
| -d "currency"="CAD" \ | ||
| -d "recurring[interval]=month" \ | ||
| -d "nickname"="Monthly Plan" | ||
|
|
||
| curl https://api.stripe.com/v1/prices \ | ||
| --header "${AUTH_HEADER}" \ | ||
| -d "product"="$PRODUCT_ID" \ | ||
| -d "unit_amount"=299 \ | ||
| -d "currency"="CAD" \ | ||
| -d "recurring[interval]=day" \ | ||
| -d "nickname"="Daily Plan" | ||
|
|
||
| curl https://api.stripe.com/v1/prices \ | ||
| --header "${AUTH_HEADER}" \ | ||
| -d "product"="$PRODUCT_ID" \ | ||
| -d "unit_amount"=50000 \ | ||
| -d "currency"="CAD" \ | ||
| -d "recurring[interval]=year" \ | ||
| -d "nickname"="Annual Plan" | ||
|
|
||
| # Create webhook on stripe platform | ||
| # See link for available webhooks: https://stripe.com/docs/api/webhook_endpoints/create?lang=curl#create_webhook_endpoint-enabled_events | ||
| curl https://api.stripe.com/v1/webhook_endpoints \ | ||
| --header "${AUTH_HEADER}" \ | ||
| -d url="${BACKEND_API_WEBHOOK_ENDPOINT}" \ | ||
| -d "enabled_events[]"="charge.failed" \ | ||
| -d "enabled_events[]"="charge.succeeded" \ | ||
| -d "enabled_events[]"="customer.created" \ | ||
| -d "enabled_events[]"="subscription_schedule.created" | ||
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.
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.