<?php

require_once __DIR__ . '/../php/insert_data.php';
require_once 'common.php';
session_start();
$var_value = $_POST['amount'];
$custom_message = $_POST['custom_mess'];
if (isset($_POST['stripeToken'])) {
    $token = $_POST['stripeToken'];
    try {
        Stripe::setApiKey("sk_test_BvefXDnddo5SyQMM2XgNTMhV");
        Stripe_Charge::create(["amount" => $var_value, "currency" => "PKR", "source" => "{$token}", "description" => $custom_message]);
        $insert = new InsertData();
        $sch_rec = $insert->after_payment("delta", $_SESSION['don_id']);
        echo json_encode($sch_rec);
        echo $_SESSION['don_id'];
    } catch (Stripe_CardError $e) {
        // error
    }
}
?>


<html>
<head>
    <title> Check out </title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="css/master-ui.css">

</head>