#IndyColor-deprecated-parameters
1 messages · Page 1 of 1 (latest)
Hi there!
What's the question?
Moving your response into this thread: I have a user who is getting this message: "2022-08-15 00:13:10 Invalid parameters were supplied to Stripe API 2022-08-15 00:13:10 -- Stripe message is: You cannot use line_items.amount, line_items.currency, line_items.name, line_items.description, or line_items.images in this API version. Please use line_items.price or line_items.price_data. Please see https://stripe.com/docs/payments/checkout/migrating-prices for more information." He checked with Stripe support who said the API I'm using is deprecated. But I have like 5K users and only one user with this complaint. So do I need to go in and recode my whole interface?
So we did just release a new API version: https://stripe.com/docs/upgrades#2022-08-01
Which did deprecate those parameters
However, if you want to force a certain version you can use https://stripe.com/docs/api/versioning
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So you can add that to your code to ensure new accounts still use the API version that you created your integration for
It was on the left in my interface... thanks.
So here's what the Stripe support person said to him: "As discussed, the highlighted errors that you're seeing on the logs section of your dashboard was because of the deprecated parameters which shouldn't be added during the integration."
Right, because the new account uses the default API version on their account and new accounts will onboard with the latest API version.
I assume you have a plugin?
Yes, Seamless Donations in WordPress.
Gotcha, so I'd either update your code to align with the API version, or update your code to force API version for your users by versioning as I referenced above.
How hard is it to force the API version? And how do I tell which API version to force? I'm doing this as volunteer, and I'm completely out of available time, so this is a trade sleep for free work kind of deal.
It requires one line of code
So it is easy
And you likely want to force the 2020-08-27 version if everything was working before the newest version was released.
Thanks, but it's not so easy because I initiate stripe setting and API key and then doing this:
$session = \Stripe\Checkout\Session::create($donation);
So where does new Stripe Client go?
$stripe = new \Stripe\StripeClient([
"api_key" => "sk_test_4eC39HqLyjWDarjtT1zdp7dc",
"stripe_version" => "2022-08-01"
]);
Yep you would do $stripe = new \Stripe\StripeClient([ "api_key" => "sk_test_123", "stripe_version" => "2020-08-27" ]);
That will force the 2020-08-27 for all API requests using that Stripe initialization
So does that go before or after the \Stripe\Stripe::setApiKey($api_key); and before or after the \Stripe\Checkout call?
And where do I pass the $stripe to?
This is my main code block:
`\Stripe\Stripe::setApiKey($api_key);
...
if ($post_data['REPEATING'] != '') {
// this is a recurring donation
$donation = [
...
];
} else {
$donation = [
...
];
}
try {
// Use Stripe's library to make requests
$session = \Stripe\Checkout\Session::create($donation);
} catch (\Stripe\Exception\CardException $e) {`
You can add it to your $api_key variable
So that variable should currently look like "api_key" => "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
Now it should be "api_key" => "sk_test_4eC39HqLyjWDarjtT1zdp7dc", "stripe_version" => "2020-08-27"
And that would go to setApiKey or to the new StripeClient call?
Right now, $api_key is a scalar string. Should I turn it into an array and pass it to setApiKey?
Yes I believe so. Double checking because you are actually using our legacy StripeClient class (which is still supported though we recommend our new class)
Frustrating, because I wrote that just last year and now there's a new class requiring a new rewrite. But thanks for double checking.
That update happened long before last year
Hmm... that was the code I was pointed to for doing the Stripe implementation. Ah well, it's not the years or the miles, it's the lines of code.
Anyway, right now, I just need to make this work so 5,000 nonprofits don't freak out on me.
Okay actually you don't set it with the API key. You set it like \Stripe\Stripe::setApiVersion('2020-08-27');
That will set it globally
Cool. Before or after the setApiKey line, or does it not matter as long as it's before the checkout call?
Shouldn't matter as long as before Checkout request
Cool. Thanks for your help and for being so patient. Have a great rest-of-day. On on it!
Test it out and let me know if you run into any further issues!