61 - When Interfaces Aren't Enough

This commit is contained in:
Adam Wathan
2017-01-17 15:28:57 -05:00
parent 244f103473
commit 19e44bb234
2 changed files with 4 additions and 10 deletions

View File

@@ -23,7 +23,7 @@ class StripePaymentGateway implements PaymentGateway
'currency' => 'usd', 'currency' => 'usd',
], ['api_key' => $this->apiKey]); ], ['api_key' => $this->apiKey]);
} catch (InvalidRequest $e) { } catch (InvalidRequest $e) {
throw new PaymentFailedException; return false;
} }
} }
} }

View File

@@ -28,15 +28,9 @@ class StripePaymentGatewayTest extends TestCase
/** @test */ /** @test */
function charges_with_an_invalid_payment_token_fail() function charges_with_an_invalid_payment_token_fail()
{ {
try { $paymentGateway = new StripePaymentGateway(config('services.stripe.secret'));
$paymentGateway = new StripePaymentGateway(config('services.stripe.secret')); $result = $paymentGateway->charge(2500, 'invalid-payment-token');
$paymentGateway->charge(2500, 'invalid-payment-token'); $this->assertFalse($result);
} catch (PaymentFailedException $e) {
$this->assertCount(0, $this->newCharges());
return;
}
$this->fail("Charging with an invalid payment token did not throw a PaymentFailedException.");
} }
private function lastCharge() private function lastCharge()