mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 02:21:55 -04:00
Add logic for accepting payments from soft credits marked as 'anonymous'
This commit is contained in:
parent
7b278da43a
commit
c9e5026cf4
2 changed files with 9 additions and 4 deletions
|
@ -64,12 +64,12 @@ class Payment{
|
||||||
if($this->UserId === null){
|
if($this->UserId === null){
|
||||||
// Check if we have to create a new `User` in the database.
|
// Check if we have to create a new `User` in the database.
|
||||||
|
|
||||||
// If the `User` isn't **null**, then check if we already have this user in our system.
|
// If the `User` isn't `null`, then check if we already have this `User` in our system.
|
||||||
if($this->User !== null && $this->User->Email !== null){
|
if($this->User !== null && $this->User->Email !== null){
|
||||||
try{
|
try{
|
||||||
$user = User::GetByEmail($this->User->Email);
|
$user = User::GetByEmail($this->User->Email);
|
||||||
|
|
||||||
// `User` exists, use their data
|
// `User` exists, use their data.
|
||||||
$user->Name = $this->User->Name;
|
$user->Name = $this->User->Name;
|
||||||
$this->User = $user;
|
$this->User = $user;
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ class Payment{
|
||||||
}
|
}
|
||||||
catch(Exceptions\UserNotFoundException){
|
catch(Exceptions\UserNotFoundException){
|
||||||
// User doesn't exist, create it now.
|
// User doesn't exist, create it now.
|
||||||
|
|
||||||
try{
|
try{
|
||||||
$this->User->Create();
|
$this->User->Create();
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,8 +153,14 @@ try{
|
||||||
$payment->IsMatchingDonation = true;
|
$payment->IsMatchingDonation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sometimes a soft credit is `Anonymous` or `Anonymous Anonymous`.
|
||||||
|
// See donation `7f296e18-6492-48e1-aeca-5063c6a0bbbb`.
|
||||||
|
if($hasSoftCredit && preg_match('/Anonymous(\s*Anonymous)*/ius', $payment->User->Name)){
|
||||||
|
$payment->User = null;
|
||||||
|
}
|
||||||
|
|
||||||
// We can get here via an AOGF donation that is anonymous.
|
// We can get here via an AOGF donation that is anonymous.
|
||||||
if(!$hasSoftCredit && ($payment->User->Email == 'Not provided' || $payment->User->Email == '')){
|
if(!$hasSoftCredit && ($payment->User?->Email == 'Not provided' || $payment->User?->Email == '')){
|
||||||
$payment->User = null;
|
$payment->User = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue