You're viewing the documentation of an older Simple Commerce version. Consider upgrading to the latest for new features and bug fixes.

Simple Commerce has will have built-in support for popular payment gateways, like Stripe. However, if we don't support your gateway of choice, it's easy enough to build one yourself.


Gateways are configured in your config/simple-commerce.php file. Like so:

1'gateways' => [
2 \DoubleThreeDigital\SimpleCommerce\Gateways\DummyGateway::class => [],

The array key is the gateway class and the key should contain an array of settings for the gateway, such as API keys.

Built-in gateways

Here's the list of popular payment gateways that Simple Commerce supports out of the box.

  • Stripe (recommended)
  • More coming soon!

Dummy Gateway

We provide a dummy gateway which can be helpful for testing/prototyping, before you've decided on a particular gateway. When using the dummy gateway, all payments will be returned as successful, unless you use the card number 1212 1212 1212 1212, where the payment will fail.

We include an example of the payment form for the Dummy gateway in the Simple Commerce starter kit.

Stripe Gateway

Stripe is the gateway we recommend, mostly because its modern and easy to use for both merchants and customers. To use the Stripe gateway in your store, add the Stripe class, followed by your Stripe API details as settings.

1'gateways' => [
2 \DoubleThreeDigital\SimpleCommerce\Gateways\StripeGateway::class => [
3 'key' => env('STRIPE_KEY'),
4 'secret' => env('STRIPE_SECRET'),
5 ],

We would highly recommend making use of environment variables to store your Stripe API details so they don't get leaked in version control (even if it's private).

We include an example of the payment form for the Stripe gateway in the Simple Commerce starter kit.

Build your own gateway

Sometimes you'll want to use a gateway that Simple Commerce doesn't provide out of the box. In that case, you'll need to make your own gateway.

  1. Create a gateway from a stub, you can copy over the stub by running php please make:gateway {gateway name}. The gateway will be created in your App\Gateways folder.
3namespace App\Gateways;
5use DoubleThreeDigital\SimpleCommerce\Contracts\Gateway;
7class SuperCoolGateway implements Gateway
9 public function name(): string
10 {
11 return 'Super Cool';
12 }
14 public function prepare(array $data): array
15 {
16 return [];
17 }
19 public function purchase(array $data): array
20 {
21 return [];
22 }
24 public function purchaseRules(): array
25 {
26 return [];
27 }
29 public function getCharge(array $data): array
30 {
31 return [];
32 }
34 public function refundCharge(array $data): array
35 {
36 return [];
37 }
  1. Now all you need to do is fill in the blank methods to make them work for your gateway. Here's a quick overview of what each of the methods do:
  • name - This method should return the name of your gateway. It's recommended this name should be recognisable.
  • prepare - This method is called while loading the sc:checkout form. If you need to, you can return an array of stuff which will be available as variables inside the form.
  • purchase - This method is called when the customer submits the sc:checkout form. $data will be everything sent to the checkout form. This is where you'll want to confirm the purchase.
  • purchaseRules - This method should return an array of validation rules which will be used to make sure the request contains everything it needs to hit the purchase method later on.
  • getCharge - This method will be hit anytime Simple Commerce needs to get gateway information.
  • refundCharge - This method will be hit whenever a refund should happen. $data will be an array of the order's entry data.
Last updated 3 months ago Improve this page on GitHub!