My SMM panel
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

38 lines
1.1 KiB

  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use Stripe\Stripe;
  5. use Stripe\Customer;
  6. use Stripe\PaymentIntent;
  7. use Illuminate\Support\Facades\Log;
  8. use Illuminate\Support\Facades\Auth;
  9. class BillingController extends Controller
  10. {
  11. //Expects an array 'packs' representing the amount of each multiple of credits.
  12. //This controller should have a way of figuring out how much of each pack
  13. //was bought later.
  14. //Should validate that all amounts are positive integers in a reasonable range
  15. public function secret(Request $request) {
  16. Stripe::setApiKey(env('STRIPE_SECRET'));
  17. Log::debug($request->packs);
  18. $amount = $request->packs[ 'credits10' ]*1099 +
  19. $request->packs[ 'credits50' ]*5499 + $request->packs[ 'credits100' ]*10999
  20. + $request->packs[ 'credits1000' ]*101000;
  21. // Pass customer and setup_future_usage values here. Maybe metadata can
  22. // also hold pack information
  23. $intent = PaymentIntent::create([
  24. 'amount' => $amount,
  25. 'currency' => 'usd',
  26. 'customer' => Auth::user()->customer_id,
  27. 'metadata' => ['integration_check' => 'accept_a_payment']
  28. ]);
  29. return $intent->client_secret;
  30. }
  31. }