Skip to content

Epic: donation details admin page #7980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6254b25
Feature: Register new Donor Details page (#7935)
pauloiankoski May 29, 2025
789356c
Merge branch 'develop' into epic/donor-details-admin-page
glaubersilva Jun 2, 2025
583fc87
Feature: Add header and tabs to Donor Details page (#7936)
pauloiankoski Jun 3, 2025
0e62bbe
Feature: Donor profile - backend (#7939)
alaca Jun 3, 2025
86657ee
Feature: Add donor stats endpoint (#7938)
glaubersilva Jun 3, 2025
7ea2218
refactor: replace get_item_schema with get_public_item_schema
glaubersilva Jun 3, 2025
ccad658
Feature: Add Donor Profile tab with Personal Details section (#7954)
pauloiankoski Jun 4, 2025
a198621
Feature: add donor notes backend (#7944)
glaubersilva Jun 5, 2025
351a42a
Merge branch 'develop' into epic/donor-details-admin-page
glaubersilva Jun 5, 2025
df0a0af
Feature: Add Email Address section to Donor Details Profile (#7955)
pauloiankoski Jun 5, 2025
bd3ecc9
Feature: add donor to donation list filter (#7956)
jonwaldstein Jun 5, 2025
dfcc38b
New: Add donor address details functionality (#7962)
pauloiankoski Jun 7, 2025
c912cf4
Merge branch 'develop' into epic/donor-details-admin-page
jonwaldstein Jun 9, 2025
4719bf4
New: Add Custom Fields section to Donor Details page (#7964)
pauloiankoski Jun 9, 2025
00b5544
feature: add Donor Details page slot-fill system (#7967)
pauloiankoski Jun 10, 2025
3c16a2f
Fix: Update donor details SendEmailButton with a mailto link to Donor…
pauloiankoski Jun 10, 2025
5f37681
Feature: add donor overview layout & components (#7953)
JoshuaHungDinh Jun 10, 2025
94e9410
Refactor: update default donor detail url and preserve legacy view (#…
jonwaldstein Jun 10, 2025
66e3d1b
Merge branch 'develop' into epic/donor-details-admin-page
jonwaldstein Jun 11, 2025
32bc3fe
Feature: Private notes (#7959)
alaca Jun 11, 2025
f3be311
fix: empty conditional
Jun 11, 2025
b525a6c
Merge branch 'develop' into epic/donation-details-admin-page
jonwaldstein Jun 16, 2025
b35f3aa
New: Add page structure for donation details admin page (#7974)
pauloiankoski Jun 17, 2025
2e96334
Feature: Donation details overview backend (#7976)
alaca Jun 18, 2025
5dc5d13
chore: merge develop
Jun 19, 2025
45ec174
New: Implement Records tab on Donation Details page (#7984)
pauloiankoski Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
498 changes: 498 additions & 0 deletions src/API/REST/V3/Routes/Donations/DonationController.php

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions src/API/REST/V3/Routes/Donations/DonationStatisticsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

namespace Give\API\REST\V3\Routes\Donations;

use Give\API\REST\V3\Routes\Donations\ValueObjects\DonationRoute;
use Give\Donations\Models\Donation;
use WP_Error;
use WP_REST_Controller;
use WP_REST_Request;
use WP_REST_Response;
use WP_REST_Server;

/**
* @unreleased
*/
class DonationStatisticsController extends WP_REST_Controller
{
/**
* @unreleased
*/
public function __construct()
{
$this->namespace = DonationRoute::NAMESPACE;
$this->rest_base = DonationRoute::BASE;
}

/**
* @unreleased
*/
public function register_routes()
{
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P<donationId>[\d]+)/statistics', [
[
'methods' => WP_REST_Server::READABLE,
'callback' => [$this, 'get_item'],
'permission_callback' => [$this, 'get_item_permissions_check'],
'args' => [
'donationId' => [
'type' => 'integer',
'required' => true,
],
'mode' => [
'type' => 'string',
'default' => 'live',
'enum' => ['live', 'test'],
],
'campaignId' => [
'type' => 'integer',
'default' => 0,
],
],
],
]);
}

/**
* @unreleased
*/
public function get_item($request)
{
$donation = Donation::find($request->get_param('donationId'));
if ( ! $donation) {
return new WP_Error('donation_not_found', __('Donation not found', 'give'), ['status' => 404]);
}

$receipt = $donation->receipt();

$item = [
'donation' => [
'amount' => $donation->amount->formatToDecimal(),
'feeAmountRecovered' => $donation->feeAmountRecovered ? $donation->feeAmountRecovered->formatToDecimal() : 0,
'status' => $donation->status->getValue(),
'date' => $donation->createdAt->format('Y-m-d H:i:s'),
'paymentMethod' => $donation->gatewayId,
'mode' => $donation->mode->getValue(),
],
'donor' => [
'id' => $donation->donorId,
'name' => $donation->donor->name,
'email' => $donation->donor->email,
],
'campaign' => [
'id' => $donation->campaignId,
'title' => $donation->campaign->title,
],
'receipt' => [
'donationDetails' => $receipt->donationDetails->toArray(),
'subscriptionDetails' => $receipt->subscriptionDetails->toArray(),
'eventTicketsDetails' => $receipt->eventTicketsDetails->toArray(),
'additionalDetails' => $receipt->additionalDetails->toArray(),
],
];

$response = $this->prepare_item_for_response($item, $request);

return rest_ensure_response($response);
}

/**
* @unreleased
*
* @param WP_REST_Request $request
*
* @return bool
*/
public function get_item_permissions_check($request): bool
{
return current_user_can('view_give_reports');
}

/**
* @unreleased
*/
public function prepare_item_for_response($item, $request): WP_REST_Response
{
$self_url = rest_url(sprintf('%s/%s/%d/%s', $this->namespace, $this->rest_base,
$request->get_param('donationId'),
'statistics'));

$self_url = add_query_arg([
'mode' => $request->get_param('mode'),
'campaignId' => $request->get_param('campaignId'),
], $self_url);

$links = [
'self' => ['href' => $self_url],
];

$response = new WP_REST_Response($item);
$response->add_links($links);

return $response;
}
}
225 changes: 0 additions & 225 deletions src/API/REST/V3/Routes/Donations/RegisterDonationRoutes.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
* @since 4.0.0
*
* @method static DonationRoute NAMESPACE()
* @method static DonationRoute DONATION()
* @method static DonationRoute DONATIONS()
* @method static DonationRoute BASE()
* @method bool isNamespace()
* @method bool isDonation()
* @method bool isDonations()
* @method bool isBase()
*/
class DonationRoute extends Enum
{
const NAMESPACE = 'givewp/v3';
const DONATION = 'donations/(?P<id>[0-9]+)';
const DONATIONS = 'donations';
const BASE = 'donations';
}
Loading