I’m using curl in my stripe webhook. When a payment if complete, my function will run a curl to pull data from an api URL. here is my curl code
$curl = new Curl();
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, (YII_ENV == 'dev') ? false : true);
$curl->setOpt(CURLOPT_SSL_VERIFYHOST, (YII_ENV == 'dev') ? false : 2);
//$curl->setOpt(CURLOPT_RETURNTRANSFER, false);
//$curl->setOpt(CURLOPT_URL, $apiURL);
$curl->get($apiURL);
if ($curl->error) {
Yii::error($curl->errorMessage);
Yii::$app->end();
} else {
$response = $curl->response;
}
In general the code works fine, but once in a while it will pull data from $apiURL
twice. Any idea how to fix this, or prevent it?
Could it be a race condition issue? I was looking into mutex, but not sure how to even implement it here.