#pastyghost_code
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1255000806021927025
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hi, yes the client_secret is separate from the publisahble key. That secret gets returned in the response, https://docs.stripe.com/checkout/embedded/quickstart
Okay, I passed in my API key, but I'm still not getting a client_secret back.
What are you getting in the response?
"body": "{\"after_expiration\":null,\"allow_promotion_codes\":false,\"amount_subtotal\":0,\"amount_total\":0,\"automatic_tax\":null,\"billing_address_collection\":\"\",\"cancel_url\":\"\",\"client_reference_id\":\"\",\"client_secret\":\"\",\"consent\":null,\"consent_collection\":null,\"created\":0,\"currency\":\"\",\"currency_conversion\":null,\"customer\":null,\"customer_creation\":\"\",\"customer_details\":null,\"customer_email\":\"\",\"custom_fields\":null,\"custom_text\":null,\"expires_at\":0,\"id\":\"\",\"invoice\":null,\"invoice_creation\":null,\"line_items\":null,\"livemode\":false,\"locale\":\"\",\"metadata\":null,\"mode\":\"\",\"object\":\"\",\"payment_intent\":null,\"payment_link\":null,\"payment_method_collection\":\"\",\"payment_method_configuration_details\":null,\"payment_method_options\":null,\"payment_method_types\":null,\"payment_status\":\"\",\"phone_number_collection\":null,\"recovered_from\":\"\",\"redirect_on_completion\":\"\",\"return_url\":\"\",\"saved_payment_method_options\":null,\"setup_intent\":null,\"shipping_address_collection\":null,\"shipping_cost\":null,\"shipping_details\":null,\"shipping_options\":null,\"status\":\"\",\"submit_type\":\"\",\"subscription\":null,\"success_url\":\"\",\"tax_id_collection\":null,\"total_details\":null,\"ui_mode\":\"\",\"url\":\"\"}"
}
Yep, one second.
can you share the request id when attempting to create the Session? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
package main
import (
"context"
"encoding/json"
"log"
"os"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/stripe/stripe-go/v78"
"github.com/stripe/stripe-go/v78/checkout/session"
)
type ClientSecret struct {
Value string `json:"value"`
}
func CreateCheckoutSession (ctx context.Context, request events.APIGatewayProxyRequest) (response events.APIGatewayProxyResponse, err error) {
stripe.Key = os.Getenv("STRIPE_API_KEY")
domain := os.Getenv("FRONTEND_URL")
params := &stripe.CheckoutSessionParams{
UIMode: stripe.String("embedded"),
ReturnURL: stripe.String(domain + "/success.html?session_id={CHECKOUT_SESSION_ID}"),
LineItems: []*stripe.CheckoutSessionLineItemParams{
{
Price: stripe.String(("price_1MwGfXGVt95r9kfacC10ZCX1")),
Quantity: stripe.Int64(1),
},
},
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)},
}
s, sessionErr := session.New(params)
if sessionErr != nil {
log.Printf("session error: %v", sessionErr)
}
session, marshalErr := json.Marshal(s)
if marshalErr != nil {
log.Printf("marshalling error: %v", marshalErr)
}
return events.APIGatewayProxyResponse{
StatusCode: 200,
Headers: map[string]string{
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods" : "GET, OPTIONS, POST",
"Access-Control-Allow-Headers" : "*",
},
Body: string(session),
}, err
}
func main() {
lambda.Start(CreateCheckoutSession)
}
Can you share the reques id please?
Yes!
You did pass one, return_url, it is just not valid
I think that mostly got me going. I will reach back out if I have further questions. ๐
Thanks so much!
Happy to help!
I did have another quick question if you don't mind: is it standard practice to POST price IDs to handle multiple products?
Are you asking if you need separate price id for each product id?
Or, something else?
Maybe this will helo clarify: https://docs.stripe.com/products-prices/how-products-and-prices-work
Each product would have prices
No - so let's say I had Product X and Product Y - could I POST a JSON with a price_id string to handle X or Y depending on what was POSTed?
I do not understand, can you reword this please?
After re-reading this, I think you're asking if you can add a condition to use one product over the other.
No there is not, you would need to code this on your end and then pass the product information on the CheckoutSession.
That second bit is actually what I was asking - thanks for confirming! ๐
Sure!