为什么我收到Stripe 400错误 - 不能多次使用Stripe Token?

时间:2016-02-16 03:38:13

标签: php mysql stripe-payments

我不确定我收到错误的原因。我在作业提交时创建一个令牌,并将其发布到相关客户的数据库中。完成作业后,我使用数据库中的令牌完成交易。以下是我的交易流程代码。

if(isset($_GET["job"])){
        $status = $_GET["status"];
        if($_GET["status"] == 1){

            $jobq = 'SELECT * from jobsubmission WHERE ID='.$_GET["job"];
            $jobres = mysqli_query($conn, $jobq);
            $data = mysqli_fetch_object($jobres);

            $token = $data->stripetoken;
            $bookdetail = 'SELECT driver from booking WHERE job='.$_GET["job"];
            $res = mysqli_query($conn, $bookdetail);
            $data1 = mysqli_fetch_object($res);
            $driver = $data1->driver;
            $driverdetail = 'SELECT stripe_account from driverinformation WHERE ID='.$driver;
            $res = mysqli_query($conn, $driverdetail);
            $data2 = mysqli_fetch_object($res);
            $accountid = $data2->stripe_account;
            $amount = $data->jobpay*100;

            require_once('Stripe/lib/Stripe.php');
            Stripe::setApiKey($key);

            $charge = Stripe_Charge::create(array(
              "amount" => $amount,
              "currency" => "usd",
              "card" => $token,
              "description" => "Charge for the booked job in Swift job"
            ), array('stripe_account' => $accountid));

            if($charge->status == "succeeded"){

                $transid = $charge->id;
                $jobid = $_POST["job"];
                $conn = dbconnection();
                $updqry = 'UPDATE booking set paid=1, paiddate='.time().', transactionid="'.$transid.'" WHERE job='.$jobid;
                $update = mysqli_query($conn, $updqry);

1 个答案:

答案 0 :(得分:0)

条纹费用ID用于立即捕获费用(自创建之日起最多5分钟)。如果您想稍后捕获费用,则应将费用ID附加到Customer对象(shown here)。