sadf
This commit is contained in:
@@ -48,35 +48,60 @@ class Belevo_Bezahl_Modul extends IPSModule
|
|||||||
{
|
{
|
||||||
IPS_LogMessage("Belevo_Bezahl_Modul", "ReservateAmount: amount=$amount");
|
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
|
$apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm"; // Test-API-Schlüssel
|
||||||
|
|
||||||
|
// Öffnen eines Fensters zur Eingabe der Zahlungsinformationen über Google Pay
|
||||||
|
$html = '<script src="https://js.stripe.com/v3/"></script>
|
||||||
|
<script>
|
||||||
|
var stripe = Stripe("' . $apiKey . '");
|
||||||
|
var elements = stripe.elements();
|
||||||
|
var paymentRequest = stripe.paymentRequest({
|
||||||
|
country: "CH",
|
||||||
|
currency: "chf",
|
||||||
|
total: {
|
||||||
|
label: "Reservation Amount",
|
||||||
|
amount: ' . ($amount * 100) . ',
|
||||||
|
},
|
||||||
|
requestPayerName: true,
|
||||||
|
requestPayerEmail: true,
|
||||||
|
});
|
||||||
|
|
||||||
// Öffnen eines Fensters zur Eingabe der Zahlungsinformationen
|
var prButton = elements.create("paymentRequestButton", {
|
||||||
$html = '<script>
|
paymentRequest: paymentRequest,
|
||||||
var windowObjectReference;
|
});
|
||||||
var strWindowFeatures = "menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes";
|
|
||||||
|
|
||||||
function openRequestedPopup() {
|
paymentRequest.canMakePayment().then(function(result) {
|
||||||
windowObjectReference = window.open("https://checkout.stripe.com/pay", "Stripe_Window", strWindowFeatures);
|
if (result) {
|
||||||
}
|
prButton.mount("#payment-request-button");
|
||||||
|
} else {
|
||||||
|
document.getElementById("payment-request-button").style.display = "none";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
openRequestedPopup();
|
paymentRequest.on("token", function(ev) {
|
||||||
</script>';
|
// 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.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<div id="payment-request-button"></div>';
|
||||||
|
|
||||||
SetValue($this->ReadPropertyInteger("Reservate"), $html); // Baut das HTML auf
|
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)
|
public function GetAmount($amount)
|
||||||
@@ -85,8 +110,7 @@ class Belevo_Bezahl_Modul extends IPSModule
|
|||||||
|
|
||||||
// Beispiel-Logik zum Abziehen des Betrags bei Stripe
|
// Beispiel-Logik zum Abziehen des Betrags bei Stripe
|
||||||
$apiUrl = "https://api.stripe.com/v1/charges";
|
$apiUrl = "https://api.stripe.com/v1/charges";
|
||||||
|
$apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm"; // Test-API-Schlüssel
|
||||||
$apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm";
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
"amount" => $amount * 100, // Betrag in Cent
|
"amount" => $amount * 100, // Betrag in Cent
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "1.007",
|
"version": "1.008",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user