mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-06 00:49:24 +00:00
59 - Handling Invalid Payment Tokens
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Billing;
|
||||
|
||||
use Stripe\Charge;
|
||||
use Stripe\Error\InvalidRequest;
|
||||
|
||||
class StripePaymentGateway implements PaymentGateway
|
||||
{
|
||||
@@ -15,10 +16,14 @@ class StripePaymentGateway implements PaymentGateway
|
||||
|
||||
public function charge($amount, $token)
|
||||
{
|
||||
Charge::create([
|
||||
'amount' => $amount,
|
||||
'source' => $token,
|
||||
'currency' => 'usd',
|
||||
], ['api_key' => $this->apiKey]);
|
||||
try {
|
||||
Charge::create([
|
||||
'amount' => $amount,
|
||||
'source' => $token,
|
||||
'currency' => 'usd',
|
||||
], ['api_key' => $this->apiKey]);
|
||||
} catch (InvalidRequest $e) {
|
||||
throw new PaymentFailedException;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user