dev-master
9999999-devMigrate your stripe subscription to new account, this is only on clone
MIT
The Requires
by Loduis Madariaga
Wallogit.com
2017 © Pedro Peláez
Migrate your stripe subscription to new account, this is only on clone
Note: This source only work for one subscription, for customer, (*1)
This is an simple tool for migrate stripe subscription, for run this process you need:, (*2)
Migrate the subscription the one customer, (*3)
use Stripe\Tools\Migrate\Subscription as Migrate;
require './vendor/autoload.php';
$migrate = new Migrate(
'stripe from account api key',
'stripe to account api key'
//, true // force to live
);
$callback = function ($err, $to, $from, $customer) {
if ($err) {
throw $err;
}
echo 'Customer: -> ', $customer, PHP_EOL;
echo 'Old subscription: -> ', $from, PHP_EOL;
echo 'New subscription: -> ', $to, PHP_EOL;
// in this callback youn can update you database ids
// if the callback return false the old subscription is not cancelled
// you can no return any o return true for cancel subscription
};
if ($migrate->run('stripe customer id', $callback) === false) {
echo 'It was not possible to find an active subscription in',
' the old account or he already has a subscription in the new account';
}
Migrate the subscription the all customers, (*4)
use Stripe\Tools\Migrate;
require './vendor/autoload.php';
$migrate = new Migrate(
'stripe from account api key',
'stripe to account api key'
);
$migrate->run(function ($err, $to, $from, $customer) {
if ($err) {
throw $err;
}
echo 'Customer: -> ', $customer, PHP_EOL;
echo 'Old subscription: -> ', $from, PHP_EOL;
echo 'New subscription: -> ', $to, PHP_EOL; // you need store in database
echo '---------------------------------', PHP_EOL;
})
Migrate your stripe subscription to new account, this is only on clone
MIT