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 built-in support for popular payment gateways, including Stripe and Mollie.

And if you need a gateway that we don't already support, it's easy enough to build your own.


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

3| Gateways
6| You can setup multiple payment gateways for your store with Simple Commerce.
7| Here's where you can configure the gateways in use.
11'gateways' => [
12 \DoubleThreeDigital\SimpleCommerce\Gateways\DummyGateway::class => [],

To add a gateway, just add the gateway's class name (DummyGateway::class syntax) as the array key and an array as the value. The array value can be used by the gateway for any configuration options, like API keys etc. If the gateway doesn't need any, just leave it an empty array.

Built-in gateways

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

  • Stripe
  • Mollie


In the case when you're building out your checkout process and you haven't decided on a payment processor or you're just playing around with Simple Commerce and don't want to setup a 'real' payment gateway, the dummy one can come in useful.

You can enter any credit card number, any cvv and any expiry and the card will always return successful.


To get started, add the Stripe gateway to your gateway configuration:

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

🔥 Hot Tip: Use environment variables for the API Key and Secret so they're never committed to version control.

You can see an example payment form using Stripe Elements, in the Simple Commerce Starter Kit.


To get started, add the Mollie gateway to your gateway configuration:

1'gateways' => [
2 \DoubleThreeDigital\SimpleCommerce\Gateways\MollieGateway::class => [
3 'key' => env('MOLLIE_KEY'),
4 'profile' => env('MOLLIE_PROFILE'),
5 ],

🔥 Hot Tip: Use environment variables for the API Key and Profile so they're never committed to version control.

Another thing you'll need to do is setup a webhook inside Mollie's Dashboard. This is how Mollie's system will communicate with Simple Commerce. The webhook URL is:!/simple-commerce/gateways/mollie/webhook.

Because of Mollie being a complete off-site gateway, no payment form is provided. Instead, you'll need to redirect users to Mollie's hosted checkout page where the customer can complete the payment process. After they pay, they will be redirected back to your site.

You can learn more about off-site gateways below.

Custom Gateway

There are often cases where you'll need to use a gateway that Simple Commerce doesn't provide out of the box. In those cases, you will need to build your own:

  1. Run php please make:gateway {gateway}, obviously replacing {gateway} with the name of your gateway. The gateway will be created in App\Gateways.

  2. Fill in the blanks! Review each of the methods, filling in the ones you need. Here's a quick breakdown of each of the methods.

  • name() - should return the name of your gateway
  • prepare() - should be used to either: generate tokens used later on for displaying the payment form or generating an off-site checkout link.
  • purchase() - should be used to do the actual purchase (aka. taking the money from the customer)
  • purchaseRules - should return Laravel Validation Rules for the checkout request.
  • getCharge() - should get information about a specific order's charge/transaction.
  • refundCharge() - should refund an order
  • webhook() - should accept incoming webhook payloads, used for off-site payment gateways.


On-site gateways

On-site gateways is where the customer is kept on the store's website to enter their payment information, Stripe is the primary on-site gateway we support.

Usually, the payment form would be on the last step in your checkout flow, inside the {{ sc:checkout }} tag. Make sure to provide the gateway being used in the checkout form.

The implementation of on-site gateways vary depending on the gateway. However, we've provided a bare-bones example below, showing usage with the built-in Stripe gateway.

2 <label for="card-element">Card Details</label>
3 <div id="card-element"></div>
6<input id="stripePaymentMethod" type="hidden" name="payment_method">
7<input type="hidden" name="gateway" value="DoubleThreeDigital\SimpleCommerce\Gateways\StripeGateway">
9<script src=""></script>
11 var stripe = Stripe('{{ gateway-config:key }}')
12 var elements = stripe.elements()
14 const card = elements.create('card')
15 card.mount('#card-element')
17 card.addEventListener('change', ({error}) => {
18 // Deal with errors
19 })
21 function confirmPayment() {
22 stripe.confirmCardPayment('{{ client_secret }}', {
23 payment_method: { card: card },
24 }).then(function (result) {
25 if (result.paymentIntent.status === 'succeeded') {
26 document.getElementById('stripePaymentMethod').value = result.paymentIntent.payment_method
27 } else if (result.error) {
28 // Deal with errors
29 }
30 })
31 }

Inside checkout forms, you can access the gateway's configuration options and anything it returns in it's prepare method.

For example: {{ gateway-config:key }} fetches the key property from the gateway's config. And the {{ client_secret }} is returned from the Stripe Gateway during it's prepare method.

Multiple on-site gateways

If you want to give the customer a choice of how they want to pay (bank transfer or credit card, for example), you can offer the customer a choice of payment methods by looping through the {{ sc:gateways }} tag.

In the below example, we're using Alpine.js to react to the value of the <select> element. We'd also recommend splitting the payment forms into their own partials.

1<div x-data="{ gateway: '{{ sc:gateways }}{{ if first }}{{ formatted_class }}{{ /if }}{{ /sc:gateways }}' }">
2 <h2>Secure Payment</h2>
4 <select
5 x-model="gateway"
6 class="h-10 w-full border rounded p-2 mb-2 outline-none mr-2"
7 name="gateway"
8 >
9 {{ sc:gateways }}
10 <option value="{{ class }}">{{ name }}</option>
11 {{ /sc:gateways }}
12 </select>
14 {{ sc:gateways }}
15 <div x-show="gateway === '{{ formatted_class }}'">
16 <!-- Payment form partial -->
17 </div>
18 {{ /sc:gateways }}
20 <button
21 type="button"
22 @click.prevent="if(typeof confirmPayment == 'function' && document.getElementsByName('gateway')[0].value == 'DoubleThreeDigital\\SimpleCommerce\\Gateways\\StripeGateway') { confirmPayment(); } else { document.querySelector('form').submit() }">
23 Complete Checkout
24 </button>

Off-site gateways

Off-site gateways are where the customer is redirected away from the store's website to a payment processor. Mollie is the off-site gateway built in with Simple Commerce.

When you want to use an off-site gateway, you can't use the standard {{ sc:checkout }} tag as the customer needs to be redirected elsewhere to complete the checkout process.

Below is an example of the off-site gateway checkout tag for Mollie. You can obviously change the gateway name and the redirect to work for you.

1{{ sc:checkout:mollie redirect="/thanks" }}

After the customer completes payment on the off-site gateway they will be redirected back to your store's site. Either to the redirect URL provided or to your store's homepage.

Behind the scenes, the customer's payment confirmation will be sent via webhooks to your gateway.

Using webhooks

Some gateways offer webhooks, a way for your gateway to report back to Simple Commerce about payment statuses etc. Webhook URLs look like this:!/simple-commerce/mollie/webhook.

Most gateways, like Stripe, will require you to setup the webhook endpoint on their website. However, others may automatically set the webhook when Simple Commerce creates a transaction.

Webhooks will also need to bypass Laravel's CSRF verification. You can configure CSRF exceptions in your app/Http/Middleware/VerifyCsrfToken.php file.

1protected $except = [
2 '/!/simple-commerce/gateways/mollie/webhook',
Last updated 3 months ago Improve this page on GitHub!