Procházet zdrojové kódy

added another api endpoint for donation to response from GET api/v2/homepage/donate/{amount}

CauseFX před 4 roky
rodič
revize
da8cdc5f96
1 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 11 0
      api/v2/routes/homepage.php

+ 11 - 0
api/v2/routes/homepage.php

@@ -552,6 +552,17 @@ $app->get('/homepage/donate', function ($request, $response, $args) {
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
 });
+$app->get('/homepage/donate/[{amount}]', function ($request, $response, $args) {
+	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
+	$amount = $args['amount'] ?: $Organizr->config['homepageDonateMinimum'] / 100;
+	$amount = (int)$amount;
+	$amount = ($amount > 0) ? $amount : $Organizr->config['homepageDonateMinimum'] / 100;
+	$Organizr->homepageDonateCreateSession($amount);
+	$response->getBody()->write(jsonE($GLOBALS['api']));
+	return $response
+		->withHeader('Content-Type', 'application/json;charset=UTF-8')
+		->withStatus($GLOBALS['responseCode']);
+});
 $app->post('/homepage/donate', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
 	$amount = $_GET['amount'] ?? 1000;