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