1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace App\Console\Commands;
- use App\Utils\Helper;
- use Illuminate\Console\Command;
- use Stripe\Source;
- use Stripe\Stripe;
- use Stripe\StripeClient;
- use Omnipay\Omnipay;
- class Test extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'test';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $gateway = Omnipay::create('Stripe');
- $gateway->setApiKey('sk_test_gDIIPtUgWZHbnTR7CUWZS8k500NsLS9SYB');
- $formData = array('number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '333');
- $response = $gateway->purchase(array('amount' => '10.00', 'currency' => 'USD', 'card' => $formData))->send();
- if ($response->isRedirect()) {
- // redirect to offsite payment gateway
- $response->redirect();
- } elseif ($response->isSuccessful()) {
- // payment was successful: update database
- print_r($response);
- } else {
- // payment failed: display message to customer
- echo $response->getMessage();
- }
- }
- }
|