API Keys

As part of the setup you'll need to get your Stripe account API keys. You can find them from your Stripe account dashboard, under Your Account > API Keys.

There's 2 ways to set your keys for Charge to use :

Set in the Charge CP #

This is the standard way to set your api keys, and the one you'll be familiar with from other plugins.

The Charge 2.0 stripe credentials view

Set in a config file #

For more advanced setups and for greater portability, you can also set the api credentials in a custom config file.

To do this, create a new config file called charge.php and place it in your standard craft/config path, alongside the rest of your build's config.

In your custom config file, just structure things like so :


return [
    'credentials' => [
        'stripeTestCredentialsSK' => 'sk_test_exampleakasdfkjasdfkjdsf',
        'stripeTestCredentialsPK' => 'pk_examplekjasdfkjasdflkjadsfksa',
        'stripeLiveCredentialsSK' => 'sk_live_ajsdfaskdfasdfasdkdkfjdk',
        'stripeLiveCredentialsPK' => 'pk_examplekjasdfkjasdfkjasdfkjad',

Using Multi-Env Configs? Super. All the same domain based config array handling works the same here too. Just be careful when using multiple separate stripe accounts during testing to make sure you're using the correct accounts to test against.

When your Stripe details are set from a config file the CP form will be locked off from edits, and you'll see a small notice. It'll look something like this :