пользовательская кнопка проверки полосы не заряжается
Я пытаюсь получить пользовательскую кнопку Stripe's Checkout для снятия средств с кредитной карты, но все, что она делает, это минимизирует после ввода данных кредитной карты. Я использую код, найденный в документации, но не могу заставить его работать. Простая кнопка проста в использовании, и я подумал, что это будет так же просто, как просто настроить ее, но она совсем другая.
Вот код:
Страница оплаты
<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/checkout.js"></script>
<input type="submit" value="Pay with card" id="customButton"/>
<?php require_once('./config.php'); ?>
<script>
var handler = StripeCheckout.configure({
key: '<?php echo $stripe['publishable_key']; ?>',
image: 'favicon.png',
token: function(token, args) {
// Use the token to create the charge with a server-side script.
// You can access the token ID with `token.id`
}
});
document.getElementById('customButton').addEventListener('click', function(e) {
// Open Checkout with further options
handler.open({
name: 'Imprintnation',
description: 'Decals',
amount: <?php echo $stripeTotal; ?>
});
e.preventDefault();
});
</script>
</form>
Страница начисления (charge.php)
<?php
require_once(dirname(__FILE__) . '/config.php');
$token = $_POST['stripeToken'];
$customer = Stripe_Customer::create(array(
'email' => '[email protected]',
'card' => $token
));
$charge = Stripe_Charge::create(array(
'customer' => $customer->id,
'amount' => 5000,
'currency' => 'usd'
));
echo '<h1>Successfully charged $5!</h1>';
?>
Страница конфигурации (config.php)
<?php
require_once('./lib/Stripe.php');
$stripe = array(
secret_key => 'sk_test_************************',
publishable_key => 'pk_test_************************'
);
Stripe::setApiKey($stripe['secret_key']);
?>
Что мне здесь не хватает? Я даже не могу заставить его получить токен.
Как я могу получить токен и зарядить карту?