mirror of
https://github.com/standardebooks/web.git
synced 2025-07-14 10:31:59 -04:00
Show payments on user detail page
This commit is contained in:
parent
560b53c2a8
commit
9835e5cee0
3 changed files with 135 additions and 1 deletions
|
@ -3,6 +3,7 @@ use Safe\DateTimeImmutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property ?User $User
|
* @property ?User $User
|
||||||
|
* @property string $ProcessorUrl
|
||||||
*/
|
*/
|
||||||
class Payment{
|
class Payment{
|
||||||
use Traits\Accessor;
|
use Traits\Accessor;
|
||||||
|
@ -18,6 +19,7 @@ class Payment{
|
||||||
public bool $IsMatchingDonation = false;
|
public bool $IsMatchingDonation = false;
|
||||||
|
|
||||||
protected ?User $_User = null;
|
protected ?User $_User = null;
|
||||||
|
protected string $_ProcessorUrl;
|
||||||
|
|
||||||
|
|
||||||
// *******
|
// *******
|
||||||
|
@ -28,13 +30,28 @@ class Payment{
|
||||||
* @throws Exceptions\UserNotFoundException
|
* @throws Exceptions\UserNotFoundException
|
||||||
*/
|
*/
|
||||||
protected function GetUser(): ?User{
|
protected function GetUser(): ?User{
|
||||||
if($this->_User === null && $this->UserId !== null){
|
if(!isset($this->_User) && $this->UserId !== null){
|
||||||
$this->_User = User::Get($this->UserId);
|
$this->_User = User::Get($this->UserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_User;
|
return $this->_User;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function GetProcessorUrl(): string{
|
||||||
|
if(!isset($this->_ProcessorUrl)){
|
||||||
|
switch($this->Processor){
|
||||||
|
case Enums\PaymentProcessorType::FracturedAtlas:
|
||||||
|
// This is not a permalink per se, because the FA permalink shows us the donor-facing receipt, without useful information like attribution, etc. However if we search by donation ID, we *do* get that information.
|
||||||
|
$this->_ProcessorUrl = 'https://fundraising.fracturedatlas.org/admin/general_support/donations?query=' . $this->TransactionId;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->_ProcessorUrl = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_ProcessorUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// *******
|
// *******
|
||||||
// METHODS
|
// METHODS
|
||||||
|
|
|
@ -32,3 +32,74 @@ legend{
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.payments thead{
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td:first-child{
|
||||||
|
width: 100%;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments time{
|
||||||
|
color: var(--body-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments td + td{
|
||||||
|
text-align: right;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments td:nth-child(2){
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments td:last-child{
|
||||||
|
text-align: left;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody time{
|
||||||
|
width: auto;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media(max-width: 1000px){
|
||||||
|
.payments thead{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td{
|
||||||
|
display: block;
|
||||||
|
text-align: left;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td:first-child{
|
||||||
|
padding-top: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td:nth-child(2){
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td:nth-child(2)::before{
|
||||||
|
content: 'Recurring? ';
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td:nth-child(3)::before{
|
||||||
|
content: 'Gross: ';
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td:nth-child(4)::before{
|
||||||
|
content: 'Fee: ';
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.payments tbody td:nth-child(5)::before{
|
||||||
|
content: 'Net: ';
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -152,6 +152,52 @@ catch(Exceptions\SeeOtherException $ex){
|
||||||
<? } ?>
|
<? } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<h2>Payments</h2>
|
||||||
|
<? if(sizeof($user->Payments) == 0){ ?>
|
||||||
|
<p>None.</p>
|
||||||
|
<? }else{ ?>
|
||||||
|
<table class="payments">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>Created</td>
|
||||||
|
<td>Recurring?</td>
|
||||||
|
<td>Gross</td>
|
||||||
|
<td>Fee</td>
|
||||||
|
<td>Net</td>
|
||||||
|
<td>Transaction ID</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<? foreach($user->Payments as $payment){ ?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<time datetime="<?= $payment->Created->format(Enums\DateTimeFormat::Html->value) ?>"><?= $payment->Created->Format(Enums\DateTimeFormat::FullDateTime->value) ?></time>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<? if($payment->IsRecurring){ ?>
|
||||||
|
☑
|
||||||
|
<? }else{ ?>
|
||||||
|
☐
|
||||||
|
<? } ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
$<?= number_format($payment->Amount, 2) ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
$<?= number_format($payment->Fee, 2) ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
$<?= number_format($payment->Amount - $payment->Fee, 2) ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="<?= $payment->ProcessorUrl ?>"><?= Formatter::EscapeHtml($payment->TransactionId) ?></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<? } ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<? } ?>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
<?= Template::Footer() ?>
|
<?= Template::Footer() ?>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue