This commit is contained in:
2025-01-28 15:37:24 +01:00
parent 4c0e144aa9
commit cbf12baa7b
2 changed files with 13 additions and 11 deletions

View File

@@ -81,22 +81,24 @@ class Belevo_Bezahl_Modul extends IPSModule
paymentRequest.on("token", function(ev) { paymentRequest.on("token", function(ev) {
// Send the token to your server to charge it! // Send the token to your server to charge it!
fetch("/charges", { var xhr = new XMLHttpRequest();
method: "POST", xhr.open("POST", "/api/");
headers: { xhr.setRequestHeader("Content-Type", "application/json");
"Content-Type": "application/json", xhr.send(JSON.stringify({
}, "jsonrpc": "2.0",
body: JSON.stringify({token: ev.token.id}), "method": "SetValue",
}).then(function(response) { "params": [' . $this->GetIDForIdent("AmountIsReserved") . ', true],
if (response.ok) { "id": 0
}));
xhr.onload = function() {
if (xhr.status === 200) {
ev.complete("success"); ev.complete("success");
SetValueBoolean(' . $this->GetIDForIdent("AmountIsReserved") . ', true);
IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung erfolgreich."); IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung erfolgreich.");
} else { } else {
ev.complete("fail"); ev.complete("fail");
IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung fehlgeschlagen."); IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung fehlgeschlagen.");
} }
}); };
}); });
</script> </script>
<div id="payment-request-button"></div>'; <div id="payment-request-button"></div>';

View File

@@ -6,7 +6,7 @@
"compatibility": { "compatibility": {
"version": "7.1" "version": "7.1"
}, },
"version": "1.008", "version": "1.009",
"build": 0, "build": 0,
"date": 0 "date": 0
} }