From f027f0a407d755bf83ab60a0dc0c528adce70cd0 Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Mon, 7 Jun 2021 14:22:21 -0400 Subject: [PATCH] Setup card payments --- .env | 1 + app/Http/Controllers/BillingController.php | 4 + resources/js/panel/credits.vue | 86 +++++++++++++++++++--- resources/scss/main.scss | 41 ++++++++++- 4 files changed, 120 insertions(+), 12 deletions(-) diff --git a/.env b/.env index 4211649..3218f49 100644 --- a/.env +++ b/.env @@ -49,4 +49,5 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" STRIPE_KEY=pk_test_51IeSwmBPMoXn2pf9VrXisJ7ubIjWHfnNWm1Iac8WB8H7hmBiJAw3GZrD8If9shKoSfSvT9my9lGdv0O0UzsbI4Iq00gn0MpA8S +VUE_APP_STRIPE_KEY=pk_test_51IeSwmBPMoXn2pf9VrXisJ7ubIjWHfnNWm1Iac8WB8H7hmBiJAw3GZrD8If9shKoSfSvT9my9lGdv0O0UzsbI4Iq00gn0MpA8S STRIPE_SECRET=sk_test_51IeSwmBPMoXn2pf9h2APPrSD8oGc5RmsO8xj6dkVtM6FrHtD84Gw5M6Mm4epaicTqRm4hpuTny8E593hNdAiKMes006IBMfAcc diff --git a/app/Http/Controllers/BillingController.php b/app/Http/Controllers/BillingController.php index 2c9ceb0..73a70e1 100644 --- a/app/Http/Controllers/BillingController.php +++ b/app/Http/Controllers/BillingController.php @@ -13,6 +13,7 @@ class BillingController extends Controller //Expects an array 'packs' representing the amount of each multiple of credits. //This controller should have a way of figuring out how much of each pack //was bought later. + //Should validate that all amounts are positive integers in a reasonable range public function secret(Request $request) { Stripe::setApiKey(env('STRIPE_SECRET')); Log::debug($request->packs); @@ -21,9 +22,12 @@ class BillingController extends Controller $request->packs[ 'credits50' ]*5499 + $request->packs[ 'credits100' ]*10999 + $request->packs[ 'credits1000' ]*101000; + // Pass customer and setup_future_usage values here. Maybe metadata can + // also hold pack information $intent = PaymentIntent::create([ 'amount' => $amount, 'currency' => 'usd', + /* 'customer' => Auth::user().customer_id, */ 'metadata' => ['integration_check' => 'accept_a_payment'] ]); diff --git a/resources/js/panel/credits.vue b/resources/js/panel/credits.vue index e321764..2fb6167 100644 --- a/resources/js/panel/credits.vue +++ b/resources/js/panel/credits.vue @@ -15,23 +15,42 @@

1000 Credits

+150 Free Credits

$1010.00

Qty
+

Total: ${{total.toLocaleString('en')}}

+
+ + +
+

Payment Method

+
+ + + +
+
+
+ + +
+ +
+
-

Total: ${{total.toLocaleString('en')}}

- +
diff --git a/resources/scss/main.scss b/resources/scss/main.scss index f2b5da3..42356af 100644 --- a/resources/scss/main.scss +++ b/resources/scss/main.scss @@ -1175,7 +1175,7 @@ button .loading-icon { margin: 0; } -.credits-confirm h3 { +.select-credits h3 { text-align: center; } @@ -1194,3 +1194,42 @@ button .loading-icon { font-size: 1.1rem; min-width: 7em; } + +div#card-errors { + margin: 5%; + text-align: center; +} + +#payment-section { + h4 { + text-align: center; + } + + form { + margin-top: 2em; + } + + label { + display: block; + } + + input { + margin: 1em 0; + } + + #save-card { + display: flex; + gap: 10px; + align-items: center; + justify-content: center; + } +} + +#card-element { + border: 2px solid grey; + border-radius: 4px; + padding: 10px; + input { + } + +}