【发布时间】:2015-05-02 06:03:30
【问题描述】:
到目前为止,我使用了将 lib 放在 vendor 文件夹下的 composer。 它是这样的:vendor\stripe\stripe-php\lib
从那里我有点迷失了我应该如何声明命名空间(我猜在组件下面的 config/web.php 中)。 Stripe.php 类文件中声明的命名空间是 Stripe。
我想在控制器中使用它,如 Stripe 网站上的示例所示。
```
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \StripeLib\Charge::create(array(
"amount" => 1000, // amount in cents, again
"currency" => "eur",
"source" => $token,
"description" => "payinguser@example.com")
);
} catch(\StripeLib\Error\Card $e) {
// The card has been declined
echo "The card has been declined. Please, try again.";
}
```
【问题讨论】:
-
你用的是什么框架?
-
@david s Yii2 框架
标签: php yii2 stripe-payments