no message
This commit is contained in:
@@ -27,67 +27,97 @@ class Belevo_Bezahl_Modul extends IPSModule
|
||||
private function SetHTMLContent()
|
||||
{
|
||||
$apiKey = "pk_test_51Qkr79LJAcsNrpivA90lt7ULEzyXKR8l0pAqTBgfeuAIWlsLS4A3BdIBITc9UooFANbImvlJQ2F2jOZ0X5j8GI7Q00hNNasvQm"; // Test-API-Schlüssel
|
||||
|
||||
$html = '<html>
|
||||
|
||||
$html = "<html>
|
||||
<head>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<meta charset=\"UTF-8\">
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
|
||||
<title>Stripe Payment Request API</title>
|
||||
<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>
|
||||
<h1>Stripe Payment Request API Integration</h1>
|
||||
<button id=\"reservate-button\">Reservate</button>
|
||||
<button id=\"get-amount-button\">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",
|
||||
// Stripe initialisieren
|
||||
const stripe = Stripe('$apiKey');
|
||||
const elements = stripe.elements();
|
||||
|
||||
// Payment Request konfigurieren
|
||||
const paymentRequest = stripe.paymentRequest({
|
||||
country: 'CH',
|
||||
currency: 'chf',
|
||||
total: {
|
||||
label: "Reservation Amount",
|
||||
label: 'Reservation Amount',
|
||||
amount: 1000, // Beispielbetrag in Cent
|
||||
},
|
||||
requestPayerName: true,
|
||||
requestPayerEmail: true,
|
||||
});
|
||||
|
||||
var prButton = elements.create("paymentRequestButton", {
|
||||
|
||||
const prButton = elements.create('paymentRequestButton', {
|
||||
paymentRequest: paymentRequest,
|
||||
});
|
||||
|
||||
|
||||
paymentRequest.canMakePayment().then(function(result) {
|
||||
if (result) {
|
||||
prButton.mount("#payment-request-button");
|
||||
prButton.mount('#payment-request-button');
|
||||
} else {
|
||||
document.getElementById("payment-request-button").style.display = "none";
|
||||
document.getElementById('payment-request-button').style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
function reservateAmount() {
|
||||
// Show the payment request button
|
||||
document.getElementById("payment-request-button").style.display = "block";
|
||||
}
|
||||
|
||||
function getAmount() {
|
||||
|
||||
document.getElementById('reservate-button').addEventListener('click', function() {
|
||||
paymentRequest.show();
|
||||
});
|
||||
|
||||
document.getElementById('get-amount-button').addEventListener('click', function() {
|
||||
// Hier kannst du die Logik zum Abbuchen des Betrags hinzufügen
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/api/");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.open('POST', '/api/');
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.send(JSON.stringify({
|
||||
"jsonrpc": "2.0",
|
||||
"method": "SetValue",
|
||||
"params": ["AmountIsReserved", false],
|
||||
"id": 0
|
||||
'jsonrpc': '2.0',
|
||||
'method': 'SetValue',
|
||||
'params': ['AmountIsReserved', false],
|
||||
'id': 0
|
||||
}));
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
console.log("Abzug erfolgreich.");
|
||||
console.log('Abzug erfolgreich.');
|
||||
} else {
|
||||
console.log("Abzug fehlgeschlagen.");
|
||||
console.log('Abzug fehlgeschlagen.');
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
paymentRequest.on('token', function(ev) {
|
||||
// Token an den Server senden
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/api/');
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.send(JSON.stringify({
|
||||
'jsonrpc': '2.0',
|
||||
'method': 'SetValue',
|
||||
'params': ['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.');
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>';
|
||||
</html>";
|
||||
|
||||
SetValue($this->ReadPropertyInteger("HTMLBox"), $html); // Baut das HTML auf
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"compatibility": {
|
||||
"version": "7.1"
|
||||
},
|
||||
"version": "1.020",
|
||||
"version": "1.021",
|
||||
"build": 0,
|
||||
"date": 0
|
||||
}
|
||||
Reference in New Issue
Block a user