Getting started with Stripe payments

Quite regularly I happen to meet the challenge of building something on the Force.com platform that is not exactly a CRM application. Exposing a public site as a storefront and integrating payment into it is quite that kind of app. We decided to use Stripe as a payment provider – its handling fees are moderate and it’s an API-first platform, using RESTful webservices and JSON objects for all communication. It’s doesn’t take a lot of knowledge about platforms to realize that anything that speaks JSON via HTTPS is a good choice to build things that seamlessly integrate.

And it gets even better: Cirruspath open-sourced an Apex-Library named “stripeforce” on github, so there’s even as foundation to build upon. 

So much for the good part of it, yet there’s a big bummer to come: Stripeforce isn’t that easy to deploy to your org. Test coverage is as low as 68% (and very hard to push higher), and even worse, it’s even hard to install to any development org because the classes have several cross-dependencies, so I spent about an hour, commenting-out references, uncommenting them again etc.  But there’s at least something good about it: I decided to give back to the community and write about these efforts (so that others hopefully find it easier to implement Stripe) and make some examples public and open source and return some pull requests to the main repo and eventually package the Stripe libraries so that you can install it more easily.

For now, I started with a sample Visualforce page that exposes a form, collects some payment data, and upon submitting the form, gets a Stripe token, starts a transaction and saves the results to an account. It’s open source on github (https://github.com/dstdia/VFSampleStripe), feel free to try it out, correct my mistakes etc. You need a Stripe account to get your secret and publishable keys, you need a Salesforce dev org at least (and StripeForce installed on your org). So: Prerequisites are high, but I promise to help making it easier to use Stripe payments in Apex and Visualforce.

2 Replies to “Getting started with Stripe payments”

  1. Hi Daniel! My name is Kevin I am very curious about what alterations to Stripeforce you had to do? For the install, did you just move the cls, component and page files into your local org then upload them?

    1. Hi Kevin,

      installing Stripeforce to my sandbox was a major pain. I copied class after class, commented out parts that caused “dependent class is invalid” errors etc.

      The updates and changes I made can be seen in my forked stripeforce repo -> https://github.com/dstdia/stripeforce. I made additional changes to cover the current API version for refunds, but didn’t take the time to port the code to my personal repo. Bank account direct debit is on my list, as well as packaging stripeforce or make the “deploy to salesforce” button work. Currently, I’m not working on the proprietary project that uses Stripeforce, therefore the repo is somewhat neglected. Hope to take up the work later this year…

Leave a Reply

Your email address will not be published. Required fields are marked *

*