diff --git a/app/views/foodcourt/qrpay/init.html.erb b/app/views/foodcourt/qrpay/init.html.erb
index dc060573..d1965337 100644
--- a/app/views/foodcourt/qrpay/init.html.erb
+++ b/app/views/foodcourt/qrpay/init.html.erb
@@ -254,70 +254,66 @@
$(document).ready(function() {
const $paymentWaiting = $('.payment-waiting');
const amountToReceive = <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i) %>;
- const $receiptNo = $('#receipt_no');
- const ws = new WebSocket("wss://juicecorner-0mo.sx-fc.app/cable");
+ const receiptNo = $('#receipt_no').text();
+ const cable = ActionCable.createConsumer("wss://juicecorner-0mo.sx-fc.app/cable");
- ws.onopen = function() {
- console.log("Nagato channel connected");
- ws.send(JSON.stringify({
- command: "subscribe",
- identifier: JSON.stringify({
- channel: "TestChannel",
- receipt_no: $receiptNo.text()
- })
- }));
- };
+ const subscription = cable.subscriptions.create(
+ {
+ channel: "TestChannel",
+ receipt_no: receiptNo
+ },
+ {
+ connected() {
+ console.log("Nagato channel connected");
+ },
- ws.onmessage = function(e) {
- const msg = JSON.parse(e.data);
- console.log("Received:", msg);
+ received(data) {
+ console.log("Received:", data);
- if (msg.type === 'confirm_subscription') {
- console.log("This world shall know pain");
+ if (data.status === "PAY_SUCCESS") {
+ this.handlePaymentSuccess();
+ }
+ },
+
+ handlePaymentSuccess() {
+ $paymentWaiting.html(`
+
+
Amount Received: ${amountToReceive}
+
- Amount Received: ${amountToReceive}
-