no message
This commit is contained in:
@@ -24,89 +24,100 @@ class Belevo_Bezahl_Modul extends IPSModule
|
|||||||
|
|
||||||
$html = "<html>
|
$html = "<html>
|
||||||
<head>
|
<head>
|
||||||
<script src=\"https://js.stripe.com/v3/\"></script>
|
<script>
|
||||||
|
const stripeScript = document.createElement('script');
|
||||||
|
stripeScript.src = 'https://js.stripe.com/v3/';
|
||||||
|
stripeScript.onload = function() {
|
||||||
|
console.log('Stripe.js loaded successfully');
|
||||||
|
initializeStripe();
|
||||||
|
};
|
||||||
|
stripeScript.onerror = function() {
|
||||||
|
console.error('Failed to load Stripe.js');
|
||||||
|
};
|
||||||
|
document.head.appendChild(stripeScript);
|
||||||
|
|
||||||
|
function initializeStripe() {
|
||||||
|
const stripe = Stripe('$apiKey');
|
||||||
|
const elements = stripe.elements();
|
||||||
|
|
||||||
|
const paymentRequest = stripe.paymentRequest({
|
||||||
|
country: 'CH',
|
||||||
|
currency: 'chf',
|
||||||
|
total: {
|
||||||
|
label: 'Reservation Amount',
|
||||||
|
amount: 1000,
|
||||||
|
},
|
||||||
|
requestPayerName: true,
|
||||||
|
requestPayerEmail: true,
|
||||||
|
requestPayerPhone: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
paymentRequest.on('paymentmethod', function(ev) {
|
||||||
|
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.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const 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';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('reservate-button').addEventListener('click', function() {
|
||||||
|
document.getElementById('payment-request-button').style.display = 'block';
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('get-amount-button').addEventListener('click', function() {
|
||||||
|
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', false],
|
||||||
|
'id': 0
|
||||||
|
}));
|
||||||
|
xhr.onload = function() {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
console.log('Abzug erfolgreich.');
|
||||||
|
} else {
|
||||||
|
console.log('Abzug fehlgeschlagen.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Stripe Payment Request API Integration</h1>
|
<h1>Stripe Payment Request API Integration</h1>
|
||||||
<button id=\"reservate-button\">Reservate</button>
|
<button id=\"reservate-button\">Reservate</button>
|
||||||
<button id=\"get-amount-button\">Get Amount</button>
|
<button id=\"get-amount-button\">Get Amount</button>
|
||||||
<div id=\"payment-request-button\"></div>
|
<div id=\"payment-request-button\"></div>
|
||||||
|
|
||||||
<script>
|
|
||||||
const stripe = Stripe('$apiKey');
|
|
||||||
const elements = stripe.elements();
|
|
||||||
|
|
||||||
const paymentRequest = stripe.paymentRequest({
|
|
||||||
country: 'CH',
|
|
||||||
currency: 'chf',
|
|
||||||
total: {
|
|
||||||
label: 'Reservation Amount',
|
|
||||||
amount: 1000,
|
|
||||||
},
|
|
||||||
requestPayerName: true,
|
|
||||||
requestPayerEmail: true,
|
|
||||||
requestPayerPhone: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
paymentRequest.on('paymentmethod', function(ev) {
|
|
||||||
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.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const 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';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('reservate-button').addEventListener('click', function() {
|
|
||||||
document.getElementById('payment-request-button').style.display = 'block';
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('get-amount-button').addEventListener('click', function() {
|
|
||||||
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', false],
|
|
||||||
'id': 0
|
|
||||||
}));
|
|
||||||
xhr.onload = function() {
|
|
||||||
if (xhr.status === 200) {
|
|
||||||
console.log('Abzug erfolgreich.');
|
|
||||||
} else {
|
|
||||||
console.log('Abzug fehlgeschlagen.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>";
|
</html>";
|
||||||
|
|
||||||
SetValue($this->ReadPropertyInteger("HTMLBox"), $html);
|
SetValue($this->ReadPropertyInteger("HTMLBox"), $html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"compatibility": {
|
"compatibility": {
|
||||||
"version": "7.1"
|
"version": "7.1"
|
||||||
},
|
},
|
||||||
"version": "1.023",
|
"version": "1.024",
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user