继"Using Checkout and PHP"一行之后,除了最后一部分,我的一切都工作了。
我的代码是这样的
<?php
require_once('config.php');
$token = $_POST['stripeToken'];
$customer = 'Stripe'Customer::create(array(
'email' => 'customer@example.com',
'source' => $token
));
echo '<h1>Successfully charged $50.00!</h1>';
?>
一切都很好,我可以在令牌上做一个var_dump,看到工作正常,我的问题是客户数组。我已经尝试使用Stripe_Customer而不是'Stripe'Customer,但它仍然不起作用。
我可能要注意的几件事是我手动下载了文件,我使用的是mamp,但我不认为这是问题所在,因为我能够接收令牌,它只是在我添加客户数组时停止工作。
这是我的config.php文件
<?php
require_once('../stripe/init.php');
$stripe = array(
"secret_key" => "test",
"publishable_key" => test"
);
'Stripe'Stripe::setApiKey($stripe['secret_key']);
?>
发现了,这是TLS更新问题。更新MAMP后一切正常