forked from mrwyndham/fastpocket
bugfix - success and cancel stripe redirects
This commit is contained in:
parent
a826f1bee6
commit
afa4040243
|
@ -6,7 +6,8 @@ FROM golang:latest
|
|||
# Set the Current Working Directory inside the container
|
||||
WORKDIR /app
|
||||
ARG STRIPE_SECRET_KEY=""
|
||||
ARG STRIPE_RETURN_URL=""
|
||||
ARG STRIPE_CANCEL_URL=""
|
||||
ARG STRIPE_SUCCESS_URL=""
|
||||
ARG HOST=""
|
||||
ARG PORT="443"
|
||||
ARG DEVELOPMENT=""
|
||||
|
@ -14,7 +15,8 @@ ARG DEVELOPMENT=""
|
|||
# Set Environment Variables
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}
|
||||
ENV STRIPE_RETURN_URL=${STRIPE_RETURN_URL}
|
||||
ENV STRIPE_CANCEL_URL=${STRIPE_CANCEL_URL}
|
||||
ENV STRIPE_SUCCESS_URL=${STRIPE_SUCCESS_URL}
|
||||
ENV HOST=${HOST}
|
||||
ENV PORT=${PORT}
|
||||
ENV DEVELOPMENT=${DEVELOPMENT}
|
||||
|
|
|
@ -62,11 +62,11 @@ Optionally, to speed up the setup, we have added a [fixtures file](stripe_bootst
|
|||
|
||||
1. clone this package
|
||||
1. set your environment variables to the following
|
||||
1. Dog
|
||||
1. STRIPE_SECRET_KEY=sk_test...
|
||||
2. STRIPE_RETURN_URL=url_to_your_site_after_checkout
|
||||
3. HOST=url_to_where_pocketbase_is_hosted
|
||||
4. DEVELOPMENT="" <-- leave blank if deploying live
|
||||
2. STRIPE_CANCEL_URL=url_to_your_site_after_checkout_cancel
|
||||
3. STRIPE_SUCCESS_URL=url_to_your_site_after_checkout_success
|
||||
4. HOST=url_to_where_pocketbase_is_hosted
|
||||
5. DEVELOPMENT="" <-- leave blank if deploying live
|
||||
1. Run `go run main.go serve` from a command line in the root of the folder
|
||||
1. Go to a webbrowser and browse to `https://127.0.0.1:8090/_/` and create new admin account and login
|
||||
1. Click `Settings` on the left hand side bar and go to `Import Collections`
|
||||
|
|
|
@ -6,7 +6,8 @@ services:
|
|||
args:
|
||||
STRIPE_SECRET_KEY: sk_test_51Oc1xLGaxPbSqiRDaGtJNmtk3aMQHFHVVSqIaC7TCUK74HQxzkb3jbjDqq5NQyoDEyKSeDitPB2bHX4vXqS8s0z100rXePxwfB
|
||||
HOST: 0.0.0.0
|
||||
STRIPE_RETURN_URL: https://sign365.com.au/account
|
||||
STRIPE_SUCCESS_URL: https://sign365.com.au/account
|
||||
STRIPE_CANCEL_URL: https://sign365.com.au/pricing
|
||||
PORT: 8090
|
||||
DEVELOPMENT: ""
|
||||
platform: linux/amd64
|
||||
|
|
|
@ -12,8 +12,10 @@ primary_region = 'syd'
|
|||
DEVELOPMENT = ''
|
||||
HOST = 'fastpocket.fly.dev'
|
||||
PORT = '8090'
|
||||
STRIPE_RETURN_URL = 'https://www.fastpocket.dev/account'
|
||||
STRIPE_SECRET_KEY = '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'
|
||||
STRIPE_SUCCESS_URL = 'https://www.fastpocket.dev/account'
|
||||
STRIPE_CANCEL_URL = 'https://www.fastpocket.dev/pricing'
|
||||
# requires STRIPE_SECRET_KEY = '{sk_live_...}' to be setup as a secret
|
||||
# see: https://fly.io/docs/reference/secrets/#setting-secrets
|
||||
|
||||
[[mounts]]
|
||||
source = 'data_fastpocket'
|
||||
|
|
|
@ -50,6 +50,8 @@ func main() {
|
|||
app := pocketbase.New()
|
||||
// Retreive your STRIPE_SECRET_KEY from environment variables
|
||||
stripe.Key = os.Getenv("STRIPE_SECRET_KEY")
|
||||
stripeSuccessURL := os.Getenv("STRIPE_SUCCESS_URL")
|
||||
stripeCancelURL := os.Getenv("STRIPE_CANCEL_URL")
|
||||
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||
e.Router.POST("/create-checkout-session", func(c echo.Context) error {
|
||||
// 1. Destructure the price and quantity from the POST body
|
||||
|
@ -126,8 +128,8 @@ func main() {
|
|||
CustomerUpdate: customerUpdateParams,
|
||||
Mode: stripe.String("subscription"),
|
||||
AllowPromotionCodes: stripe.Bool(true),
|
||||
SuccessURL: stripe.String("https://www.sign365.com.au/account"),
|
||||
CancelURL: stripe.String("https://www.sign365.com.au/"),
|
||||
SuccessURL: &stripeSuccessURL,
|
||||
CancelURL: &stripeCancelURL,
|
||||
LineItems: lineParams,
|
||||
SubscriptionData: subscriptionParams,
|
||||
}
|
||||
|
@ -152,8 +154,8 @@ func main() {
|
|||
CustomerUpdate: customerUpdateParams,
|
||||
Mode: stripe.String("payment"),
|
||||
AllowPromotionCodes: stripe.Bool(true),
|
||||
SuccessURL: stripe.String("https://www.sign365.com.au/account"),
|
||||
CancelURL: stripe.String("https://www.sign365.com.au/"),
|
||||
SuccessURL: &stripeSuccessURL,
|
||||
CancelURL: &stripeCancelURL,
|
||||
LineItems: lineParams,
|
||||
}
|
||||
sesh, _ := checkoutSession.New(sessionParams)
|
||||
|
@ -185,8 +187,8 @@ func main() {
|
|||
CustomerUpdate: customerUpdateParams,
|
||||
Mode: stripe.String("subscription"),
|
||||
AllowPromotionCodes: stripe.Bool(true),
|
||||
SuccessURL: stripe.String("https://www.sign365.com.au/account"),
|
||||
CancelURL: stripe.String("https://www.sign365.com.au/"),
|
||||
SuccessURL: &stripeSuccessURL,
|
||||
CancelURL: &stripeCancelURL,
|
||||
LineItems: lineParams,
|
||||
SubscriptionData: subscriptionParams,
|
||||
}
|
||||
|
@ -211,8 +213,8 @@ func main() {
|
|||
CustomerUpdate: customerUpdateParams,
|
||||
Mode: stripe.String("payment"),
|
||||
AllowPromotionCodes: stripe.Bool(true),
|
||||
SuccessURL: stripe.String("https://www.sign365.com.au/account"),
|
||||
CancelURL: stripe.String("https://www.sign365.com.au/"),
|
||||
SuccessURL: &stripeSuccessURL,
|
||||
CancelURL: &stripeCancelURL,
|
||||
LineItems: lineParams,
|
||||
}
|
||||
sesh, _ := checkoutSession.New(sessionParams)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "STRIPE_SECRET_KEY = $STRIPE_SECRET_KEY"
|
||||
echo "STRIPE_RETURN_URL = $STRIPE_RETURN_URL"
|
||||
echo "STRIPE_CANCEL_URL = $STRIPE_CANCEL_URL"
|
||||
echo "STRIPE_SUCCESS_URL = $STRIPE_SUCCESS_URL"
|
||||
echo "HOST = $HOST"
|
||||
echo "PORT = $PORT"
|
||||
echo "DEVELOPMENT = $DEVELOPMENT"
|
||||
|
|
Loading…
Reference in New Issue