I want to make a payment gateway using Stripe. Here is my code. The config file and first of all i add a stripe library in confiig file. I want a token from this. How do I make or generate a token from stripe?
<?php
require_once('./lib/Stripe.php');
$stripe = array(
secret_key => 'sk_test_SrG9Yb8SrhcDNkqsGdc5eKu1',
publishable_key => 'pk_test_8ZBVXSwrHDKuQe6dgMNfk8Wl'
);
Stripe::setApiKey($stripe['secret_key']);
?>
<?php require_once('config.php'); ?>
<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-amount="5000" data-description="One year's subscription"></script>
</form>
<?php require_once('config.php'); ?>
<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-amount="5000" data-description="One year's subscription"></script>
</form>
require_once('../lib/Stripe.php');
Stripe::setApiKey("sk_test_SrG9Yb8SrhcDNkqsGdc5eKu1");
$result = Stripe_Token::create(
array(
"card" => array(
"name" => $user['name'],
"number" => base64decrypt($user['card_number']),
"exp_month" => $user['month'],
"exp_year" => $user['year'],
"cvc" => base64decrypt($user['cvc_number'])
)
)
);
$token = $result['id'];
$charge = Stripe_Charge::create(array(
"amount" => $data_input['amount']*100,
"currency" => "usd",
"card" => $token,
"description" => "Charge for [email protected]"
));