Skip to content

Commit

Permalink
Merge branch 'develop' into fix/totals-shortcode-reference-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaHungDinh authored Oct 30, 2023
2 parents 8436a86 + 9fe1ad3 commit 2ad6abe
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 40 deletions.
4 changes: 2 additions & 2 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: The most robust, flexible, and intuitive way to accept donations on WordPress.
* Author: GiveWP
* Author URI: https://givewp.com/
* Version: 3.0.3
* Version: 3.0.4
* Requires at least: 6.0
* Requires PHP: 7.2
* Text Domain: give
Expand Down Expand Up @@ -391,7 +391,7 @@ private function setup_constants()
{
// Plugin version.
if (!defined('GIVE_VERSION')) {
define('GIVE_VERSION', '3.0.3');
define('GIVE_VERSION', '3.0.4');
}

// Plugin Root File.
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: donation, donate, recurring donations, fundraising, crowdfunding
Requires at least: 6.0
Tested up to: 6.4
Requires PHP: 7.2
Stable tag: 3.0.3
Stable tag: 3.0.4
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -262,6 +262,9 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri
10. Use almost any payment gateway integration with GiveWP through our add-ons or by creating your own add-on.

== Changelog ==
= 3.0.4: October 30th, 2023 =
* Fix: Resolved issue with some Stripe gateways not recording incoming recurring donation renewals. To recover missing renewals from Stripe in GiveWP, please use the "Sync Subscription" button on the individual subscription details page. Click [here](https://docs.givewp.com/syncrecurring) to learn more about syncing subscriptions in GiveWP.

= 3.0.3: October 20th, 2023 =
* Fix: Using the multi-form shortcode with the ids attribute no longer causes a fatal error
* Fix: Forms no longer have fatal errors on Elementor websites when the Display Content option is enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ChargeRefunded
*
* @see https://stripe.com/docs/api/events/types#event_types-charge.refunded
*
* @since 3.0.4 Add exit statement only when the event is successfully processed.
* @since 3.0.0
*
* @return void
Expand All @@ -30,28 +31,29 @@ class ChargeRefunded
public function __invoke(Event $event)
{
try {
$this->processEvent($event);
if ($this->processEvent($event)) {
exit;
}
} catch (Exception $exception) {
$this->logWebhookError($event, $exception);
}

exit;
}

/**
* @since 3.0.4 Return a bool value.
* @since 3.0.0
*
* @throws Exception
*/
public function processEvent(Event $event)
public function processEvent(Event $event): bool
{
/* @var Charge $stripeCharge */
$stripeCharge = $event->data->object;

$donation = give()->donations->getByGatewayTransactionId($stripeCharge->payment_intent);

if (!$donation || !$this->shouldProcessDonation($donation)) {
return;
return false;
}

if ($stripeCharge->refunded && !$donation->status->isRefunded()) {
Expand All @@ -63,5 +65,7 @@ public function processEvent(Event $event)
'content' => __('Payment refunded in Stripe.', 'give'),
]);
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CustomerSubscriptionCreated
*
* @see https://stripe.com/docs/api/events/types#event_types-customer.subscription.created
*
* @since 3.0.4 Add exit statement only when the event is successfully processed.
* @since 3.0.0
*
* @return void
Expand All @@ -28,18 +29,19 @@ class CustomerSubscriptionCreated
public function __invoke(Event $event)
{
try {
$this->processEvent($event);
if ($this->processEvent($event)) {
exit;
}
} catch (Exception $exception) {
$this->logWebhookError($event, $exception);
}

exit;
}

/**
* @since 3.0.4 Return a bool value.
* @since 3.0.0
*/
public function processEvent(Event $event)
public function processEvent(Event $event): bool
{
/* @var StripeSubscription $stripeSubscription */
$stripeSubscription = $event->data->object;
Expand All @@ -48,11 +50,11 @@ public function processEvent(Event $event)

// only use this for next gen for now
if (!$subscription || !$this->shouldProcessSubscription($subscription)) {
return;
return false;
}

// exit early to prevent legacy webhook
// we don't need to do anything here at the moment because the subscription is already created & active
exit;
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CustomerSubscriptionDeleted
*
* @see https://stripe.com/docs/api/events/types#event_types-customer.subscription.deleted
*
* @since 3.0.4 Add exit statement only when the event is successfully processed.
* @since 3.0.0
*
* @return void
Expand All @@ -29,19 +30,20 @@ class CustomerSubscriptionDeleted
public function __invoke(Event $event)
{
try {
$this->processEvent($event);
if ($this->processEvent($event)) {
exit;
}
} catch (Exception $exception) {
$this->logWebhookError($event, $exception);
}

exit;
}

/**
* @since 3.0.4 Return a bool value.
* @since 3.0.0
* @throws Exception
*/
public function processEvent(Event $event)
public function processEvent(Event $event): bool
{
/* @var StripeSubscription $stripeSubscription */
$stripeSubscription = $event->data->object;
Expand All @@ -50,12 +52,14 @@ public function processEvent(Event $event)

// only use this for next gen for now
if (!$subscription || !$this->shouldProcessSubscription($subscription)) {
return;
return false;
}

if (!$subscription->status->isCancelled() && !$subscription->status->isCompleted()) {
$subscription->status = SubscriptionStatus::COMPLETED();
$subscription->save();
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class InvoicePaymentFailed
*
* @see https://stripe.com/docs/api/events/types#event_types-invoice.payment_failed
*
* @since 3.0.4 Add exit statement only when the event is successfully processed.
* @since 3.0.0
*
* @return void
Expand All @@ -29,20 +30,21 @@ class InvoicePaymentFailed
public function __invoke(Event $event)
{
try {
$this->processEvent($event);
if ($this->processEvent($event)) {
exit;
}
} catch (Exception $exception) {
$this->logWebhookError($event, $exception);
}

exit;
}

/**
* @since 3.0.4 Return a bool value.
* @since 3.0.0
*
* @throws Exception
*/
public function processEvent(Event $event)
public function processEvent(Event $event): bool
{
/* @var Invoice $invoice */
$invoice = $event->data->object;
Expand All @@ -51,7 +53,7 @@ public function processEvent(Event $event)

// only use this for next gen for now
if (!$subscription || !$this->shouldProcessSubscription($subscription)) {
return;
return false;
}

if (
Expand All @@ -64,6 +66,8 @@ public function processEvent(Event $event)
$subscription->status = SubscriptionStatus::FAILING();
$subscription->save();
}

return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,28 @@ class InvoicePaymentSucceeded
*
* @see https://stripe.com/docs/api/events/types#event_types-invoice.payment_succeeded
*
* @since 3.0.4 Add exit statement only when the event is successfully processed.
* @since 3.0.0
*
* @return void
* @throws \Exception
*/
public function __invoke(Event $event)
{
try {
$this->processEvent($event);
if ($this->processEvent($event)) {
exit;
}
} catch (Exception $exception) {
$this->logWebhookError($event, $exception);
}

exit;
}

/**
* @since 3.0.4 Return a bool value.
* @since 3.0.0
* @throws \Exception
*/
public function processEvent(Event $event)
public function processEvent(Event $event): bool
{
/* @var Invoice $invoice */
$invoice = $event->data->object;
Expand All @@ -54,7 +55,7 @@ public function processEvent(Event $event)

// only use this for next gen for now
if (!$subscription || !$this->shouldProcessSubscription($subscription)) {
return;
return false;
}

if ($initialDonation = give()->donations->getByGatewayTransactionId($invoice->payment_intent)) {
Expand All @@ -71,6 +72,8 @@ public function processEvent(Event $event)
$subscriptionModel->handleSubscriptionCompleted();
}
}

return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PaymentIntentPaymentFailed
*
* @see https://stripe.com/docs/api/events/types#event_types-payment_intent.payment_failed
*
* @since 3.0.4 Add exit statement only when the event is successfully processed.
* @since 3.0.0
*
* @return void
Expand All @@ -30,26 +31,27 @@ class PaymentIntentPaymentFailed
public function __invoke(Event $event)
{
try {
$this->processEvent($event);
if ($this->processEvent($event)) {
exit;
}
} catch (Exception $exception) {
$this->logWebhookError($event, $exception);
}

exit;
}

/**
* @since 3.0.4 Return a bool value.
* @since 3.0.0
*/
public function processEvent(Event $event)
public function processEvent(Event $event): bool
{
/* @var PaymentIntent $paymentIntent */
$paymentIntent = $event->data->object;

$donation = give()->donations->getByGatewayTransactionId($paymentIntent->id);

if (!$donation || !$this->shouldProcessDonation($donation)) {
return;
return false;
}

if ($donation->type->isSingle() && !$donation->status->isFailed()) {
Expand All @@ -61,5 +63,7 @@ public function processEvent(Event $event)
'content' => __('Payment failed in Stripe.', 'give'),
]);
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PaymentIntentSucceeded
*
* @see https://stripe.com/docs/api/events/types#event_types-invoice.payment_succeeded
*
* @since 3.0.4 Add exit statement only when the event is successfully processed.
* @since 3.0.0
*
* @return void
Expand All @@ -30,26 +31,27 @@ class PaymentIntentSucceeded
public function __invoke(Event $event)
{
try {
$this->processEvent($event);
if ($this->processEvent($event)) {
exit;
}
} catch (Exception $exception) {
$this->logWebhookError($event, $exception);
}

exit;
}

/**
* @since 3.0.4 Return a bool value.
* @since 3.0.0
*/
public function processEvent(Event $event)
public function processEvent(Event $event): bool
{
/* @var PaymentIntent $paymentIntent */
$paymentIntent = $event->data->object;

$donation = give()->donations->getByGatewayTransactionId($paymentIntent->id);

if (!$donation || !$this->shouldProcessDonation($donation)) {
return;
return false;
}

if ($donation->type->isSingle() && !$donation->status->isComplete()) {
Expand All @@ -61,5 +63,7 @@ public function processEvent(Event $event)
'content' => __('Payment succeeded in Stripe.', 'give'),
]);
}

return true;
}
}

0 comments on commit 2ad6abe

Please sign in to comment.