My SMM panel
 
 
 
 
 
 

33 行
879 B

  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. public function secret(Request $request) {
  14. Stripe::setApiKey(env('STRIPE_SECRET'));
  15. Log::debug($request->packs);
  16. $amount = $request->packs[ 'credits10' ]*1099 +
  17. $request->packs[ 'credits50' ]*5499 + $request->packs[ 'credits100' ]*10999
  18. + $request->packs[ 'credits1000' ]*101000;
  19. $intent = PaymentIntent::create([
  20. 'amount' => $amount,
  21. 'currency' => 'usd',
  22. 'metadata' => ['integration_check' => 'accept_a_payment']
  23. ]);
  24. return $intent->client_secret;
  25. }
  26. }