← 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 | /** |