From ba39872b9ec1f95c15a59d7eb5a7f2c31990c8ab Mon Sep 17 00:00:00 2001 From: schrom01 Date: Wed, 16 Aug 2023 18:31:46 +0200 Subject: [PATCH] removed not working donation functionality --- donations/donations.php | 82 ----------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 donations/donations.php diff --git a/donations/donations.php b/donations/donations.php deleted file mode 100644 index f59ae0c..0000000 --- a/donations/donations.php +++ /dev/null @@ -1,82 +0,0 @@ -query($sql); -$dolibarrAPIKey = $result->fetch_assoc()["value"]; - -$conn = getDatabaseConnection(); -$sql = "SELECT `value` FROM `dolibarrInformation` WHERE `information` = 'url'"; -$result = $conn->query($sql); -$dolibarrURL = $result->fetch_assoc()["value"]; - -$conn = getDatabaseConnection(); -$sql = "SELECT `value` FROM `dolibarrInformation` WHERE `information` = 'socid'"; -$result = $conn->query($sql); -$BusinesspartnerID = $result->fetch_assoc()["value"]; - -function createDonation($amount, $dolibarrURL, $dolibarrAPIKey, $BusinesspartnerID) { - $pulicNote = "Automatisch generiert von genderwatchprotocol"; - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $dolibarrURL."api/index.php/donations"); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"amount\": ".$amount.", \"date\": ".time().", \"socid\": ".$BusinesspartnerID.", \"note_public\": \"".$pulicNote."\"}"); - - $headers = array(); - $headers[] = 'Content-Type: application/json'; - $headers[] = 'Accept: application/json'; - $headers[] = 'Dolapikey: '.$dolibarrAPIKey; - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - - $result = curl_exec($ch); - if (curl_errno($ch)) { - echo 'Error:' . curl_error($ch); - } - curl_close($ch); - return $result; -} - -function validateDonation($donationID, $dolibarrURL, $dolibarrAPIKey) { - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $dolibarrURL."api/index.php/donations/".$donationID."/validate"); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, "{}"); - - $headers = array(); - $headers[] = 'Content-Type: application/json'; - $headers[] = 'Accept: application/json'; - $headers[] = 'Dolapikey: '.$dolibarrAPIKey; - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - - $result = curl_exec($ch); - if (curl_errno($ch)) { - echo 'Error:' . curl_error($ch); - } - curl_close($ch); - return $result; -} -function forwardToDonationPage($amount, $dolibarrURL, $dolibarrAPIKey, $BusinesspartnerID){ - echo "Sie werden weitergeleitet. Bitte um einen Moment Geduld..."; - $donationID = createDonation($amount, $dolibarrURL, $dolibarrAPIKey, $BusinesspartnerID); - validateDonation($donationID, $dolibarrURL, $dolibarrAPIKey); - $payment_link = $dolibarrURL."public/payment/newpayment.php?source=donation&ref=".($donationID)."&securekey=NSmKzZ73HW1zWO8nAlpdq95mDt77Q32o"; - header('Location: '.$payment_link); -} - -$amount = (float)($_GET["amount"]); -if(is_numeric($amount) && $amount > 0) { - forwardToDonationPage($amount, $dolibarrURL, $dolibarrAPIKey, $BusinesspartnerID); -} else { - $amount = (float)($_POST["amount"]); - if(is_numeric($amount) && $amount > 0) { - forwardToDonationPage($amount, $dolibarrURL, $dolibarrAPIKey, $BusinesspartnerID); - } else { - echo "invalid amount!"; - } -}