[英]Why am I receiving a Stripe 400 Error - Cannot Use Stripe Token More Than Once?
I am unsure as to why I am receiving the error. 我不确定为什么会收到错误消息。 I create a token upon job submission and post it to the database for the associated customer. 我在提交工作后创建一个令牌,并将其发布到相关客户的数据库中。 Upon completion of the job, I use the token from the database to complete the transaction. 作业完成后,我使用数据库中的令牌完成交易。 Below is my code for the transaction process. 以下是我的交易过程代码。
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);
The Stripe charge ID is meant to capture charges immediately (up to 5 minutes from when it was created). Stripe收费ID旨在立即捕获收费(从创建之日起最多5分钟)。 If you want to capture the charge later, then you should attach the charge ID to a Customer
object (which is shown here ). 如果要在以后捕获费用,则应将费用ID附加到“ Customer
对象(如此处所示 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.