#DouCrazy
1 messages · Page 1 of 1 (latest)
hello, you can update the Price via the API : https://stripe.com/docs/api/prices/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i had try it
params := &stripe.PriceParams{ UnitAmount: stripe.Int64(2000), Currency: stripe.String("usd"), }
it always report error to me:
{"code":"parameter_unknown","doc_url":"https://stripe.com/docs/error-codes/parameter-unknown","status":400,"message":"Received unknown parameter: unit_amount","param":"unit_amount","request_id":"req_56FqTDQbeCmgti","type":"invalid_request_error"}
you can't update the amount via the API, there's a specific list of parameters you can update
but the docs have more parameters
ah sorry, my bad, i missed that
it mentions currency_options.<currency>.unit_amount
gimme a second to go through this
are you planning to present in multiple currencies to your customers?
e.g. if your customer is in US, present in USD, if your customer is in CA, present in CAD
not yet, i was use USD now
i try it just now, still got error
{"status":400,"message":"Currencies must be lowercase when used as keys in a map. Use `usd` instead of `USD`.","param":"currency_options","request_id":"req_ifwEN6THzjpTf3","request_log_url":"https://dashboard.stripe.com/test/logs/req_ifwEN6THzjpTf3?t=1683598437","type":"invalid_request_error"}
my code is
params := &stripe.PriceParams{
CurrencyOptions: map[string]*stripe.PriceCurrencyOptionsParams{
"USD": &stripe.PriceCurrencyOptionsParams{
UnitAmount: stripe.Int64(amount),
},
},
}
have you updated your code to use ``usdinstead ofUSD` as the error message mentions?
i change it and try again, still no good
{"status":400,"message":"You are specifying an update to a currency option that matches the top-level currency for this price. Please remove this currency option and update the top-level params instead.","param":"currency_options[usd]","request_id":"req_xBDwhsE4FSesew","request_log_url":"https://dashboard.stripe.com/test/logs/req_xBDwhsE4FSesew?t=1683598758","type":"invalid_request_error"}
ah, okay, it looks like that's not possible. So for context, the CurrencyOptions is meant to provide a way to present multiple currencies for a single Price. You still need to define the top level currency. The top level currency's amount cannot be updated
you're going to need to create a new Price object