diff --git a/lib/Payment.php b/lib/Payment.php index 7ff9e87c..00309d38 100644 --- a/lib/Payment.php +++ b/lib/Payment.php @@ -13,6 +13,7 @@ class Payment extends PropertiesBase{ public $Amount; public $Fee; public $IsRecurring; + public $IsMatchingDonation = false; // ******* @@ -50,15 +51,16 @@ class Payment extends PropertiesBase{ try{ Db::Query(' - INSERT into Payments (UserId, Created, ChannelId, TransactionId, Amount, Fee, IsRecurring) + INSERT into Payments (UserId, Created, ChannelId, TransactionId, Amount, Fee, IsRecurring, IsMatchingDonation) values(?, ?, ?, ?, ?, ?, + ?, ?) - ', [$this->UserId, $this->Created, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring]); + ', [$this->UserId, $this->Created, $this->ChannelId, $this->TransactionId, $this->Amount, $this->Fee, $this->IsRecurring, $this->IsMatchingDonation]); } catch(PDOException $ex){ if($ex->errorInfo[1] == 1062){ diff --git a/scripts/process-pending-payments b/scripts/process-pending-payments index b8702c75..65eade8e 100755 --- a/scripts/process-pending-payments +++ b/scripts/process-pending-payments @@ -133,6 +133,13 @@ try{ $payment->User->Email = trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Email"]]'))->getText()); } + // These donations are typically (always?) employer matches. + // FA does not provide a way to connect the original donation with the employer match. + // Example bbf87b83-d341-426f-b6c9-9091e3222e57 + if($payment->User->Name == 'American Online Giving Foundation'){ + $payment->IsMatchingDonation = true; + } + // We can get here via an AOGF donation that is anonymous if($payment->User->Email == 'Not provided' || $payment->User->Email == ''){ $payment->User = null; @@ -150,7 +157,7 @@ try{ $payment->Fee = floatval(str_replace('$', '', trim($detailsRow->findElement(WebDriverBy::xpath('//td[preceding-sibling::td[normalize-space(.) = "Fee"]]'))->getText()))); // We might also get a case where the donation is on behalf of a company match, but there's not really a way to distinguish that. Do a rough check. - // See donation #00b60a22-eafa-44cb-9850-54bef9763e8d + // See donation 00b60a22-eafa-44cb-9850-54bef9763e8d if($payment->User !== null && preg_match('/\b(L\.?L\.?C\.?|Foundation|President|Fund|Charitable)\b/ius', $payment->User->Name)){ $payment->User = null; } @@ -166,7 +173,23 @@ try{ } // Does this payment put us in the Patrons Circle? - if(($payment->IsRecurring && $payment->Amount >= 10 && $payment->Created >= $lastMonth) || (!$payment->IsRecurring && $payment->Amount >= 100 && $payment->Created >= $lastYear)){ + if( + ( + $payment->IsRecurring + && + $payment->Amount >= 10 + && + $payment->Created >= $lastMonth + ) + || + ( + !$payment->IsRecurring + && + $payment->Amount >= 100 + && + $payment->Created >= $lastYear + ) + ){ // This payment is eligible for the Patrons Circle! if($payment->User !== null){ // Are we already a patron? @@ -195,7 +218,7 @@ try{ $patron->Create(); } } - elseif(!$payment->IsRecurring){ + elseif(!$payment->IsRecurring && !$payment->IsMatchingDonation){ // Fully-anonymous, non-recurring donation eligible for the Patrons Circle. We can't notify them, but do notify the admins. $patron = new Patron(); $patron->User = new User(); diff --git a/www/about/index.php b/www/about/index.php index a847689a..bd138e60 100644 --- a/www/about/index.php +++ b/www/about/index.php @@ -22,6 +22,7 @@ $anonymousPatronCount = Db::QueryInt(' ( select count(*) cnt from Payments where UserId is null + and IsMatchingDonation = false and ( (IsRecurring = true and Amount >= 10 and Created >= utc_timestamp() - interval 30 day) @@ -32,7 +33,8 @@ $anonymousPatronCount = Db::QueryInt(' ( select count(*) as cnt from Patrons where IsAnonymous = true - and Ended is null ) ) x + and Ended is null ) + ) x '); ?> 'About Standard Ebooks', 'highlight' => 'about', 'description' => 'Standard Ebooks is a volunteer-driven effort to produce a collection of high quality, carefully formatted, accessible, open source, and free public domain ebooks that meet or exceed the quality of commercially produced ebooks. The text and cover art in our ebooks is already believed to be in the public domain, and Standard Ebook dedicates its own work to the public domain, thus releasing the entirety of each ebook file into the public domain.']) ?>