You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.4 KiB
35 lines
1.4 KiB
<?php
|
|
$request = file_get_contents('php://input');
|
|
$payload = json_decode($request, true) ?: $_POST ?: [];
|
|
|
|
zinipay_log('Incoming Webhook', $payload);
|
|
|
|
$settings = function_exists('getPaymentGateway') ? getPaymentGateway('zinipay') : [];
|
|
$invoiceId = $payload['metadata']['invoiceId'] ?? $_REQUEST['invoiceId'] ?? null;
|
|
$transactionId = $payload['transactionId'] ?? $payload['val_id'] ?? null;
|
|
$amount = $payload['amount'] ?? 0;
|
|
|
|
if ($invoiceId) {
|
|
$recorded = false;
|
|
if (function_exists('addPayment')) {
|
|
@addPayment($invoiceId, $transactionId ?? uniqid('zinipay_'), $amount, 0, 'zinipay');
|
|
$recorded = true;
|
|
} elseif (function_exists('invoicePaymentAdd')) {
|
|
@invoicePaymentAdd($invoiceId, $transactionId ?? uniqid('zinipay_'), $amount, 0, 'zinipay');
|
|
$recorded = true;
|
|
}
|
|
if ($recorded) zinipay_log('Payment Recorded via Webhook', ['invoice'=>$invoiceId,'transaction'=>$transactionId,'amount'=>$amount]);
|
|
}
|
|
|
|
http_response_code(200);
|
|
echo 'OK';
|
|
exit;
|
|
|
|
function zinipay_log($title, $data = []) {
|
|
$logDir = realpath(__DIR__ . '/../../storage/logs') ?: (__DIR__ . '/../../storage/logs');
|
|
if (!is_dir($logDir)) @mkdir($logDir, 0777, true);
|
|
$logFile = $logDir . '/gateway_zinipay.log';
|
|
$time = date("Y-m-d H:i:s");
|
|
$entry = "[$time] $title\n" . print_r($data,true) . "\n-------------------\n";
|
|
@file_put_contents($logFile, $entry, FILE_APPEND | LOCK_EX);
|
|
}
|