Files
ticketbeast/app/Billing/StripePaymentGateway.php
2017-01-17 15:28:57 -05:00

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;
}
}
}