Files
ticketbeast/app/Billing/FakePaymentGateway.php
2016-11-11 15:02:02 -05:00

32 lines
562 B
PHP

<?php
namespace App\Billing;
class FakePaymentGateway implements PaymentGateway
{
private $charges;
public function __construct()
{
$this->charges = collect();
}
public function getValidTestToken()
{
return "valid-token";
}
public function charge($amount, $token)
{
if ($token !== $this->getValidTestToken()) {
throw new PaymentFailedException;
}
$this->charges[] = $amount;
}
public function totalCharges()
{
return $this->charges->sum();
}
}