Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('vendor/autoload.php');
- \Stripe\Stripe::setApiKey('sk_test_');
- $customer = \Stripe\Customer::create([
- 'description' => 'My First Test Customer (created for API docs)',
- ]);
- $paymentMethod = \Stripe\ PaymentMethod::create([
- 'type' => 'card',
- 'card' => [
- 'number' => '4000002500003155',
- 'exp_month' => '02',
- 'exp_year' => 2020 ,
- 'cvc' => 222,
- ],
- ]);
- $paymentMethod->attach([
- 'customer' => $customer->id,
- ]);
- \Stripe\ Customer::update(
- $customer->id,
- [
- "invoice_settings" => [
- "default_payment_method" => $paymentMethod['id']
- ]
- ]
- );
- $setupIntent = \Stripe\ SetupIntent::create([
- 'payment_method_types' => ['card'],
- 'customer' => $customer->id,
- 'payment_method' => $paymentMethod['id'],
- 'confirm' => true
- ]);
- $subscription = \Stripe\Subscription::create([
- "customer" => $customer->id,
- "items" => [
- [
- "plan" => 'plan_',
- ],
- ],
- "expand" => ['latest_invoice.payment_intent']
- ]);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement