Advertisement
Guest User

Untitled

a guest
Apr 11th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php
  2. /* Displays user information and some useful messages */
  3. session_start();
  4.  
  5. // Check if user is logged in using the session variable
  6. if ( $_SESSION['logged_in'] != 1 ) {
  7.   $_SESSION['message'] = "Du mÃ¥ logge inn for Ã¥ ha tilgang til dashboardet!";
  8.   header("location: error.php");
  9. }
  10. else {
  11.     // Makes it easier to read
  12.     $first_name = $_SESSION['first_name'];
  13.     $last_name = $_SESSION['last_name'];
  14.     $email = $_SESSION['email'];
  15.     $active = $_SESSION['active'];
  16.     $id = $_SESSION['id'];
  17. }
  18.  
  19.     require_once('vendor/autoload.php');
  20.  
  21.     // Set your secret key: remember to change this to your live secret key in production
  22.     // See your keys here: https://dashboard.stripe.com/account/apikeys
  23.     \Stripe\Stripe::setApiKey("sk_test_XG9SCznKQqToCA64crpRJ7dv");
  24.  
  25.     $token = $_POST['stripeToken'];
  26.  
  27.     $customer = \Stripe\Customer::create([
  28.         'email' => $email,
  29.         'source' => $token,
  30.     ]);
  31.  
  32.     $subscription = \Stripe\Subscription::create([
  33.         'customer' => $customer,
  34.         'items' => [['plan' => 'plan_CenGR6XkrJeIDp']],
  35.     ]);
  36.  
  37.  
  38.         $customer1 = json_decode($customer);
  39.  
  40.         $customer_ident = $customer->profile;
  41.  
  42.  
  43.         $todaydate = date("Y.m.d");
  44.         $enddate = date('Y-m-d', strtotime("+30 days"));
  45.         $servername = "localhost";
  46.         $username = "root";
  47.         $password = "Kolsrud2002";
  48.         $dbname = "netvpn";
  49.  
  50.         // Create connection
  51.         $conn = new mysqli($servername, $username, $password, $dbname);
  52.         // Check connection
  53.         if ($conn->connect_error) {
  54.             die("Connection failed: " . $conn->connect_error);
  55.         }
  56.         $sql = "UPDATE users SET    customer_id = '$customer_ident', subscription_start = '$todaydate', subscription_end = '$enddate' WHERE id =$id";
  57.         if ($conn->query($sql) === TRUE) {
  58.     echo "Succesfull";
  59. } else {
  60.     echo "Error updating record: " . $conn->error;
  61. }
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement