Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('vendor/autoload.php');
  4.  
  5. \Stripe\Stripe::setApiKey('sk_test_');
  6.  
  7. $customer = \Stripe\Customer::create([
  8.   'description' => 'My First Test Customer (created for API docs)',
  9. ]);
  10.  
  11. $paymentMethod = \Stripe\ PaymentMethod::create([
  12.     'type' => 'card',
  13.     'card' => [
  14.         'number' => '4000002500003155',
  15.         'exp_month' => '02',
  16.         'exp_year' => 2020 ,
  17.         'cvc' => 222,
  18.     ],
  19. ]);
  20.  
  21. $paymentMethod->attach([
  22.   'customer' => $customer->id,
  23. ]);
  24.  
  25. \Stripe\ Customer::update(
  26.     $customer->id,
  27.     [
  28.         "invoice_settings" => [
  29.             "default_payment_method" => $paymentMethod['id']
  30.         ]
  31.     ]
  32. );
  33.  
  34. $setupIntent = \Stripe\ SetupIntent::create([
  35.     'payment_method_types' => ['card'],
  36.     'customer' => $customer->id,
  37.     'payment_method' => $paymentMethod['id'],
  38.     'confirm' => true
  39. ]);
  40.  
  41. $subscription = \Stripe\Subscription::create([
  42.   "customer" => $customer->id,
  43.   "items" => [
  44.     [
  45.       "plan" => 'plan_',
  46.     ],
  47.    ],
  48.   "expand" => ['latest_invoice.payment_intent']
  49. ]);
  50.  
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement