Skip to content

Instantly share code, notes, and snippets.

@bran921007
Created May 26, 2015 10:46
Show Gist options
  • Save bran921007/64edb01d1ffeba38cf9f to your computer and use it in GitHub Desktop.
Save bran921007/64edb01d1ffeba38cf9f to your computer and use it in GitHub Desktop.
Stripe backend - PHP Laravel
//use Stripe\Stripe;
\Stripe\Stripe::setApiKey('SECRET API KEY');
$token = Input::get('token');
$amount = Input::get('amount');
try {
$charge = \Stripe\Charge::create(array('card' => $token, 'amount' => $amount, 'currency' => 'usd'));
} catch (Error\Card $e) {
return Response::json(array(
'status' => 'failed',
'msg' => 'sripe transaction invalid',
'error_msg' => $e->getMessage(),
'error_line_ubication' => $e->getLine(),
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment