mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 01:22:23 -04:00
Update user in database if they exist when processing a payment
This commit is contained in:
parent
de9e8161ce
commit
727e1af67d
2 changed files with 9 additions and 15 deletions
|
@ -25,16 +25,19 @@ class Payment extends PropertiesBase{
|
|||
|
||||
// If the User object isn't null, then check if we already have this user in our system
|
||||
if($this->User !== null && $this->User->Email !== null){
|
||||
$result = Db::Query('SELECT * from Users where Email = ?', [$this->User->Email], 'User');
|
||||
try{
|
||||
$user = User::GetByEmail($this->User->Email);
|
||||
|
||||
if(sizeof($result) == 0){
|
||||
// User exists, use their data
|
||||
$this->User = $user;
|
||||
|
||||
// Update their name in case we have their email (but not name) recorded from a newsletter subscription
|
||||
Db::Query('UPDATE Users set Name = ? where UserId = ?', [$this->User->Name, $this->User->UserId]);
|
||||
}
|
||||
catch(Exceptions\InvalidUserException $ex){
|
||||
// User doesn't exist, create it now
|
||||
$this->User->Create();
|
||||
}
|
||||
else{
|
||||
// User exists, use their data
|
||||
$this->User = $result[0];
|
||||
}
|
||||
|
||||
$this->UserId = $this->User->UserId;
|
||||
}
|
||||
|
|
|
@ -50,15 +50,6 @@ $pendingPayments = Db::Query('start transaction;
|
|||
update PendingPayments set ProcessedOn = utc_timestamp() where ProcessedOn is null;
|
||||
commit;');
|
||||
|
||||
// $pendingPayments = [];
|
||||
// $csv = array_map( 'str_getcsv', file( '/home/alex/donations.csv') );
|
||||
// foreach($csv as $row){
|
||||
// $obj = new stdClass();
|
||||
// $obj->TransactionId = $row[0];
|
||||
// $obj->ChannelId = PAYMENT_CHANNEL_FA;
|
||||
// $pendingPayments[] = $obj;
|
||||
// }
|
||||
|
||||
if(sizeof($pendingPayments) == 0){
|
||||
// Don't start the very slow Selenium driver if we have nothing to process
|
||||
exit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue