feat: the webhook is now processed correctly
This commit is contained in:
parent
1e95fd8bce
commit
ce0456a98d
1 changed files with 11 additions and 2 deletions
15
BitCart.php
15
BitCart.php
|
@ -61,6 +61,7 @@ class BitCart extends Gateway
|
||||||
* @param int $total
|
* @param int $total
|
||||||
* @param array $products
|
* @param array $products
|
||||||
* @param int $invoiceId
|
* @param int $invoiceId
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function pay($total, $products, $invoiceId)
|
public function pay($total, $products, $invoiceId)
|
||||||
{
|
{
|
||||||
|
@ -109,11 +110,19 @@ class BitCart extends Gateway
|
||||||
public function webhook(Request $request)
|
public function webhook(Request $request)
|
||||||
{
|
{
|
||||||
$body = $request->getContent();
|
$body = $request->getContent();
|
||||||
|
$api_domain = ExtensionHelper::getConfig('Bitcart', 'api_endpoint');
|
||||||
$data = json_decode($body, true);
|
$data = json_decode($body, true);
|
||||||
|
$url_check = sprintf('%s/%s', $api_domain, 'invoices/' . $data['id']);
|
||||||
|
$checkData = $this->send_request($url_check, array(), 0);
|
||||||
$invoiceId = $data['id'];
|
$invoiceId = $data['id'];
|
||||||
$status = $data['status'];
|
$status = $data['status'];
|
||||||
if ($status == 'complete') {
|
if ($invoiceId != $checkData->id) {
|
||||||
ExtensionHelper::paymentDone($invoiceId,'BitCart',null);
|
return response()->json(['success' => false]);
|
||||||
}
|
}
|
||||||
|
if ($status != 'complete' || $status != $checkData->status) {
|
||||||
|
return response()->json(['success' => false]);
|
||||||
|
}
|
||||||
|
ExtensionHelper::paymentDone($checkData -> order_id,'BitCart',null);
|
||||||
|
return response()->json(['success' => true]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue