Test.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Utils\Helper;
  4. use Illuminate\Console\Command;
  5. use Stripe\Source;
  6. use Stripe\Stripe;
  7. use Stripe\StripeClient;
  8. use Omnipay\Omnipay;
  9. class Test extends Command
  10. {
  11. /**
  12. * The name and signature of the console command.
  13. *
  14. * @var string
  15. */
  16. protected $signature = 'test';
  17. /**
  18. * The console command description.
  19. *
  20. * @var string
  21. */
  22. protected $description = '';
  23. /**
  24. * Create a new command instance.
  25. *
  26. * @return void
  27. */
  28. public function __construct()
  29. {
  30. parent::__construct();
  31. }
  32. /**
  33. * Execute the console command.
  34. *
  35. * @return mixed
  36. */
  37. public function handle()
  38. {
  39. $gateway = Omnipay::create('Stripe');
  40. $gateway->setApiKey('sk_test_gDIIPtUgWZHbnTR7CUWZS8k500NsLS9SYB');
  41. $formData = array('number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '333');
  42. $response = $gateway->purchase(array('amount' => '10.00', 'currency' => 'USD', 'card' => $formData))->send();
  43. if ($response->isRedirect()) {
  44. // redirect to offsite payment gateway
  45. $response->redirect();
  46. } elseif ($response->isSuccessful()) {
  47. // payment was successful: update database
  48. print_r($response);
  49. } else {
  50. // payment failed: display message to customer
  51. echo $response->getMessage();
  52. }
  53. }
  54. }