#_lionelp

1 messages ยท Page 1 of 1 (latest)

delicate furnaceBOT
rich sandal
#

๐Ÿ‘‹ 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

red dust
#

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();
  }
}
rich sandal
#

what's the issue then?

red dust
#

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

rich sandal
#

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

red dust
#

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

rich sandal
#

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?

red dust
#

generally all those related to a new subscription and remove subscription so customer.created, customer.subscription.created, customer.subscription.deleted I would say ๐Ÿค”

rich sandal
#

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

red dust
#

Ok, so I have to create my two offers. Reset the test environment on the UI. Generate the new prices via my code... ๐Ÿค”

rich sandal
#

Reset the test environment on the UI
I'm not really sure whether this is possible or not

red dust
#

I thought to that thing

rich sandal
#

yes you're right

red dust
#

ok in fact, your link mention exactly that

#

๐Ÿ˜‚

rich sandal
#

yes

red dust
#

ok, I will do that.

#

have a good day

rich sandal
#

same to you. let me know if you need any more help