#_lionelp
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
actually you can create a script that lists the products https://stripe.com/docs/api/products/list and delete https://stripe.com/docs/api/products/delete
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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 have already attempted to do that
<?php
use Stripe\Price;
use Stripe\Product;
use Stripe\Stripe;
require 'vendor/autoload.php';
Stripe::setApiKey('sk_test_51NaKkgFvrVE1j92W7tmYjyeST9s7WwY2NR3bwXonPNHfqNksdrghv2AVPRgtDMi6gvjnx47skNusDhBpNgrWBpfE00PfWS3M2H');
$prices = Price::all(['limit' => 100]);
$realProductIds = [];
foreach ($prices->data as $price)
{
if (in_array($price->id, ['price_1NdVHtFvrVE1j92WkfIIP7BA', 'price_1NfN8AFvrVE1j92WvqIJbuCP'], true))
$realProductIds[] = $price->product;
}
$products = Product::all(['limit' => 100]);
foreach ($products->data as $product)
{
if (!in_array($product->id, $realProductIds, true)) {
$associatedPrices = Price::all(['product' => $product->id]);
foreach ($associatedPrices->data as $price)
Price::retrieve($price->id)->delete();
Product::retrieve($product->id)->delete();
}
}
what's the issue then?
Uncaught Error: Call to undefined method Stripe\Price::delete()
and even....we should be able to do this easily from the interface, not having to write code for this
unfortunately that's not something we have right now, and in all cases, if there were (which I'm 99% sure there isn't) this won't be the right channel to help you with that, we have so little info about dashboard features
we mostly help people with their integration questions here
how can I fix the code then?
It is maybe not directly tied to integration but I am trying to integrate Stripe and this slows my test workflow
yes sure I can help you with that
just give me a second to read through your code
just a quick question, which events are you triggering exactly?
generally all those related to a new subscription and remove subscription so customer.created, customer.subscription.created, customer.subscription.deleted I would say ๐ค
once a price is already used in a subscription/invoice/checkout etc. you can't really delete it
a better solution here is to create your own fixtures
and use "predefined" prices
Ok, so I have to create my two offers. Reset the test environment on the UI. Generate the new prices via my code... ๐ค
Reset the test environment on the UI
I'm not really sure whether this is possible or not
actually you can https://stripe.com/docs/test-mode#delete-test-data
I thought to that thing
yes you're right
yes
same to you. let me know if you need any more help