首页 文章

条纹不会创建客户或收费

提问于
浏览
2

我试图通过条带实现付款,几周前它让它工作但现在似乎没有用 .

我正在使用php来实现:

payment.php

require('stripe/lib/Stripe.php');

$stripe = array(
'secret_key'      => 'sk_test_???',
'publishable_key' => 'pk_test_???'
);

Stripe::setApiKey($stripe['secret_key']);

try{
$customer = Stripe_Customer::create(array(
      'card'     => $_POST['stripeToken'],
      'email'    => $_POST['email'],
      'name'     => $_POST['name']
      ));

$charge = Stripe_Charge::create(array(
  'card'     => $_POST['stripeToken'],
  'amount'   => 2500,
  'currency' => 'usd',
  "description" => "Charge for ..."
));
} catch (Stripe_ApiConnectionError $e) {
  $errors[] = 'Network problem, perhaps try again.';
} catch (Stripe_InvalidRequestError $e) {
  $errors[] = 'You screwed up in your programming. Shouldnt happen!';
} catch (Stripe_ApiError $e) {
  $errors[] = 'Stripe servers are down!';
} catch (Stripe_CardError $e) {
  $errors[] = 'Card was declined.';
}

echo "<p>You have paid!</p>";

register.php

<form id="payment-form" action="" method="POST">
    <script
        src="https://checkout.stripe.com/v2/checkout.js" class="stripe-button"
        data-key="pk_test_???"
        data-amount="2500"
        data-name="Purtrainer"
        data-description="Monthly Subscription ($25.00)"
    </script>
    <div id="payment-errors">
        <? print_r($errors); ?>
    </div>
    </form>

在register.php中,我有几个文本输入电子邮件,名称,密码等...

当我点击“支付卡”按钮条带提供js代码,我将在测试信用卡信息,我的用户输入到我的数据库与文本输入的信息,但剥离既不创建客户也不收费 .

有帮助吗?

还有其他需要注意的事项 - 直接在URL中访问我的payment.php文件会给出一个错误,指出存在需要条带文件的问题 . 它说没有文件存在,即使它确实:)

1 回答

  • 2

    我想到了一些事情:

    • register.php中表单的操作是本地的,不是payment.php .

    • data-key="pk_test_???" 应为 $stripe['publishable_key']

    • 如评论中所述,SSL在实时模式下是必需的,但不是在测试模式下 .

    • 以递归方式检查所有文件的权限,对于测试 chmod -R 777 /path/to/stripe 将是一个可靠的测试 .

    • 下载条带PHP api文件的新副本 .

相关问题