SCK: Stripe Checkout for Kirby

SCK is my first plug-in for Kirby, which makes it easy to start processing payments with Stripe using Checkout. You can also accept AliPay and Bitcoin payments, if your Stripe account supports it.

The plugin is available to download on GitHub, and a fully working demo can be viewed here.

Features

  • Includes everything needed to add Checkout to any page and begin processing payments with Stripe.
  • Works on both desktop and mobile.
  • Checkout integration is easy with just the addition of a snippet and a template.
  • Makes use of Checkout’s vast array of features and functionality.
  • Supports alternative payment methods, such as Bitcoin and AliPay, in addition to most major credit/debit cards (if your Stripe account supports it)
  • Supports Stripe’s email receipt feature, so customers will receive an email confirmation of their purchase.
  • All billing and email information is passed to Stripe when creating the charge.
  • Option to collect shipping address information, which is then passed as metadata to Stripe and viewable within your Stripe dashboard.
  • Supports both decimal mark types: decimal point or decimal comma (e.g. $999.99 or €999,99).
  • Supports both left or right-positioned currency symbols (e.g. $999.99 or 999,99 kr)
  • All configuration settings are integrated into Kirby’s config.php file, making them easy to find and build upon if you want to extend the plugin’s functionality.
3 Likes

Just noticed the link to the demo was broken, have fixed!

Looks great! I’ve been meaning to set up my own invoicing area for clients - this will be a big help. I’m happy to donate some $$ if I use it, do you have a donate link anywhere?

Glad to hear you’ll find this useful! I hadn’t considered taking donations, but what better use of SCK than that, so the working demo is now set up for users to make a $3 donation if they wish :slight_smile:

From what I can tell, this isn’t really a shopping-cart style checkout, correct? It’s more for if you have like a membership fee or something where people click a pay button and check out for that one item?

@jordanmerrick is development of this plugin still active? The link to your working demo is broken :frowning: and it seems the GitHub repo hasn’t been updated in a while. The Stripe API has undergone a couple of updates since 2015 - is the current version still compatible?

Many thanks in advance for any info, and for your work!

if not, stripe has a github repo as well. it’s quite easy to integrate to whatever you want to do… e.g. the guy who wants to get invoices paid:

// Initiation
  require('assets/stripe/init.php');

  if($page->test()->bool()){
    $stripe = array(
      "secret_key"      => $page->testsecret()->value(),
      "publishable_key" => $page->testpublish()->value()
    );
  } else {
    $stripe = array(
      "secret_key"      => $page->livesecret()->value(),
      "publishable_key" => $page->livepublish()->value(),
    );
  }
  \Stripe\Stripe::setApiKey($stripe['secret_key']);

Form (needs to be adjusted obviously)

		<form action="<?php echo $page->children()->first()->url() ?>" method="POST">
			<script
				src="https://checkout.stripe.com/checkout.js" class="stripe-button"
				data-key="<?php e($page->test()->bool(),$page->testpublish()->value(),$page->livepublish()->value()) ?>"
				data-amount="10000"
				data-name="<?php echo $site->title() ?>"
				data-description="<?php echo u() ?>"
				data-email="<?php echo s::get('email') ?>"
				data-image="URL"
				data-locale="<?php echo $site->language()->code() ?>"
				data-label="<?php echo l('kreditzahlen') ?>"
				data-currency="<?php echo page('shop')->currency() ?>">
			</script>
			</form>
		</div>

And charging…

  require('assets/stripe/init.php');
  if($page->parent()->test()->bool()){
    $stripe = array(
      "secret_key"      => $page->parent()->testsecret()->value(),
      "publishable_key" => $page->parent()->testpublish()->value()
    );
  } else {
    $stripe = array(
      "secret_key"      => $page->parent()->livesecret()->value(),
      "publishable_key" => $page->parent()->livepublish()->value(),
    );
  }
  \Stripe\Stripe::setApiKey($stripe['secret_key']);


  $token  = get('stripeToken');
  $customer = \Stripe\Customer::create(array(
      'email' => s::get('email'),
      'source'  => $token
  ));

  $charge = \Stripe\Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 10000,
      'currency' => page('shop')->currency()
  ));
// Update Invoice as Paid then...


This can be integrated into both shopping cart or single payments, all depends what happens around the API.
having a cart you’d need to calculate the total amount and charge it, and somehow manage to successfully book that cart or create an order.

for single payments, such as having an invoice, let’s say the invoice is always the page() object, your charge, and form just needs to call for

$page->price()*100 as stripe always uses no decimals.

Apologies for the broken link to the demo. I’m not actively working on SCK right now but it should still work for card payments (feel free to fork the repo though!). The plugin uses only the core payments functionality for creating charges and none of that has changed with Stripe’s API updates. I still use it for one of my sites, in fact. However, Bitcoin and Alipay support has changed significantly and are no longer be supported by SCK. I’ll update the repo to reflect that as soon as possible.

Many thanks for your ongoing work. Trying to implement subscription payments and gift vouchers now, using Stripe Checkout, and your plugin came really, really handy! Stripe documentation is scattered and difficult to understand, and your plugin has really helped.

Please, keep up the good work - it’s truly appreciated! :slight_smile: