Skip to content

Stripe account migration tools to copy products, prices, and subscriptions between accounts while maintaining billing cycles and customer relationships.

License

Notifications You must be signed in to change notification settings

Xtendify/stripe-copy

Repository files navigation

Stripe Account Migration Tools

A collection of PHP scripts to help migrate data between Stripe accounts. Currently supports copying products, prices, and subscriptions from one Stripe account to another.

Features

  • Copy products with their prices from source to target Stripe account
  • Copy active subscriptions while maintaining billing cycles
  • Match products and prices between accounts
  • Automatically cancel source subscriptions after successful migration
  • Support for both single and bulk migrations
  • Detailed error handling and logging

Prerequisites

  • PHP 7.4 or higher
  • Composer
  • Source Stripe Account API Key
  • Target Stripe Account API Key
  • Customers must be copied to target account first (see Migration Steps below)

Migration Steps

  1. First, copy your customers from source to target account using Stripe's Customers Copy feature.

  2. Then follow the installation steps below to copy products and subscriptions.

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/stripe-copy.git
cd stripe-copy
  1. Install dependencies:
composer install
  1. Create a .env file in the root directory:
SOURCE_STRIPE_KEY=sk_live_your_source_key
TARGET_STRIPE_KEY=sk_live_your_target_key

Usage

Copy Products

Copy all products and their prices:

php copy_products.php

Copy a specific product:

php copy_products.php --product=prod_xyz

Copy Subscriptions

Copy all active subscriptions:

php copy_subscriptions.php

Copy specific subscriptions (comma-separated):

php copy_subscriptions.php --subscriptions=sub_xyz,sub_abc

Important Notes

  1. The scripts will:

    • Match products by name
    • Match prices by amount, currency, and recurrence
    • Set source subscriptions to cancel at period end
    • Create new subscriptions with the same billing cycle
  2. Prerequisites for subscription copying:

    • Customers MUST be migrated first using Stripe's Data Import feature
    • Products must exist in the target account (use copy_products.php first)
    • Payment methods should be copied along with customers
  3. Error Handling:

    • The process will halt on any error
    • Detailed error messages are displayed
    • No partial migrations are left in an inconsistent state

Security

  • Never commit your .env file
  • Use test mode keys first to verify the migration
  • Review all migrations in the Stripe dashboard

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

Stripe account migration tools to copy products, prices, and subscriptions between accounts while maintaining billing cycles and customer relationships.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages