gpt4 book ai didi

php - Stripe 类 ' Stripe\充电

转载 作者:行者123 更新时间:2023-12-01 09:51:13 26 4
gpt4 key购买 nike

我想实现一个 Stripe 支付表单,但我收到一个 fatal error Class 'Stripe\Charge.类(class)在那里(见我的文件夹树),我试过了:

$charge =  \Stripe\Charge::create(array(

$charge = \Charge::create(array(

但两者都不起作用。我的 PHP 代码:

require_once('Stripe/lib/Stripe.php');
\Stripe\Stripe::setApiKey("my_key"); //Replace with your Secret Key

$charge = \Stripe\Charge::create(array(
"amount" => 1500,
"currency" => "usd",
"card" => $_POST['stripeToken'],
"description" => "Charge for Facebook Login code."
));

enter image description here

最佳答案

您使用的是旧版 (1.x) 的 Stripe PHP 库。在那个版本中,所有类都被命名为 Stripe_Class

版本 2.0.0 ,语法更改为使用命名空间,现在所有类都命名为 \Stripe\Class

如果可能,我建议您升级到最新版本 (3.13.0)。您可以在这里找到它:https://github.com/stripe/stripe-php/releases . Stripe 文档和 API 引用中的所有示例都使用更新的语法。

关于php - Stripe 类 ' Stripe\充电,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37321134/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com