Hey,
Are there any plans to be able to import a product catalog from in my case the legacy sandbox, or even from a ?
We have a few hundred products in our test environment (legacy sandbox) and I don’t want to have to recreate them all to be able to mirror the legacy sandbox. The big use case for us here is to be able to create a new sandbox for a feature environment and mirror the legacy sandbox as close as we can to avoid having to do a lot of setup each time.
Thanks
5 Likes
Hi there! Thanks for this feedback and feature request. I can definitely understand wanting an easy way to copy over products you have already made. Today, we do copy some settings from your live account to a sandbox at the time of sandbox creation, but this does not include products. We don’t have any immediate plans to allow this, but I am documenting this as a potential future capability to build!
It sounds like you’re interested in copying product data from another test environment rather than your live account though - is that correct? Would you have a preference of one environment over the other?
The Product ID would likely be different when it is copied over. Does that present any challenges for you?
Thank you for the reply!
Yeah, the old test environment (which is now legacy) had all of our products setup for our QA and technical teams to be able to test all of our payment flows in-app, but with the new Sandboxes, we haven’t been able to setup new feature environments for more isolated testing due to having to setup all the products again.
Does this indicate we cannot have the same product IDs across different sandboxes? It would be a problem for us in this case.
I’m working on a potential solution from our end, but a way to just import from sandbox to sandbox would have been ideal for us
This feature would be more then needed to us as well, now I have to create all of our products with all of their configs one by one in each sandbox.
Regarding the product catalog and the information about it. I have made a python script that basically moves from a sandbox to another the informations about products and prices. Basically I am iterating through the products and one by one I send to my destination sandbox. For debug purposes I store in my metadata the source_destination sandbox id. Now for the other entities the process is quite challenging depending on you requirements.
Here is a sample:
`` for p in stripe.Product.auto_paging_iter(api_key=source_key):
new_product = stripe.Product.create(api_key=dest_key,
name=p[‘name’],
description=p.get(‘description’),
active=p[‘active’],
metadata=p.get(‘metadata’, {}),
tax_code=p.tax_code,
idempotency_key=p[‘id’]
)
stripe.Product.modify(new_product.id,
api_key=sandbox_key,
idempotency_key=new_product.id,
metadata={‘source_id’: p[‘id’]}
)
prices = stripe.Price.list(api_key=live_key, product=p[‘id’], expand=[‘data.tiers’])
for price in prices.auto_paging_iter():
tiers = price.get(‘tiers’, )
tiered_pricing =
for tier in tiers:
tiered_pricing.append({
‘up_to’: ‘inf’ if tier.get(‘up_to’) is None else tier.get(‘up_to’),
‘unit_amount’: tier[‘unit_amount’],
‘flat_amount’: tier[‘flat_amount’]
})
new_price = stripe.Price.create(api_key=sandbox_key,
product=new_product[‘id’],
unit_amount=price[‘unit_amount’],
currency=price[‘currency’],
recurring=price.get(‘recurring’, {}),
metadata=price.get(‘metadata’, {}),
idempotency_key=price[‘id’],
billing_scheme=price[‘billing_scheme’],
tiers_mode=price[‘tiers_mode’],
tax_behavior=price[‘tax_behavior’],
tiers=tiered_pricing if tiers else None
)
stripe.Price.modify(new_price.id,
api_key=sandbox_key,
metadata={‘source_id’: price[‘id’]},
idempotency_key=new_price[‘id’]
)`
1 Like
+1 to add an option to copy products from account to sandbox. In our case there is no need for them to share the same IDs. Even better for us would be to have an option to duplicate sandboxes (in case it copies over tax settings, products and prices).
1 Like