Kruler

Untitled

Feb 25th, 2021 (edited)
506
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $stripe = new \Stripe\StripeClient(
  3.   'sk_test_DpcPTGfuEFtNY1GtHkXvnRWB00SWhmPpOA' //TEST KEY
  4. );
  5.  
  6.  
  7. //TODO сохранять айди продукта. и использовать его если он уже есть
  8. $product = $stripe->products->create([
  9.   'name' => "Articles products ",
  10. ]);
  11.  
  12.  
  13. //прайс для каждой оплаты разный
  14. $price = $stripe->prices->create([
  15.     'unit_amount' => 2000, //
  16.     'currency' => 'USD',
  17.     'recurring' => ['interval' => 'month'],
  18.     'product' => $product->id,
  19. ]);
  20.  
  21. //кастомера можно тоже сохранять для юзера и использовать его айди
  22. $customer = $stripe->customers->create([
  23.     'email'=>"test@test.com",
  24.     'name'=>'Jenny Rosen',
  25.     "invoice_settings" => [
  26.         "default_payment_method" => "ТУТ ПАЙМЕНТ МЕТОД ИЗ ЖСА"
  27.     ]
  28. ]);
  29.  
  30.  
  31.  
  32. $subscription = $stripe->subscriptions->create([
  33.   'customer' => $customer->id,
  34.   'items' => [
  35.     ['price' => 'price_id'],
  36.   ],
  37. ]);
  38.  
  39. //TODO проверяем атквирована ли подписка.
  40.  
  41.  
  42.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×