diff --git a/Belevo_Bezahl_Modul/module.php b/Belevo_Bezahl_Modul/module.php index 110df3d..7f6d796 100644 --- a/Belevo_Bezahl_Modul/module.php +++ b/Belevo_Bezahl_Modul/module.php @@ -48,35 +48,60 @@ class Belevo_Bezahl_Modul extends IPSModule { IPS_LogMessage("Belevo_Bezahl_Modul", "ReservateAmount: amount=$amount"); - // Beispiel-Logik zur Reservierung des Betrags bei Stripe - + // Beispiel-Logik zur Reservierung des Betrags bei Stripe mit Google Pay $apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm"; // Test-API-Schlüssel + // Öffnen eines Fensters zur Eingabe der Zahlungsinformationen über Google Pay + $html = ' + '; + paymentRequest.on("token", function(ev) { + // Send the token to your server to charge it! + fetch("/charges", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({token: ev.token.id}), + }).then(function(response) { + if (response.ok) { + ev.complete("success"); + SetValueBoolean(' . $this->GetIDForIdent("AmountIsReserved") . ', true); + IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung erfolgreich."); + } else { + ev.complete("fail"); + IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung fehlgeschlagen."); + } + }); + }); + +
'; SetValue($this->ReadPropertyInteger("Reservate"), $html); // Baut das HTML auf - - - // Simulierte erfolgreiche Reservierung - $reservationSuccessful = true; - - if ($reservationSuccessful) { - SetValueBoolean($this->GetIDForIdent("AmountIsReserved"), true); - IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung erfolgreich."); - } else { - IPS_LogMessage("Belevo_Bezahl_Modul", "Reservierung fehlgeschlagen."); - } } public function GetAmount($amount) @@ -85,8 +110,7 @@ class Belevo_Bezahl_Modul extends IPSModule // Beispiel-Logik zum Abziehen des Betrags bei Stripe $apiUrl = "https://api.stripe.com/v1/charges"; - - $apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm"; + $apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm"; // Test-API-Schlüssel $data = [ "amount" => $amount * 100, // Betrag in Cent diff --git a/library.json b/library.json index 106316b..d0ead9a 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "1.007", + "version": "1.008", "build": 0, "date": 0 } \ No newline at end of file