Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Displays user information and some useful messages */
- session_start();
- // Check if user is logged in using the session variable
- if ( $_SESSION['logged_in'] != 1 ) {
- $_SESSION['message'] = "Du må logge inn for å ha tilgang til dashboardet!";
- header("location: error.php");
- }
- else {
- // Makes it easier to read
- $first_name = $_SESSION['first_name'];
- $last_name = $_SESSION['last_name'];
- $email = $_SESSION['email'];
- $active = $_SESSION['active'];
- $id = $_SESSION['id'];
- }
- require_once('vendor/autoload.php');
- // Set your secret key: remember to change this to your live secret key in production
- // See your keys here: https://dashboard.stripe.com/account/apikeys
- \Stripe\Stripe::setApiKey("sk_test_XG9SCznKQqToCA64crpRJ7dv");
- $token = $_POST['stripeToken'];
- $customer = \Stripe\Customer::create([
- 'email' => $email,
- 'source' => $token,
- ]);
- $subscription = \Stripe\Subscription::create([
- 'customer' => $customer,
- 'items' => [['plan' => 'plan_CenGR6XkrJeIDp']],
- ]);
- $customer1 = json_decode($customer);
- $customer_ident = $customer->profile;
- $todaydate = date("Y.m.d");
- $enddate = date('Y-m-d', strtotime("+30 days"));
- $servername = "localhost";
- $username = "root";
- $password = "Kolsrud2002";
- $dbname = "netvpn";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "UPDATE users SET customer_id = '$customer_ident', subscription_start = '$todaydate', subscription_end = '$enddate' WHERE id =$id";
- if ($conn->query($sql) === TRUE) {
- echo "Succesfull";
- } else {
- echo "Error updating record: " . $conn->error;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement