My SMM panel
 
 
 
 
 
 

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