57 - Don't Mock What You Don't Own

This commit is contained in:
Adam Wathan
2016-12-30 13:15:24 -05:00
parent 3472361c35
commit 7eb064a9ec
6 changed files with 294 additions and 6 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Billing\Alternate;
use App\Billing\PaymentGateway;
class StripePaymentGateway implements PaymentGateway
{
private $stripeClient;
public function __construct(\Stripe\ApiClient $stripeClient)
{
$this->stripeClient = $stripeClient;
}
public function charge($amount, $token)
{
$this->stripeClient->createCharge([
'amount' => $amount,
'source' => $token,
'currency' => 'usd',
]);
}
}

View File

@@ -22,3 +22,27 @@ class StripePaymentGateway implements PaymentGateway
], ['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',
// ]
// ]);
// }
// }