mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
incorporate websocket
This commit is contained in:
parent
886d1af824
commit
67379d7c4f
@ -77,11 +77,7 @@ class Blockonomics implements MethodInterface
|
|||||||
|
|
||||||
if ($status != 200) {
|
if ($status != 200) {
|
||||||
echo "ERROR: " . $status . ' ' . $responseObj->message;
|
echo "ERROR: " . $status . ' ' . $responseObj->message;
|
||||||
} else {
|
|
||||||
echo "Success: " . $status;
|
|
||||||
echo json_encode($responseObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $responseObj;
|
return $responseObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,11 +153,14 @@ class Blockonomics implements MethodInterface
|
|||||||
$data['amount'] = $data['total']['amount_with_fee'];
|
$data['amount'] = $data['total']['amount_with_fee'];
|
||||||
$data['currency'] = $this->driver_class->client->getCurrencyCode();
|
$data['currency'] = $this->driver_class->client->getCurrencyCode();
|
||||||
$btc_amount = $data['amount'] / $this->getBTCPrice();
|
$btc_amount = $data['amount'] / $this->getBTCPrice();
|
||||||
$data['btc_amount'] = round($btc_amount, 10);
|
$data['btc_amount'] = number_format($btc_amount, 10, '.', '');
|
||||||
$data['btc_address'] = $this->getBTCAddress();
|
$btc_address = $this->getBTCAddress();
|
||||||
|
$data['btc_address'] = $btc_address;
|
||||||
$data['invoice_id'] = $this->invoice_id;
|
$data['invoice_id'] = $this->invoice_id;
|
||||||
$data['end_time'] = $this->getTenMinutesCountDownEndTime();
|
$data['end_time'] = $this->getTenMinutesCountDownEndTime();
|
||||||
$data['callback_url'] = $this->setCallbackUrl();
|
$data['callback_url'] = $this->setCallbackUrl();
|
||||||
|
|
||||||
|
$data['websocket_url'] = 'wss://www.blockonomics.co/payment/' . $btc_address;
|
||||||
return render('gateways.blockonomics.pay', $data);
|
return render('gateways.blockonomics.pay', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,15 +182,13 @@ class Blockonomics implements MethodInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// $data = [
|
$data = [
|
||||||
// 'payment_method' => '',
|
'payment_method' => '',
|
||||||
// 'payment_type' => PaymentType::CRYPTO,
|
'payment_type' => PaymentType::CRYPTO,
|
||||||
// 'amount' => 200,
|
'amount' => 200,
|
||||||
// 'transaction_reference' => 123,
|
'transaction_reference' => 123,
|
||||||
// 'gateway_type_id' => GatewayType::CRYPTO,
|
'gateway_type_id' => GatewayType::CRYPTO,
|
||||||
// ];
|
];
|
||||||
|
|
||||||
// $payment = $this->createPayment($data, Payment::STATUS_COMPLETED);
|
|
||||||
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey(6)]);
|
return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey(6)]);
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
@ -125,6 +125,7 @@ class BlockonomicsPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
public function processPaymentResponse($request)
|
public function processPaymentResponse($request)
|
||||||
{
|
{
|
||||||
|
echo "It reached the processPaymentResponse";
|
||||||
return $this->payment_method->paymentResponse($request);
|
return $this->payment_method->paymentResponse($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,30 @@
|
|||||||
var x = setInterval(updateCountdown, 1000);
|
var x = setInterval(updateCountdown, 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var webSocketUrl = "{{ $websocket_url }}";
|
||||||
|
const ws = new WebSocket(webSocketUrl);
|
||||||
|
|
||||||
|
ws.onopen = function() {
|
||||||
|
console.log('WebSocket connection established');
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.onmessage = function(event) {
|
||||||
|
const data = JSON.parse(event.data);
|
||||||
|
console.log('Payment status:', data.status);
|
||||||
|
document.getElementById('server-response').submit();
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.onerror = function(error) {
|
||||||
|
console.error('WebSocket error:', error);
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.onclose = function() {
|
||||||
|
console.log('WebSocket connection closed');
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.blockonomics-payment-wrapper {
|
.blockonomics-payment-wrapper {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user