0
SOLUTION:卷曲PHP5没有安装确保启用错误在PHP条纹PHP结帐错误
指南我跟着:https://stripe.com/docs/checkout/guides/php
的路径条纹PHP库:在/ var/WWW /条-php/LIB/Stripe.php或/stripe-php/lib/Stripe.php
错误消息:致命错误:类 'Stripe_Customer' 在/var/www/charge.php没有发现在第9行
in dex.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-amount="2000" data-billing-address data-description="Test"></script>
</form>
config.php中:(键只是测试由条纹提供的)
<?php
require_once('stripe-php/lib/Stripe.php');
$stripe = array(
"secret_key" => "sk_test_************************",
"publishable_key" => "pk_test_************************"
);
Stripe::setApiKey($stripe['secret_key']);
?>
charge.php:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
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' => 2000,
'currency' => 'usd'
));
echo '<h1>Successfully charged $20.00!</h1>';
?>
在配置你'require_once( '条纹PHP/lib目录/条纹/ Stripe.php');'但是你说的路径是'/条-php/LIB/Stripe.php'。这对我来说似乎不一致。 –
你可以在'config.php'中做'echo'test';'以确保它被成功地包含在'charge.php'中吗?另外,为什么'dirname(__ FILE __)'而不是'__DIR__'? – Sam
我只是隐藏了测试密钥。尽管如此,有些人仍然可以看到修改,所以我强烈建议你在Stripe上改变它们。即使他们只是测试键,您也不会喜欢某人通过发布费用来倾斜您的所有测试。 – Sam