Created
June 25, 2018 07:17
-
-
Save studio-fars-company/dbb16c807cb24463e387429c78be44d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use Stripe\Stripe; | |
use Stripe\Customer; | |
use Stripe\Charge; | |
class ChargeController extends Controller | |
{ | |
/*単発決済用のコード*/ | |
public function charge(Request $request) | |
{ | |
try { | |
Stripe::setApiKey(env('STRIPE_SECRET')); | |
$customer = Customer::create(array( | |
'email' => $request->stripeEmail, | |
'source' => $request->stripeToken | |
)); | |
$charge = Charge::create(array( | |
'customer' => $customer->id, | |
'amount' => 1000, | |
'currency' => 'jpy' | |
)); | |
return back(); | |
} catch (\Exception $ex) { | |
return $ex->getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment