首页 文章

条纹不用PHP充电

提问于
浏览
0

我创建了一个非常简单的网站,它具有提交到计费页面的默认条带检出 . 我已经按照条带网站上的PHP说明进行操作,我完全不知道为什么它不起作用 . 结帐页面工作正常:

<div class="container">
            <form action="charge.php" method="POST">
                <h6> amount </h6>
                <input type="text" name="amount" />
                <h6> test-info </h6>
                
<input type="text" name="pubkey" /> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="pk_test_NC2CbWJLgm82SMzbxRX4JBLo" data-amount="2000" data-name="Demo Site" data-description="2 widgets ($20.00)" data-image="/128x128.png" data-bitcoin="true"> </script> </form> </div>

结帐的所有输入(例如电子邮件,令牌和pubkey)都会完美地传输到charge.php页面 . 在charge.php:

<?php
    require_once('config.php');

    $token = $_POST ['stripeToken'];
    $email = $_POST['stripeEmail'];
    $pubkey = $_POST['pubkey'];
    $amount = $_POST['amount'];
    ?>
    <h3> Public key: <?php echo $pubkey; ?> </h3> 
    <h3> Token: <?php echo $token; ?> </h3> 
    <h3> Amount: <?php echo $amount; ?> </h3> 
    <h3> Email: <?php echo $email; ?> </h3>

    <?php
        try {
            $charge = \Stripe\Charge::create(array(
                "amount" => 1000, // amount in cents, again
                "currency" => "gbp",
                "source" => $token,
                "description" => "Example charge"
            ));
            } catch(\Stripe\Error\Card $e) {

            }


    ?>

    <h6> You've been charged </h6>

表单提交中的所有变量都将打印出来 . 但是,由于某种原因,实际充电不起作用,并且不打印出 Headers (即您已被充电) . 令牌是正确的所以我真的不确定它是如何可以充电的 . 为什么我错了,我怎么调试这个才能找到答案?

config.php文件

<?php 
    require_once('vendor/autoload.php');
    $stripe = array(
        "secret_key" => "sk_test_**********************",
        "publishable_key" => "pk_test_NC2CbWJLgm82SMzbxRX4JBLo"
    );
    \Stripe\Stripe::setApiKey($stripe['secret_key']);
    echo 'this is from config.php';

?>

1 回答

  • 0

    似乎问题是data-bitcoin =“true” . 摆脱它意味着付款通过 .

相关问题