Skip to content

Commit

Permalink
Merge branch 'fix/prevents-donations-trash-forms' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
angelablake committed Sep 18, 2023
2 parents 069a2e2 + f526a5c commit 9c4a443
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion give.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private function setup_constants()
{
// Plugin version.
if (!defined('GIVE_VERSION')) {
define('GIVE_VERSION', '3.0.0');
define('GIVE_VERSION', '2.33.1');
}

// Plugin Root File.
Expand Down
3 changes: 0 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri
8. GiveWP has a dedicated support team to help answer any questions you may have and help you through stumbling blocks.

== Changelog ==
= 3.0.0: August 15th, 2023 =
* New: GiveWP 3.0 is here! This is a major release that includes a new visual form builder and many more. Read more about it [on our website](https://go.givewp.com/corenextgen).

= 2.33.1: August 31st, 2023 =
* Security: The donor default user role has been sanitized to prevent privilege escalation

Expand Down
2 changes: 1 addition & 1 deletion src/DonationForms/V2/ValueObjects/DonationFormStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @method bool isPublished()
* @method bool isPrivate()
* @method bool isDraft()
* @method bool isTrashed()
* @method bool isTrash()
* @method bool isUpgraded()
*/
class DonationFormStatus extends Enum
Expand Down
25 changes: 25 additions & 0 deletions src/LegacyPaymentGateways/Adapters/LegacyPaymentGatewayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Give\LegacyPaymentGateways\Adapters;

use Exception;
use Give\DonationForms\V2\Models\DonationForm;
use Give\Donations\Models\Donation;
use Give\Donations\ValueObjects\DonationType;
use Give\Donors\Models\Donor;
Expand Down Expand Up @@ -62,6 +63,9 @@ public function handleBeforeGateway(array $legacyDonationData, PaymentGateway $r
$formData = FormData::fromRequest($legacyDonationData);

$this->validateGatewayNonce($formData->gatewayNonce);

$this->validateDonationFormStatus($formData->formId);

$donor = $this->getOrCreateDonor(
$formData->donorInfo->wpUserId,
$formData->donorInfo->email,
Expand Down Expand Up @@ -234,6 +238,27 @@ private function validateGatewayNonce(string $gatewayNonce)
}
}

/**
* Validate Donation Form Status
*
* @since 2.33.2
*/
private function validateDonationFormStatus(int $formId)
{
$donationForm = DonationForm::find($formId);

if (!$donationForm || $donationForm->status->isTrash()) {
wp_die(
esc_html__(
'This donation form is not accepting donations.',
'give'
),
esc_html__('Error', 'give'),
['response' => 403]
);
}
}

/**
* Set donation id to purchase session for use in the donation receipt.
*
Expand Down

0 comments on commit 9c4a443

Please sign in to comment.