Bezahlmodul zum testen eingefühgt
This commit is contained in:
67
Belevo_Bezahl_Modul/README.md
Normal file
67
Belevo_Bezahl_Modul/README.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# Manager_1
|
||||||
|
Beschreibung des Moduls.
|
||||||
|
|
||||||
|
### Inhaltsverzeichnis
|
||||||
|
|
||||||
|
1. [Funktionsumfang](#1-funktionsumfang)
|
||||||
|
2. [Voraussetzungen](#2-voraussetzungen)
|
||||||
|
3. [Software-Installation](#3-software-installation)
|
||||||
|
4. [Einrichten der Instanzen in IP-Symcon](#4-einrichten-der-instanzen-in-ip-symcon)
|
||||||
|
5. [Statusvariablen und Profile](#5-statusvariablen-und-profile)
|
||||||
|
6. [WebFront](#6-webfront)
|
||||||
|
7. [PHP-Befehlsreferenz](#7-php-befehlsreferenz)
|
||||||
|
|
||||||
|
### 1. Funktionsumfang
|
||||||
|
|
||||||
|
*
|
||||||
|
|
||||||
|
### 2. Voraussetzungen
|
||||||
|
|
||||||
|
- IP-Symcon ab Version 7.1
|
||||||
|
|
||||||
|
### 3. Software-Installation
|
||||||
|
|
||||||
|
* Über den Module Store das 'Manager_1'-Modul installieren.
|
||||||
|
* Alternativ über das Module Control folgende URL hinzufügen
|
||||||
|
|
||||||
|
### 4. Einrichten der Instanzen in IP-Symcon
|
||||||
|
|
||||||
|
Unter 'Instanz hinzufügen' kann das 'Manager_1'-Modul mithilfe des Schnellfilters gefunden werden.
|
||||||
|
- Weitere Informationen zum Hinzufügen von Instanzen in der [Dokumentation der Instanzen](https://www.symcon.de/service/dokumentation/konzepte/instanzen/#Instanz_hinzufügen)
|
||||||
|
|
||||||
|
__Konfigurationsseite__:
|
||||||
|
|
||||||
|
Name | Beschreibung
|
||||||
|
-------- | ------------------
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
||||||
|
### 5. Statusvariablen und Profile
|
||||||
|
|
||||||
|
Die Statusvariablen/Kategorien werden automatisch angelegt. Das Löschen einzelner kann zu Fehlfunktionen führen.
|
||||||
|
|
||||||
|
#### Statusvariablen
|
||||||
|
|
||||||
|
Name | Typ | Beschreibung
|
||||||
|
------ | ------- | ------------
|
||||||
|
| |
|
||||||
|
| |
|
||||||
|
|
||||||
|
#### Profile
|
||||||
|
|
||||||
|
Name | Typ
|
||||||
|
------ | -------
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
||||||
|
### 6. WebFront
|
||||||
|
|
||||||
|
Die Funktionalität, die das Modul im WebFront bietet.
|
||||||
|
|
||||||
|
### 7. PHP-Befehlsreferenz
|
||||||
|
|
||||||
|
`boolean GEF_BeispielFunktion(integer $InstanzID);`
|
||||||
|
Erklärung der Funktion.
|
||||||
|
|
||||||
|
Beispiel:
|
||||||
|
`GEF_BeispielFunktion(12345);`
|
||||||
5
Belevo_Bezahl_Modul/form.json
Normal file
5
Belevo_Bezahl_Modul/form.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"elements":[
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
12
Belevo_Bezahl_Modul/module.json
Normal file
12
Belevo_Bezahl_Modul/module.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"id": "{466A36DA-3C90-06E8-1D57-161D921B45EE}",
|
||||||
|
"name": "Belevo_Bezahl_Modul",
|
||||||
|
"type": 3,
|
||||||
|
"vendor": "Belevo AG",
|
||||||
|
"aliases": [],
|
||||||
|
"parentRequirements": [],
|
||||||
|
"childRequirements": [],
|
||||||
|
"implemented": [],
|
||||||
|
"prefix": "GEF",
|
||||||
|
"url": ""
|
||||||
|
}
|
||||||
112
Belevo_Bezahl_Modul/module.php
Normal file
112
Belevo_Bezahl_Modul/module.php
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
class Belevo_Bezahl_Modul extends IPSModule
|
||||||
|
{
|
||||||
|
public function Create()
|
||||||
|
{
|
||||||
|
// Die Standard-Create() Methode aufrufen
|
||||||
|
parent::Create();
|
||||||
|
$this->RegisterVariableBoolean("Reservate", "Reservate", '', false);
|
||||||
|
$this->RegisterVariableInteger("ReservationAmount", "ReservationAmount", '', 0);
|
||||||
|
$this->RegisterVariableBoolean("AmountIsReserved", "AmountIsReserved", '', false);
|
||||||
|
$this->RegisterVariableBoolean("Get", "Get", '', false);
|
||||||
|
$this->RegisterVariableInteger("GetAmount", "GetAmount", '', 0);
|
||||||
|
|
||||||
|
// Event-Handler registrieren
|
||||||
|
$this->RegisterMessage($this->GetIDForIdent("Reservate"), VM_UPDATE);
|
||||||
|
$this->RegisterMessage($this->GetIDForIdent("Get"), VM_UPDATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function ApplyChanges()
|
||||||
|
{
|
||||||
|
parent::ApplyChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function MessageSink($TimeStamp, $SenderID, $Message, $Data)
|
||||||
|
{
|
||||||
|
switch ($SenderID) {
|
||||||
|
case $this->GetIDForIdent("Reservate"):
|
||||||
|
if (GetValueBoolean($this->GetIDForIdent("Reservate"))) {
|
||||||
|
$this->ReservateAmount(GetValueInteger($this->GetIDForIdent("ReservationAmount")));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case $this->GetIDForIdent("Get"):
|
||||||
|
if (GetValueBoolean($this->GetIDForIdent("Get"))) {
|
||||||
|
$this->GetAmount(GetValueInteger($this->GetIDForIdent("GetAmount")));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ReservateAmount($amount)
|
||||||
|
{
|
||||||
|
// Beispiel-Logik zur Reservierung des Betrags bei Wallee
|
||||||
|
$apiUrl = "https://api.wallee.com/transaction/create";
|
||||||
|
$apiKey = "DEIN_API_KEY"; // Ersetze dies durch deinen tatsächlichen API-Schlüssel
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
"amount" => $amount,
|
||||||
|
"currency" => "CHF", // Ersetze dies durch die gewünschte Währung
|
||||||
|
"paymentMethod" => "creditcard" // Beispiel: Kreditkarte
|
||||||
|
];
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
'http' => [
|
||||||
|
'header' => "Content-type: application/json\r\nAuthorization: Bearer $apiKey\r\n",
|
||||||
|
'method' => 'POST',
|
||||||
|
'content' => json_encode($data),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$context = stream_context_create($options);
|
||||||
|
$result = file_get_contents($apiUrl, false, $context);
|
||||||
|
|
||||||
|
if ($result === FALSE) {
|
||||||
|
echo "Reservierung fehlgeschlagen.";
|
||||||
|
} else {
|
||||||
|
$response = json_decode($result, true);
|
||||||
|
if ($response['success']) {
|
||||||
|
SetValueBoolean($this->GetIDForIdent("AmountIsReserved"), true);
|
||||||
|
} else {
|
||||||
|
echo "Reservierung fehlgeschlagen: " . $response['message'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function GetAmount($amount)
|
||||||
|
{
|
||||||
|
// Beispiel-Logik zum Abziehen des Betrags bei Wallee
|
||||||
|
$apiUrl = "https://api.wallee.com/transaction/charge";
|
||||||
|
$apiKey = "DEIN_API_KEY"; // Ersetze dies durch deinen tatsächlichen API-Schlüssel
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
"amount" => $amount,
|
||||||
|
"currency" => "CHF", // Ersetze dies durch die gewünschte Währung
|
||||||
|
"paymentMethod" => "creditcard" // Beispiel: Kreditkarte
|
||||||
|
];
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
'http' => [
|
||||||
|
'header' => "Content-type: application/json\r\nAuthorization: Bearer $apiKey\r\n",
|
||||||
|
'method' => 'POST',
|
||||||
|
'content' => json_encode($data),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$context = stream_context_create($options);
|
||||||
|
$result = file_get_contents($apiUrl, false, $context);
|
||||||
|
|
||||||
|
if ($result === FALSE) {
|
||||||
|
echo "Abzug fehlgeschlagen.";
|
||||||
|
} else {
|
||||||
|
$response = json_decode($result, true);
|
||||||
|
if ($response['success']) {
|
||||||
|
SetValueBoolean($this->GetIDForIdent("Reservate"), false);
|
||||||
|
SetValueBoolean($this->GetIDForIdent("AmountIsReserved"), false);
|
||||||
|
SetValueBoolean($this->GetIDForIdent("Get"), false);
|
||||||
|
} else {
|
||||||
|
echo "Abzug fehlgeschlagen: " . $response['message'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user