v2board/app/Console/Commands/Test.php
2020-06-04 18:00:33 +08:00

63 lines
1.5 KiB
PHP

<?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();
}
}
}