From 3acda1137250217ccca176cf852f606e4b2940aa Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Thu, 29 Dec 2016 20:41:29 -0500 Subject: [PATCH] 55 - Making a Successful Charge --- app/Billing/StripePaymentGateway.php | 24 +++++++++++++++++++ .../unit/Billing/StripePaymentGatewayTest.php | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 app/Billing/StripePaymentGateway.php diff --git a/app/Billing/StripePaymentGateway.php b/app/Billing/StripePaymentGateway.php new file mode 100644 index 0000000..6f5a988 --- /dev/null +++ b/app/Billing/StripePaymentGateway.php @@ -0,0 +1,24 @@ +apiKey = $apiKey; + } + + public function charge($amount, $token) + { + Charge::create([ + 'amount' => $amount, + 'source' => $token, + 'currency' => 'usd', + ], ['api_key' => $this->apiKey]); + } +} diff --git a/tests/unit/Billing/StripePaymentGatewayTest.php b/tests/unit/Billing/StripePaymentGatewayTest.php index 07fb0fb..119c160 100644 --- a/tests/unit/Billing/StripePaymentGatewayTest.php +++ b/tests/unit/Billing/StripePaymentGatewayTest.php @@ -1,5 +1,6 @@ [