PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
← All changes | src/API/REST/V3/Routes/Donations/DonationController.php +27 -2 4.16.3 → 4.17.0 View file →
@@ -164,8 +164,21 @@
164 164 'id' => [
165 165 'type' => 'integer',
166 166 'required' => true,
167 167 ],
168 + 'includeSensitiveData' => [
169 + 'type' => 'boolean',
170 + 'default' => false,
171 + ],
172 + 'anonymousDonations' => [
173 + 'type' => 'string',
174 + 'default' => 'exclude',
175 + 'enum' => [
176 + 'exclude',
177 + 'include',
178 + 'redact',
179 + ],
180 + ],
168 181 ],
169 182 ],
170 183 'schema' => [$this, 'get_public_item_schema'],
171 184 ]);
@@ -409,13 +422,25 @@
409 422 $handler = new PaymentRefundedHandler($command);
410 423 $handler->handle($donation);
411 424 }
412 425
413 - $response = $this->prepare_item_for_response($donation->toArray(), $request);
426 + $includeSensitiveData = $request->get_param('includeSensitiveData');
427 + $donationAnonymousMode = new DonationAnonymousMode($request->get_param('anonymousDonations'));
414 428
429 + $item = (new DonationViewModel($donation))
430 + ->includeSensitiveData($includeSensitiveData)
431 + ->anonymousMode($donationAnonymousMode)
432 + ->exports();
433 +
434 + $response = $this->prepare_item_for_response($item, $request);
435 +
415 436 return rest_ensure_response($response);
416 437 } catch (\Exception $exception) {
417 - return new WP_REST_Response(__('Failed to refund donation', 'give'), 500);
438 + return new WP_REST_Response([
439 + 'message' => __('Failed to refund donation', 'give'),
440 + 'error' => $exception->getMessage(),
441 + 'code' => $exception->getCode(),
442 + ], 500);
418 443 }
419 444 }
420 445
421 446 /**