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