php - 条纹 - PHP fatal error : Class 'Stripe\Charge' not found

标签 php class

我一直在关注 Stripe 文档,但我无法创建“费用”。

收费.php

require('/var/www/stripe-php-2.1.1/lib/Stripe.php');
\Stripe\Stripe::setApiKey("KEY_HERE");

\Stripe\Charge::create(array(
  "amount" => 400,
  "currency" => "usd",
  "source" => "TOKEN_HERE", // obtained with Stripe.js
  "description" => "Charge for test@example.com"
));
?>

我能够处理第一个命令“\Stripe\Stripe::setApiKey("KEY_HERE");"但是在处理下一个时收到错误并收到以下错误: “在/var/www/charge.php 中找不到类‘Stripe\Charge’”

最佳答案

这里是这个问题的更新答案。

来自 Stripe 的 Dana:

If you prefer not to use Composer, our latest PHP bindings (>=2.x) include a init.php file that you can add to your project. Download and unzip the folder whereever you'd like, then include this init.php at the top of your scripts you use to communicate with the Stripe API, changing the path to the location of this file. Just like this: require_once('/path/to/stripe-php/init.php')

这对我有用。

关于php - 条纹 - PHP fatal error : Class 'Stripe\Charge' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28846062/

相关文章:

php - 如何从 WP 标题中删除 HOME 链接?

php - 为什么在构造函数的站点外的类中声明变量?

python - 什么时候在 Python 中初始化类变量?

php - sql查询中变量的任何值避免被零除错误

php - 从html表生成excel文件后出现奇怪的符号

excel - VBA 子类引用

c++ - 在 C++ 的另一个 .h 文件中使用类中的方法

java - 要创建哪些类方法?

php - Laravel Controller 功能全局应用

PHP/MySQL : UPDATE Statement containing carriage returns or new lines