【发布时间】:2017-02-17 22:55:16
【问题描述】:
我在将 Stripe 集成到我的网站时遇到了麻烦,因为似乎每次我解决一个问题都会出现不同的问题。
我决定使用本地 Stripe 文件夹库而不是安装它。
我的购买页面如下所示:
<body>
<?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-description="Access for a year"
data-amount="5000"
data-locale="auto"></script>
</form>
</body>
我的charge.php 看起来像这样:
<?php
require_once('./config.php');
$token = $_POST['stripeToken'];
$customer = \Stripe\Customer::create(array(
'email' => 'customer@example.com',
'source' => $token
));
$charge = \Stripe\Charge::create(array(
'customer' => $customer->id,
'amount' => 5000,
'currency' => 'usd'
));
echo '<h1>Successfully charged $50.00!</h1>';
?>
最后,我的 config.php:(星星取代了我的钥匙)
<?php
require_once('./Stripe/init.php');
$stripe = array(
"secret_key" => "sk_test_***********************",
"publishable_key" => "pk_test_***********************"
);
\Stripe\Stripe::setApiKey($stripe['secret_key']);
我的 Stripe 库文件夹与我的其他页面处于同一级别,这可能是我的问题,为了展示这一点,我将制作一个分级的项目符号列表:
- config.php
- index.php
- charge.php
- 条纹(文件夹)
- 文件夹中的内容
我做错了什么?我已将文件夹上传到我的 Webhost 服务器,当我转到应该有按钮的页面时,我收到一个错误:
警告: 要求(/home1/desmoriz/public_html/Stripe/lib/AttachedObject.php): 无法打开流:中没有这样的文件或目录 /home1/desmoriz/public_html/Stripe/init.php 在第 32 行
致命错误:require():需要打开失败 '/home1/desmoriz/public_html/Stripe/lib/AttachedObject.php' (include_path='.:/opt/php56/lib/php') 在 /home1/desmoriz/public_html/Stripe/init.php 在第 32 行
【问题讨论】:
标签: php stripe-payments