解决方案:没有安装CURL-PHP5以确保PHP中的错误
我遵循的指南:https://stripe.com/docs/checkout/guides/php
Stripe PHP库的路径:/var/www/stripe-php/lib/Stripe.php或/stripe-php/lib/Stripe.php
错误消息:致命错误:Class' Stripe_Customer'在第9行的/var/www/charge.php中找不到
的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-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' => 'customer@example.com',
'card' => $token
));
$charge = Stripe_Charge::create(array(
'customer' => $customer->id,
'amount' => 2000,
'currency' => 'usd'
));
echo '<h1>Successfully charged $20.00!</h1>';
?>
答案 0 :(得分:0)
<?php
require_once('vendor/autoload.php');
$stripe = array(
"secret_key" => "sk_test_duZNCP2a1Hf2KL2BX5ShdD8N",
"publishable_key" => "pk_test_plGLUfjyTapopWA0ZQY8UdSt"
);
\Stripe\Stripe::setApiKey($stripe['secret_key']);
?>
require_once()行假设您已经通过Composer安装了Stripe PHP库。
无法输入打开的文件:composer.phar