<?php session_start(); ob_start(); if (!isset($_SESSION["user_id"])) { header("Location:/login/"); } require_once "../../inc/config.php"; require_once ROOT_PATH . "inc/database.php"; $mem_levels = array("Individual", "Family", "Steward", "Business Basic", "Business Premium"); $mem_icons = array("fa-user", "fa-users", "fa-user-plus", "fa-briefcase", "fa-briefcase"); $mem_level = $_SESSION["member_level"]; if ($_SERVER["REQUEST_METHOD"] == "POST") { $level = (int) $_POST["level"]; $subscription_id = getSubscriptionId($_SESSION["user_id"]); $cust_id = getStripeCustomerId($_SESSION["user_id"]); $cust = \Stripe\Customer::retrieve($cust_id); $subscription = $cust->subscriptions->retrieve($subscription_id); $subscription->plan = $level; $subscription->save(); $_SESSION["member_level"] = $level; enrollUser($_SESSION["user_id"], $level); $_SESSION["change_mem_level"] = true; header("Location:/user/membership/"); } else { ?> <html> <?php include ROOT_PATH . "inc/head.php"; ?> <body>
// Uses sessions, you could use a cookie instead. if (empty($errors)) { # create the charge on Stripe's servers - this will charge the user's card try { #print "<br>funding_for:$funding_for<br>"; #print "<br>trailforcent:$trailforcent<br>"; // Include the Stripe library: #require_once('lib/Stripe.php'); // set your secret key: remember to change this to your live secret key in production // see your keys here https://manage.stripe.com/account Stripe::setApiKey(STRIPE_PRIVATE_KEY); $charge = array(); if (CHARGE_LATER) { # We will charge the customer later so we will create the customer at first and will charge the customer later. # We will check whether there are any customer already available in database or not. $customerId = getStripeCustomerId($_SESSION['FBID']); error_log("Got Customer ID [" . $customerId . "]"); if ($customerId == "") { # Create a Customer if the customer is already not in database. $customer = Stripe_Customer::create(array("card" => $token, "description" => $_SESSION['FBID'])); // Save the customer ID in your database so you can use it later saveStripeCustomerId($_SESSION['FBID'], $customer->id); error_log("Saving Customer [" . $_SESSION['FBID'] . "] [" . $customer->id . "]"); $customerId = $customer->id; } if ($customerId != "") { // Save the Transaction details in your database so you can use it later ## The default card is the 1st card list($fullName, $email) = getFullName($_SESSION['FBID']); $sid = $_SESSION['FBID']; #autoSubscribe($email);
<div class="field"> <input id="account_password" type="password" name="account_password"> </div> </div> </fieldset> <div class="input-group submit"> <div class="field"> <button id="pay_button" type="submit" class="pay_button button">Submit Payment</button> <input type="hidden" name="action" value="new-card"> </div> </div> </form> <?php } else { $stripe_cust_id = getStripeCustomerId($user["user_id"]); $customer = \Stripe\Customer::retrieve($stripe_cust_id); $brand = str_replace(' ', '', $customer->sources->data[0]->brand); $last4 = $customer->sources->data[0]->last4; ?> <form action="/user/events/<?php echo $event["event_id"]; ?> /" method="post"> <fieldset> <h3>Payment information on file:</h3> <div class="field cc-on-file"> <p><span class="<?php echo $brand; ?> "></span> with last 4 digits: <span class="last4"><?php
} else { if ($action == 'force_disburse') { $action = 'capture'; $force_disburse = 1; } } } } ## Here we are going to do all that stuff!!! $result = mysql_query("select funding_details_id, account_funder_id, fund_amount from funding_details where element_id='{$eID}' AND account_id = '{$aID}' AND funding_details_status = '1' ") or die("mysql error @ 72"); while ($row = mysql_fetch_row($result)) { $funding_details_id = $row[0]; $funder_id = $row[1]; $fund_amount = $row[2]; $funder_sid = getFunderSocialID($funder_id); $customer_id = getStripeCustomerId($funder_sid); $card_token = getStripeTransactionToken($funding_details_id); $stripeConnectToken = getStripeConnectToken($aID); $applicable_fee = $fund_amount * $application_fee / 100; $stripeUserobj = json_decode($stripeConnectToken); $stripeUserAccessToken = $stripeUserobj->{'access_token'}; $errors = array(); ## Find alreaddy disursed or not if (alreadyDisbursed($funding_details_id)) { if ($DEBUG) { print "Already funded! Morphed Call!"; } error_log("Already funded! Morphed Call!"); continue; } if ($DEBUG) {