mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
163 - Total Charges for a Specific Account
This commit is contained in:
@@ -20,4 +20,9 @@ class Charge
|
||||
{
|
||||
return $this->data['card_last_four'];
|
||||
}
|
||||
|
||||
public function destination()
|
||||
{
|
||||
return $this->data['destination'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class FakePaymentGateway implements PaymentGateway
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function charge($amount, $token)
|
||||
public function charge($amount, $token, $destinationAccountId)
|
||||
{
|
||||
if ($this->beforeFirstChargeCallback !== null) {
|
||||
$callback = $this->beforeFirstChargeCallback;
|
||||
@@ -38,6 +38,7 @@ class FakePaymentGateway implements PaymentGateway
|
||||
return $this->charges[] = new Charge([
|
||||
'amount' => $amount,
|
||||
'card_last_four' => substr($this->tokens[$token], -4),
|
||||
'destination' => $destinationAccountId,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -53,6 +54,13 @@ class FakePaymentGateway implements PaymentGateway
|
||||
return $this->charges->map->amount()->sum();
|
||||
}
|
||||
|
||||
public function totalChargesFor($accountId)
|
||||
{
|
||||
return $this->charges->filter(function ($charge) use ($accountId) {
|
||||
return $charge->destination() === $accountId;
|
||||
})->map->amount()->sum();
|
||||
}
|
||||
|
||||
public function beforeFirstCharge($callback)
|
||||
{
|
||||
$this->beforeFirstChargeCallback = $callback;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Billing;
|
||||
|
||||
interface PaymentGateway
|
||||
{
|
||||
public function charge($amount, $token);
|
||||
public function charge($amount, $token, $destinationAccountId);
|
||||
|
||||
public function getValidTestToken();
|
||||
public function newChargesDuring($callback);
|
||||
|
||||
Reference in New Issue
Block a user