2020-05-17 15:23:39 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2020-06-04 18:00:33 +08:00
|
|
|
use App\Utils\Helper;
|
2020-05-17 15:23:39 +08:00
|
|
|
use Illuminate\Console\Command;
|
2020-06-04 18:00:33 +08:00
|
|
|
use Stripe\Source;
|
|
|
|
use Stripe\Stripe;
|
|
|
|
use Stripe\StripeClient;
|
|
|
|
use Omnipay\Omnipay;
|
2020-05-17 15:23:39 +08:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2020-06-04 18:00:33 +08:00
|
|
|
$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();
|
|
|
|
}
|
2020-05-17 15:23:39 +08:00
|
|
|
}
|
|
|
|
}
|