Rework BTC Payment webhooks
This commit is contained in:
parent
dfdabe1f1a
commit
30b4ed191f
|
|
@ -91,7 +91,7 @@ class BTCPayPaymentDriver extends BaseDriver
|
|||
|
||||
public function processWebhookRequest()
|
||||
{
|
||||
sleep(2);
|
||||
|
||||
|
||||
$webhook_payload = file_get_contents('php://input');
|
||||
|
||||
|
|
@ -100,11 +100,21 @@ class BTCPayPaymentDriver extends BaseDriver
|
|||
if ($btcpayRep == null) {
|
||||
throw new PaymentFailed('Empty data');
|
||||
}
|
||||
if (true === empty($btcpayRep->invoiceId)) {
|
||||
|
||||
if (empty($btcpayRep->invoiceId)) {
|
||||
throw new PaymentFailed(
|
||||
'Invalid BTCPayServer payment notification- did not receive invoice ID.'
|
||||
);
|
||||
}
|
||||
|
||||
if(!isset($btcpayRep->metadata->InvoiceNinjaPaymentHash)){
|
||||
|
||||
throw new PaymentFailed(
|
||||
'Invalid BTCPayServer payment notification- did not receive Payment Hashed ID.'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if (
|
||||
str_starts_with($btcpayRep->invoiceId, "__test__")
|
||||
|| $btcpayRep->type == "InvoiceProcessing"
|
||||
|
|
@ -121,7 +131,7 @@ class BTCPayPaymentDriver extends BaseDriver
|
|||
}
|
||||
}
|
||||
|
||||
$this->init();
|
||||
|
||||
$webhookClient = new Webhook($this->btcpay_url, $this->api_key);
|
||||
|
||||
if (!$webhookClient->isIncomingWebhookRequestValid($webhook_payload, $sig, $this->webhook_secret)) {
|
||||
|
|
@ -130,6 +140,11 @@ class BTCPayPaymentDriver extends BaseDriver
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
sleep(1);
|
||||
|
||||
$this->init();
|
||||
|
||||
$this->setPaymentMethod(GatewayType::CRYPTO);
|
||||
$this->payment_hash = PaymentHash::where('hash', $btcpayRep->metadata->InvoiceNinjaPaymentHash)->firstOrFail();
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class Statement
|
|||
$pdf = null;
|
||||
$html = $maker->getCompiledHTML(true);
|
||||
|
||||
nlog($html);
|
||||
// nlog($html);
|
||||
|
||||
if ($this->rollback) {
|
||||
\DB::connection(config('database.default'))->rollBack();
|
||||
|
|
|
|||
Loading…
Reference in New Issue