Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. $pid = 'movies';
  2. $returnpage = 'http://localhost:3000/';
  3. $failedpage = 'http://localhost:3000/';
  4.  
  5. \Stripe\Stripe::setApiKey($stripesecretkey);
  6. \Stripe\Stripe::setApiVersion("2019-05-16");
  7.  
  8. if ((is_numeric($trialdays)) && ($trialdays>0))
  9.   $trial_period_days = $trialdays;
  10. if ($paidfordays>0)
  11.   $trial_period_days = $paidfordays;
  12.  
  13. $session_params = [
  14.   'client_reference_id' => json_encode($passthru),
  15.   'payment_method_types' => ['card'],
  16.   'subscription_data' => [
  17.     'items' => [[
  18.       'plan' => $pid,
  19.       'trial_period_days' => $trial_period_days
  20.     ]]
  21.   ],
  22.   'line_items' => [[
  23.     'name' => 'Setup fee',
  24.     'amount' => 995,
  25.     'currency' => 'USD',
  26.     'quantity' => 1,
  27.   ]],
  28.   'success_url' => $returnpage,
  29.   'cancel_url' => $failedpage,
  30. ];
  31.  
  32. if (($stripeidsubscr=="") && ($customer_email!=""))
  33.   $session_params['customer_email'] = $customer_email;
  34. if ($stripeidsubscr!="")
  35.   $session_params['customer'] = $stripeidsubscr;
  36. if ($settings['billingaddress']==1)
  37.   $session_params['billing_address_collection'] = "required";
  38.  
  39. $session = \Stripe\Checkout\Session::create($session_params);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement