From bf2c6e90060ece0d9f7964f3e9a55ad49a89c165 Mon Sep 17 00:00:00 2001
From: Jamie McClelland <jm@mayfirst.org>
Date: Fri, 12 Mar 2021 14:07:41 -0500
Subject: [PATCH] properly avoid counting more than limit.

---
 api/v3/Stripe/Listevents.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/api/v3/Stripe/Listevents.php b/api/v3/Stripe/Listevents.php
index 8a896c56..166ad46b 100644
--- a/api/v3/Stripe/Listevents.php
+++ b/api/v3/Stripe/Listevents.php
@@ -358,8 +358,7 @@ function civicrm_api3_stripe_Listevents($params) {
     $out = [];
     $count = 0;
     foreach($data_list['data'] as $data) {
-      $count++;
-      if ($count > $limit) {
+      if ($count >= $limit) {
         break;
       }
       $item = [];
@@ -450,6 +449,7 @@ function civicrm_api3_stripe_Listevents($params) {
           }
         }
       }
+      $count++;
       $out[] = $item;
     }
   }
-- 
GitLab