Skip to content

Instantly share code, notes, and snippets.

@jimrubenstein
Created February 21, 2016 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimrubenstein/f879c91f57573f9cfd84 to your computer and use it in GitHub Desktop.
Save jimrubenstein/f879c91f57573f9cfd84 to your computer and use it in GitHub Desktop.
STRIPE_SECRET_KEY=XXXXXXX
STRIPE_PUBLIC_KEY=YYYYYYY
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Stripe\Stripe;
use Config;
use Blade;
class StripeServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$api_key = Config::get('stripe.api_key');
$public_key = Config::get('stripe.publishable_key');
Stripe::setApiKey($api_key);
Blade::extend(function($view, $Compiler) use ($public_key) {
$pattern = $Compiler->createPlainMatcher('stripePublicKey');
return preg_replace($pattern, $public_key, $view);
});
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array();
}
}
<?php
return array(
'api_key' => env('STRIPE_SECRET_KEY', ''),
'publishable_key' => env('STRIPE_PUBLIC_KEY', ''),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment