作为标题我有一个奇怪的问题。我试图将Stripe支付网关集成到我的网站,但问题是Live Server上没有生成令牌,而在本地计算机上它工作得很好......
我的代码:
/*index.php*/
<?php
require_once('config.php');
?>
<form action="charge.php" method="post">
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="<?php echo $stripe['publishable_key']; ?>"
data-description="Access for a year"
data-amount="5000"
data-locale="auto">
</script>
</form>
/*config.php*/
<?php
require_once('stripe/init.php');
$stripe = array(
"secret_key" => "sk_test_lcnCLz5lnSWPzhMRMOhjGcXD",
"publishable_key" => "pk_test_KW35E5D3ShuLfvd60VHrRVJQ"
);
\Stripe\Stripe::setApiKey($stripe['secret_key']);
?>
/*charge.php*/
<?php
require_once('config.php');
$token = $_POST['stripeToken'];
$email = $_POST['stripeEmail'];
$customer = \Stripe\Customer::create(array(
'email' => $email,
'source' => $token
));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 5000,
'currency' => 'usd'
));
echo '<h1>Successfully charged $50.00!</h1>';
?>