[英]Stripe PHP Checkout Error
解決方案:請確保未安裝CURL-PHP5以啟用PHP中的錯誤
我遵循的指南: https : //stripe.com/docs/checkout/guides/php
Stripe PHP庫的路徑:/var/www/stripe-php/lib/Stripe.php或/stripe-php/lib/Stripe.php
錯誤消息:致命錯誤:在第9行的/var/www/charge.php中找不到類'Stripe_Customer'
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 :(這些鍵只是stripe提供的測試鍵)
<?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>';
?>
<?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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.