parent
ec71770847
commit
f0a1149558
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
$dolibarrURL = "https://dolibarr.romanschenk.ch/";
|
$dolibarrURL = "https://dolibarr.romanschenk.ch/";
|
||||||
function createDonation($amount, $dolibarrURL) {
|
$dolibarrAPIKey = "4mQX4x4x65MlkGZ9HUD5A4oElqTn92kl";
|
||||||
|
function createDonation($amount, $dolibarrURL, $dolibarrAPIKey) {
|
||||||
$BusinesspartnerID = "220";
|
$BusinesspartnerID = "220";
|
||||||
$pulicNote = "Automatisch generiert von genderwatchprotocol.com";
|
$pulicNote = "Automatisch generiert von genderwatchprotocol.com";
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
@ -13,7 +14,7 @@ function createDonation($amount, $dolibarrURL) {
|
||||||
$headers = array();
|
$headers = array();
|
||||||
$headers[] = 'Content-Type: application/json';
|
$headers[] = 'Content-Type: application/json';
|
||||||
$headers[] = 'Accept: application/json';
|
$headers[] = 'Accept: application/json';
|
||||||
$headers[] = 'Dolapikey: 4mQX4x4x65MlkGZ9HUD5A4oElqTn92kl';
|
$headers[] = 'Dolapikey: '.$dolibarrAPIKey;
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
|
@ -24,7 +25,7 @@ function createDonation($amount, $dolibarrURL) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateDonation($donationID, $dolibarrURL) {
|
function validateDonation($donationID, $dolibarrURL, $dolibarrAPIKey) {
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_URL, $dolibarrURL."api/index.php/donations/".$donationID."/validate");
|
curl_setopt($ch, CURLOPT_URL, $dolibarrURL."api/index.php/donations/".$donationID."/validate");
|
||||||
|
@ -35,7 +36,7 @@ function validateDonation($donationID, $dolibarrURL) {
|
||||||
$headers = array();
|
$headers = array();
|
||||||
$headers[] = 'Content-Type: application/json';
|
$headers[] = 'Content-Type: application/json';
|
||||||
$headers[] = 'Accept: application/json';
|
$headers[] = 'Accept: application/json';
|
||||||
$headers[] = 'Dolapikey: 4mQX4x4x65MlkGZ9HUD5A4oElqTn92kl';
|
$headers[] = 'Dolapikey: '.$dolibarrAPIKey;
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
|
@ -45,20 +46,20 @@ function validateDonation($donationID, $dolibarrURL) {
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
function forwardToDonationPage($amount, $dolibarrURL){
|
function forwardToDonationPage($amount, $dolibarrURL, $dolibarrAPIKey){
|
||||||
$donationID = createDonation($amount, $dolibarrURL);
|
$donationID = createDonation($amount, $dolibarrURL, $dolibarrAPIKey);
|
||||||
validateDonation($donationID, $dolibarrURL);
|
validateDonation($donationID, $dolibarrURL, $dolibarrAPIKey);
|
||||||
$payment_link = $dolibarrURL."public/payment/newpayment.php?source=donation&ref=".($donationID)."&securekey=NSmKzZ73HW1zWO8nAlpdq95mDt77Q32o";
|
$payment_link = $dolibarrURL."public/payment/newpayment.php?source=donation&ref=".($donationID)."&securekey=NSmKzZ73HW1zWO8nAlpdq95mDt77Q32o";
|
||||||
header('Location: '.$payment_link);
|
header('Location: '.$payment_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
$amount = (float)($_GET["amount"]);
|
$amount = (float)($_GET["amount"]);
|
||||||
if(is_numeric($amount) && $amount > 0) {
|
if(is_numeric($amount) && $amount > 0) {
|
||||||
forwardToDonationPage($amount, $dolibarrURL);
|
forwardToDonationPage($amount, $dolibarrURL, $dolibarrAPIKey);
|
||||||
} else {
|
} else {
|
||||||
$amount = (float)($_POST["amount"]);
|
$amount = (float)($_POST["amount"]);
|
||||||
if(is_numeric($amount) && $amount > 0) {
|
if(is_numeric($amount) && $amount > 0) {
|
||||||
forwardToDonationPage($amount, $dolibarrURL);
|
forwardToDonationPage($amount, $dolibarrURL, $dolibarrAPIKey);
|
||||||
} else {
|
} else {
|
||||||
echo "invalid amount!";
|
echo "invalid amount!";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue