条纹不用PHP收费

时间:2015-08-15 16:25:59

标签: php web stripe-payments

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

<div class="container">
            <form action="charge.php" method="POST">
                <h6> amount </h6>
                <input type="text" name="amount" />
                <h6> test-info </h6>
                <br /> <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>

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

的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 :(得分:0)

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