164 - Paying Promoters Directly

This commit is contained in:
Adam Wathan
2018-01-26 11:58:50 -05:00
parent 0db962d04c
commit 7442baa5c5
6 changed files with 14 additions and 14 deletions

View File

@@ -33,7 +33,7 @@ class ConcertOrdersController extends Controller
try {
$reservation = $concert->reserveTickets(request('ticket_quantity'), request('email'));
$order = $reservation->complete($this->paymentGateway, request('payment_token'));
$order = $reservation->complete($this->paymentGateway, request('payment_token'), $concert->user->stripe_account_id);
Mail::to($order->email)->send(new OrderConfirmationEmail($order));

View File

@@ -28,9 +28,9 @@ class Reservation
return $this->email;
}
public function complete($paymentGateway, $paymentToken)
public function complete($paymentGateway, $paymentToken, $destinationAccountId)
{
$charge = $paymentGateway->charge($this->totalCost(), $paymentToken);
$charge = $paymentGateway->charge($this->totalCost(), $paymentToken, $destinationAccountId);
return Order::forTickets($this->tickets(), $this->email(), $charge);
}

View File

@@ -40,7 +40,7 @@ class DatabaseSeeder extends Seeder
Carbon::setTestNow(Carbon::instance($faker->dateTimeBetween('-2 months')));
$concert->reserveTickets(rand(1, 4), $faker->safeEmail)
->complete($gateway, $gateway->getValidTestToken($faker->creditCardNumber));
->complete($gateway, $gateway->getValidTestToken($faker->creditCardNumber), 'test_acct_1234');
}
Carbon::setTestNow();

View File

@@ -34,11 +34,11 @@ class FakePaymentGatewayTest extends TestCase
$paymentGateway->beforeFirstCharge(function ($paymentGateway) use (&$timesCallbackRan) {
$timesCallbackRan++;
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken());
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken(), 'test_acct_1234');
$this->assertEquals(2500, $paymentGateway->totalCharges());
});
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken());
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken(), 'test_acct_1234');
$this->assertEquals(1, $timesCallbackRan);
$this->assertEquals(5000, $paymentGateway->totalCharges());
}

View File

@@ -14,7 +14,7 @@ trait PaymentGatewayContractTests
$paymentGateway = $this->getPaymentGateway();
$newCharges = $paymentGateway->newChargesDuring(function ($paymentGateway) {
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken());
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken(), 'test_acct_1234');
});
$this->assertCount(1, $newCharges);
@@ -40,7 +40,7 @@ trait PaymentGatewayContractTests
$newCharges = $paymentGateway->newChargesDuring(function ($paymentGateway) {
try {
$paymentGateway->charge(2500, 'invalid-payment-token');
$paymentGateway->charge(2500, 'invalid-payment-token', 'test_acct_1234');
} catch (PaymentFailedException $e) {
return;
}
@@ -55,12 +55,12 @@ trait PaymentGatewayContractTests
function can_fetch_charges_created_during_a_callback()
{
$paymentGateway = $this->getPaymentGateway();
$paymentGateway->charge(2000, $paymentGateway->getValidTestToken());
$paymentGateway->charge(3000, $paymentGateway->getValidTestToken());
$paymentGateway->charge(2000, $paymentGateway->getValidTestToken(), 'test_acct_1234');
$paymentGateway->charge(3000, $paymentGateway->getValidTestToken(), 'test_acct_1234');
$newCharges = $paymentGateway->newChargesDuring(function ($paymentGateway) {
$paymentGateway->charge(4000, $paymentGateway->getValidTestToken());
$paymentGateway->charge(5000, $paymentGateway->getValidTestToken());
$paymentGateway->charge(4000, $paymentGateway->getValidTestToken(), 'test_acct_1234');
$paymentGateway->charge(5000, $paymentGateway->getValidTestToken(), 'test_acct_1234');
});
$this->assertCount(2, $newCharges);

View File

@@ -76,11 +76,11 @@ class ReservationTest extends TestCase
$reservation = new Reservation($tickets, 'john@example.com');
$paymentGateway = new FakePaymentGateway;
$order = $reservation->complete($paymentGateway, $paymentGateway->getValidTestToken());
$order = $reservation->complete($paymentGateway, $paymentGateway->getValidTestToken(), 'test_acct_1234');
$this->assertEquals('john@example.com', $order->email);
$this->assertEquals(3, $order->ticketQuantity());
$this->assertEquals(3600, $order->amount);
$this->assertEquals(3600, $paymentGateway->totalCharges());
$this->assertEquals(3600, $paymentGateway->totalChargesFor('test_acct_1234'));
}
}