我有各种用户存储在数据库中。我需要检查每个用户的日期并将今天的日期与数据库中的日期进行比较,如果今天是数据库中日期的第 30 天,则执行curl。以下是我的代码
public function repeatPayment()
{
//return "hi22";
$users=Payment::all();
foreach ($users as $user)
{
$trans_id = $user->transactionid;
$clinicid = $user->clinicID;
$last_transaction_date = $user->updated_at;
echo $last_transaction_date."<br>";
if (strtotime($last_transaction_date) < strtotime('-30 days')) {
echo "hello";
}
$payment = array(
"MerchantID"=> "0000000001",
"Login"=> "API0000000001",
"Password"=> "Temp1234!",
"NewExpDate"=> "102020",
"Amount"=> "29.99",
"Token"=>$trans_id,
"StandardEntryCode"=> "string",
"AuthOnly"=> false
);
$post_field = json_encode($payment);
// var_dump($post_field);
// die();
$ch = curl_init();
$headers = array(
"Content-type: application/json",
"Cache-Control: no-cache",
);
curl_setopt($ch, CURLOPT_URL,"https://api.securepds.com/2.0/payments.svc/JSON/SubmitTokenPayment");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_field);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close ($ch);
$payment_id= json_decode($server_output,true);
$newTransId= new CronJob;
$newTransId->clinic_id = $clinicid;
$newTransId->tranascation_id = $payment_id["Confirmation"];
$newTransId->transaction_date = date('d/m/Y');
$newTransId->save();
}
}
森栏
梦里花落0921
吃鸡游戏