Integrate Stripe with your Kinvey Application

Kinvey is my new favorite platform as a service (PAAS) because I can do my entire app as an angularjs app with no backend, deploy it to heroku and have it communicate with Kinvey using ajax.  It’s beautiful.

Here is how to process credit card payments in Kinvey using stripe – it took me a while to figure out, so I thought I would save you some time.

In your client-side javascript (I use angular), you can do something like this:

Then you have to create a custom endpoint in Kinvey called “chargeCard”.  The code for the custom endpoint looks like this:

Basically what that does is:

  • Use the stripe token generated on the client i.e. no credit card info ever hits kinvey
  • Create a customer record on stripe
  • Subscribe the customer to the plan name passed in from the client
  • Save the stripe customer object to the user record in kinvey