mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
49 lines
1.0 KiB
PHP
49 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Billing;
|
|
|
|
use Stripe\Charge;
|
|
|
|
class StripePaymentGateway implements PaymentGateway
|
|
{
|
|
private $apiKey;
|
|
|
|
public function __construct($apiKey)
|
|
{
|
|
$this->apiKey = $apiKey;
|
|
}
|
|
|
|
public function charge($amount, $token)
|
|
{
|
|
Charge::create([
|
|
'amount' => $amount,
|
|
'source' => $token,
|
|
'currency' => 'usd',
|
|
], ['api_key' => $this->apiKey]);
|
|
}
|
|
}
|
|
|
|
// class StripePaymentGateway implements PaymentGateway
|
|
// {
|
|
// private $apiKey;
|
|
|
|
// public function __construct($apiKey)
|
|
// {
|
|
// $this->apiKey = $apiKey;
|
|
// }
|
|
|
|
// public function charge($amount, $token)
|
|
// {
|
|
// (new \GuzzleHttp\Client)->post('https://api.stripe.com/v1/charges', [
|
|
// 'headers' => [
|
|
// 'Authorization' => "Bearer {$this->apiKey}",
|
|
// ],
|
|
// 'form_params' => [
|
|
// 'amount' => $amount,
|
|
// 'token' => $token,
|
|
// 'currency' => 'usd',
|
|
// ]
|
|
// ]);
|
|
// }
|
|
// }
|