Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// ok so i want to charge the customer $100 for the first month and then $25 monthly
// ok so i create a customer - this all works as expected
$customer = \Stripe\Customer::create([
'source' => $source,
'email' => $email,
]);
// then we will charge the trialprice, this also works as expected
$charge = \Stripe\Charge::create ([
'customer' => $customer,
'amount' => $amount,
'currency' => $currency,
'metadata' => $metadata,
]);
// now i make a plan, this appears correct in the stripe panel
$plan = \Stripe\Plan::create([
'id' => uniqid('plan-'),
'name' => $planName,
'amount' => $amount,
'interval' => $interval,
'currency' => $currency,
'trial_period_days' => $trialDays,
]);
// and now i make a subscription
$subscriptionProcessed = \Stripe\Subscription::create([
'customer' => $customer,
'plan' => $plan,
'metadata' => $metadata,
]);
// everything works as expected, the right customer gets the right plan and subscription
// except for
// the subscription is immediately charged, i see it in the panel and in my bank account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment