d
This commit is contained in:
@@ -29,84 +29,85 @@ class Belevo_Bezahl_Modul extends IPSModule
|
||||
$apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm"; // Test-API-Schlüssel
|
||||
|
||||
$html = '<html>
|
||||
<head>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="reservateAmount()">Reservate</button>
|
||||
<button onclick="getAmount()">Get Amount</button>
|
||||
<div id="payment-request-button"></div>
|
||||
<script>
|
||||
var stripe = Stripe("' . $apiKey . '");
|
||||
var elements = stripe.elements();
|
||||
var paymentRequest = stripe.paymentRequest({
|
||||
country: "CH",
|
||||
currency: "chf",
|
||||
total: {
|
||||
label: "Reservation Amount",
|
||||
amount: 1000, // Beispielbetrag in Cent
|
||||
},
|
||||
requestPayerName: true,
|
||||
requestPayerEmail: true,
|
||||
});
|
||||
<head>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="reservateAmount()">Reservate</button>
|
||||
<button onclick="getAmount()">Get Amount</button>
|
||||
<div id="payment-request-button"></div>
|
||||
<script>
|
||||
var stripe = Stripe("pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm");
|
||||
var elements = stripe.elements();
|
||||
var paymentRequest = stripe.paymentRequest({
|
||||
country: "CH",
|
||||
currency: "chf",
|
||||
total: {
|
||||
label: "Reservation Amount",
|
||||
amount: 1000, // Beispielbetrag in Cent
|
||||
},
|
||||
requestPayerName: true,
|
||||
requestPayerEmail: true,
|
||||
});
|
||||
|
||||
var prButton = elements.create("paymentRequestButton", {
|
||||
paymentRequest: paymentRequest,
|
||||
});
|
||||
var prButton = elements.create("paymentRequestButton", {
|
||||
paymentRequest: paymentRequest,
|
||||
});
|
||||
|
||||
paymentRequest.canMakePayment().then(function(result) {
|
||||
if (result) {
|
||||
prButton.mount("#payment-request-button");
|
||||
} else {
|
||||
document.getElementById("payment-request-button").style.display = "none";
|
||||
}
|
||||
});
|
||||
paymentRequest.canMakePayment().then(function(result) {
|
||||
if (result) {
|
||||
prButton.mount("#payment-request-button");
|
||||
} else {
|
||||
document.getElementById("payment-request-button").style.display = "none";
|
||||
}
|
||||
});
|
||||
|
||||
function reservateAmount() {
|
||||
paymentRequest.on("token", function(ev) {
|
||||
// Send the token to your server to charge it!
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/api/");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "SetValue",
|
||||
"params": [' . $this->GetIDForIdent("AmountIsReserved") . ', true],
|
||||
"id": 0
|
||||
}));
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
ev.complete("success");
|
||||
console.log("Reservierung erfolgreich.");
|
||||
} else {
|
||||
ev.complete("fail");
|
||||
console.log("Reservierung fehlgeschlagen.");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
function reservateAmount() {
|
||||
paymentRequest.show();
|
||||
paymentRequest.on("token", function(ev) {
|
||||
// Send the token to your server to charge it!
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/api/");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "SetValue",
|
||||
"params": [' . $this->GetIDForIdent("AmountIsReserved") . ', true],
|
||||
"id": 0
|
||||
}));
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
ev.complete("success");
|
||||
console.log("Reservierung erfolgreich.");
|
||||
} else {
|
||||
ev.complete("fail");
|
||||
console.log("Reservierung fehlgeschlagen.");
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function getAmount() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/api/");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "SetValue",
|
||||
"params": [' . $this->GetIDForIdent("AmountIsReserved") . ', false],
|
||||
"id": 0
|
||||
}));
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
console.log("Abzug erfolgreich.");
|
||||
} else {
|
||||
console.log("Abzug fehlgeschlagen.");
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>';
|
||||
function getAmount() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/api/");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "SetValue",
|
||||
"params": [' . $this->GetIDForIdent("AmountIsReserved") . ', false],
|
||||
"id": 0
|
||||
}));
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
console.log("Abzug erfolgreich.");
|
||||
} else {
|
||||
console.log("Abzug fehlgeschlagen.");
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
SetValue($this->ReadPropertyInteger("HTMLBox"), $html); // Baut das HTML auf
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"compatibility": {
|
||||
"version": "7.1"
|
||||
},
|
||||
"version": "1.017",
|
||||
"version": "1.018",
|
||||
"build": 0,
|
||||
"date": 0
|
||||
}
|
||||
Reference in New Issue
Block a user