genderwatchprotocol/donations/donations.php

39 lines
1.3 KiB
PHP
Raw Normal View History

2023-02-16 14:25:14 +01:00
<?php
function createDonation($amount) {
2023-02-16 14:45:36 +01:00
$dolibarrURL = "https://dolibarr.romanschenk.ch/api/index.php/donations";
$BusinesspartnerID = "220";
2023-02-16 14:52:26 +01:00
$pulicNote = "Automatisch generiert von genderwatchprotocol.com";
2023-02-16 14:25:14 +01:00
$ch = curl_init();
2023-02-16 14:45:36 +01:00
curl_setopt($ch, CURLOPT_URL, $dolibarrURL);
2023-02-16 14:25:14 +01:00
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
2023-02-16 15:02:46 +01:00
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"amount\": ".$amount.", \"date\": 1676545200, \"socid\": ".$BusinesspartnerID."}");
2023-02-16 14:25:14 +01:00
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Accept: application/json';
$headers[] = 'Dolapikey: 4mQX4x4x65MlkGZ9HUD5A4oElqTn92kl';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
2023-02-16 14:27:36 +01:00
return $result;
2023-02-16 14:25:14 +01:00
}
2023-02-16 14:36:53 +01:00
function forwardToDonationPage($amount){
$payment_link = "https://dolibarr.romanschenk.ch/public/payment/newpayment.php?source=donation&ref=".(createDonation($amount))."&securekey=NSmKzZ73HW1zWO8nAlpdq95mDt77Q32o";
header('Location: '.$payment_link);
}
$amount = (float)($_GET["amount"]);
2023-02-16 14:38:15 +01:00
if(is_numeric($amount) && $amount > 0) {
2023-02-16 14:36:53 +01:00
forwardToDonationPage($amount);
} else {
echo "invalid amount!";
}