我的Stripe付款非常有效.但现在我想从数据库中捕获


My Stripe payment is working perfect. But now i want to catch from Database

我正在使用条纹支付。我已经在我的博士网站上集成了Stripe结账系统。有了静态价格,效果很好。但我不想从我的数据库中获取价格。它在屏幕上显示它已充电。但在我的脱衣舞账户里,它并没有汇款。。

$charge = Stripe_Charge::create(array(
  "amount" => 999999, // I want here $price from my database.
  "currency" => "usd",
  "card" => $_POST['stripeToken'],
  "description" => 'This is Different Thing'
));

当我添加$price而不是静态价格99999时,它不会向我的条纹支付汇款。但当我再次添加99999时,它就开始工作了。我的数据库正常所有可验证文件和数据库连接正常。问题就在这里。。我怎样才能把它修好。。如果你想要我的完整代码。。

include 'header.php';  //Connection File is in header.php
error_reporting(0);
try {
    require_once('Stripe/lib/Stripe.php');
    Stripe::setApiKey("sk_test_GkvxX3TWD6juGRLhZwP2LQ1x");
$req_id = $_REQUEST['order_id'];
$get_req = "SELECT * FROM `requests` WHERE `req_id` = '$req_id'";
$result = mysqli_query($dbc, $get_req);
while($row = mysqli_fetch_array($result)){
$req_id = $row['req_id'];
$request_title = $row['request_title'];
$username = $row['username'];
$user_id = $row['user_id'];
$price = $row['price'];
$request_time = $row['request_time'];
$req_date = $row['req_date'];
$category = $row['category'];
$sub_category = $row['sub_category'];
$from_address = $row['from_address'];
$to_address = $row['to_address'];
$from_state = $row['from_state'];
$to_state = $row['to_state'];
$from_city = $row['from_city'];
$to_city = $row['to_city'];
$req_desc = $row['req_desc'];
$status = $row['req_status'];
$paid = $row['paid'];
}
$charge = Stripe_Charge::create(array(
  "amount" => 999999,
  "currency" => "usd",
  "card" => $_POST['stripeToken'],
  "description" => 'This is Different Thing'
));

$status = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $errors = array();

    if (isset($_POST['stripeToken'])) {
        $token = $_POST['stripeToken'];
        echo 'Payment Done ';
$status = 1;

//print_r($token);
    } else {
        $errors['token'] = 'The order cannot be processed. You have not been charged.
                            Please confirm that you have JavaScript enabled and try again.';
echo "payment not successfully done.Please try again";
$status = 0;
    }
} // End of form submission conditional.


}
catch(Stripe_CardError $e) {
}
//catch the errors in any way you like
 catch (Stripe_InvalidRequestError $e) {
  // Invalid parameters were supplied to Stripe's API
} catch (Stripe_AuthenticationError $e) {
  // Authentication with Stripe's API failed
  // (maybe you changed API keys recently)
} catch (Stripe_ApiConnectionError $e) {
  // Network communication with Stripe failed
} catch (Stripe_Error $e) {
  // Display a very generic error to the user, and maybe send
  // yourself an email
} catch (Exception $e) {
  // Something else happened, completely unrelated to Stripe
}
if($status2 = 1){
$query = "UPDATE `requests` SET `req_status`='1', `paid`='1' WHERE `req_id`='$req_id'";
$result = mysqli_query($dbc,$query);
}else{ 

}

我还没有在你的代码中看到$price的输出是什么不要假设从您的数据库中提取的$price准备不正确,正如Stripe文档中所提到的价格以美分为单位。这样,如果你放置这个代码

$findme = ".";
$pos = strpos($price, $findme);
$PosPlus = $pos+1;
$Part1=substr($price, 0, $pos);
$Part2=substr($price, $PosPlus);
$price = ($Part1.$Part2);

在你的电话线上,

$charge = Stripe_Charge::create(array(   //.....

你的指控应该会成功。