#EightMegsAndConstantlySwapping
1 messages · Page 1 of 1 (latest)
hi! can you share what you have so far?
I'd imagine it's this though? https://pkg.go.dev/github.com/stripe/stripe-go#CheckoutSessionPaymentIntentDataParams
domain := globalConfig.DomainName
priceParams := &stripe.PriceParams{
Currency: stripe.String(string(stripe.CurrencyGBP)),
Product: stripe.String(globalConfig.StripeItem),
UnitAmount: stripe.Int64(int64(newCustomer.Treecount)*globalConfig.BasePrice+int64(donation)),
}
newPrice,_:=price.New(priceParams)
params := &stripe.CheckoutSessionParams{
LineItems: []*stripe.CheckoutSessionLineItemParams{
&stripe.CheckoutSessionLineItemParams{
Price: stripe.String(newPrice.ID),
Quantity: stripe.Int64(1),
},
},
PaymentMethodTypes: stripe.StringSlice([]string{
"card",
}),
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
PaymentIntentData: &stripe.PaymentIntentData{
Description: "Treecycling Payment",
},
SuccessURL: stripe.String(domain + "/stripeSuccess.html"),
CancelURL: stripe.String(domain + "/testform.html"),
}
s, err := session.New(params)
I'm missing params at the end, I've just noticed.
yeah I would try PaymentIntentData: &stripe.CheckoutSessionPaymentIntentData{....} instead
./main.go:450:23: undefined: stripe.CheckoutSessionPaymentIntentData <- That's not it, unfortunately.
import (
"fmt"
"github.com/stripe/stripe-go/v73"
"github.com/stripe/stripe-go/v73/checkout/session"
)
func main() {
stripe.Key = "sk_test_xxxx"
params := &stripe.CheckoutSessionParams{
LineItems: []*stripe.CheckoutSessionLineItemParams{
&stripe.CheckoutSessionLineItemParams{
Price: stripe.String("price_1M4PMYJoUivz182DlpHowJXd"),
Quantity: stripe.Int64(1),
},
},
PaymentMethodTypes: stripe.StringSlice([]string{
"card",
}),
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
PaymentIntentData: &stripe.CheckoutSessionPaymentIntentDataParams{
Description: stripe.String("Treecycling Payment"),
},
SuccessURL: stripe.String("https://example.com/stripeSuccess.html"),
CancelURL: stripe.String("https://example.com/testform.html"),
}
s, _ := session.New(params)
fmt.Println(s.ID);
}
this works for me.
Yup, I was missing Params. It's working now but a new problem has arisen.
Nevermind, I think I'm using an old product ID.
For some reason, I'm getting "no such product" back when I try to create a new price on one of my test items.
[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 product: 'prod_Mo2498FXIIRV6s'","param":"product","request_id":"req_4keSILHV2ult9g","type":"invalid_request_error"} 2022/11/15 14:26:42 /home/beno/Documents/treecycling/oldenv/developmentBuild/TreeSV2.0/main.go:438
Hi 👋 I'm jumping in as my teammate needed to step away. I've deleted the message where you shared a secret key, and encourage you to roll that key promptly.
The Product that you're trying to reference does not exist on the account that is trying to access it, so it is expected for that request to be failing.
Oh right, I'm using a key from an account we no longer use.
Thank you, we used to have two accounts for the company but the accounts department closed the one I had been testing with previously, that would explain the confusion, thank you!
Gotcha, happy to help!