mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
30 lines
579 B
PHP
30 lines
579 B
PHP
<?php
|
|
|
|
namespace App\Billing;
|
|
|
|
use Stripe\Charge;
|
|
use Stripe\Error\InvalidRequest;
|
|
|
|
class StripePaymentGateway implements PaymentGateway
|
|
{
|
|
private $apiKey;
|
|
|
|
public function __construct($apiKey)
|
|
{
|
|
$this->apiKey = $apiKey;
|
|
}
|
|
|
|
public function charge($amount, $token)
|
|
{
|
|
try {
|
|
Charge::create([
|
|
'amount' => $amount,
|
|
'source' => $token,
|
|
'currency' => 'usd',
|
|
], ['api_key' => $this->apiKey]);
|
|
} catch (InvalidRequest $e) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|