【发布时间】:2015-08-22 20:05:49
【问题描述】:
我正在尝试设置 Stripe 结帐支付系统,但遇到了 PHP 问题。当我运行控制台日志时,一切都会执行,除了实际将费用发布到我的 Stripe 仪表板的那部分,这至关重要。下面我强调了一些可能导致我的谎言出错的地方。如果您需要更多信息,请告诉我,因为我很乐意提供帮助。
注意:“//充值卡下面的行是我认为问题所在,但我可能弄错了。
`
require_once('Stripe.php');
$stripe = array(
**'secret_key' => 'secret key',**
'publishable_key' => 'publishable key'
);
**\Stripe\Stripe::setApiKey($stripe['secret key']);**
if($_POST) {
$error = NULL;
try{
if (isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
//charge the card
**$charge = \Stripe\Charge::create(array(**
'card' => $_POST['stripeToken'],
'amount' => 2000,
'currency' => 'usd'
));
}
catch(Exception $e) {
$error = $e->getMessage();
}
$quotes= array(
"A",
"B",
"C"
);
echo "<h1>Here is your quote!</h1>";
echo "<h2>" . $quotes[array_rand($quotes)]. "</h2>";
} else{
//show the welcome screen
?>
<form action="index.php" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="publishable key"
data-amount="2000"
data-name="BB Traders"
data-description="Wiping Rags Order"
data-image="/128x128.png">
</script>
</form>
`
【问题讨论】:
-
**\Stripe\Stripe::setApiKey($stripe['secret key'])中缺少下划线。
标签: php payment stripe-payments