#pastyghost_code
1 messages ¡ Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- pastyghost_code, 8 hours ago, 37 messages
đ 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/1255156471755440229
đ Have more to share? Add details, code, screenshots, videos, etc. below.
Logs:
2024-06-25T09:30:02.187-04:00 START RequestId: cabc5b50-b1d6-43a9-b0ea-fe2c8f861418 Version: $LATEST
2024-06-25T09:30:02.189-04:00 2024/06/25 13:30:02 Body: "price_1PLevaGVt95r9kfaeabGF9bn"
2024-06-25T09:30:03.609-04:00 END RequestId: cabc5b50-b1d6-43a9-b0ea-fe2c8f861418
2024-06-25T09:30:03.609-04:00 REPORT RequestId: cabc5b50-b1d6-43a9-b0ea-fe2c8f861418 Duration: 1422.42 ms Billed Duration: 2255 ms Memory Size: 128 MB Max Memory Used: 29 MB Init Duration: 831.80 ms
2024-06-25T09:35:22.472-04:00 START RequestId: 1aaf156c-0345-4f3f-b2a4-f461e36cf8d4 Version: $LATEST
2024-06-25T09:35:22.488-04:00 2024/06/25 13:35:22 Body: "price_1MwGfXGVt95r9kfacC10ZCX1"
2024-06-25T09:35:23.047-04:00 END RequestId: 1aaf156c-0345-4f3f-b2a4-f461e36cf8d4
2024-06-25T09:35:23.047-04:00 REPORT RequestId: 1aaf156c-0345-4f3f-b2a4-f461e36cf8d4 Duration: 574.82 ms Billed Duration: 575 ms Memory Size: 128 MB Max Memory Used: 30 MB
2024-06-25T09:35:33.480-04:00 START RequestId: f57f758b-9f7e-49f8-b71f-5c07a3f73b06 Version: $LATEST
2024-06-25T09:35:33.480-04:00 2024/06/25 13:35:33 Body: "price_1PLevaGVt95r9kfaeabGF9bn"
2024-06-25T09:35:33.969-04:00 END RequestId: f57f758b-9f7e-49f8-b71f-5c07a3f73b06
2024-06-25T09:35:33.969-04:00 REPORT RequestId: f57f758b-9f7e-49f8-b71f-5c07a3f73b06 Duration: 489.33 ms Billed Duration: 490 ms Memory Size: 128 MB Max Memory Used: 30 MB
Full code:
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")
log.Printf("Body: %v", request.Body)
params := &stripe.CheckoutSessionParams{
UIMode: stripe.String("embedded"),
ReturnURL: stripe.String(domain + "/demigod_pdf_purchase?session_id={CHECKOUT_SESSION_ID}"),
LineItems: []*stripe.CheckoutSessionLineItemParams{
{
Price: stripe.String((request.Body)),
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)
}
No matter which price_id I pass, my embedded checkout session returns the same product and I am unsure why.
Can you say more about this? What do you observe?
Yep - gimme just a minute.
Waiting for the code to rebuild
[ERROR] Request error from Stripe (status 400):
{
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"status": 400,
"message": "No such price: '\\\"price_1MwGfXGVt95r9kfacC10ZCX1\\\"'",
"param": "line_items[0][price]",
"request_id": "req_1HNW5NBkg9wrPM",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_1HNW5NBkg9wrPM?t=1719323404",
"type": "invalid_request_error"
}
For example, in your most recent three test session requests:
https://dashboard.stripe.com/test/logs/req_5QC4vdttDDWmqU
https://dashboard.stripe.com/test/logs/req_RobylB9qPAWdRz
https://dashboard.stripe.com/test/logs/req_4w8a6ABRYyQqVO
You send the same price: price_1MwGfXGVt95r9kfacC10ZCX1
This is a malformed request/string. You sent:
price: "\"price_1MwGfXGVt95r9kfacC10ZCX1\"",