Gravity uses Stripe to process subscription payments. Stripe is affordable, easy-to-use and developer friendly.
We've done most of the heavy lifting with regards to creating and managing subscriptions in your application, but you will need to set up a Stripe account and configure a few settings.
SSL Certificate Requirement
While you can run Stripe in test mode without an SSL certificate, you will need to purchase one before you can use Stripe in your live application.
1. Register a Stripe Account
Head over to Stripe and register your account. Setup is free – you'll only be charged a fee on each transaction that you process.Register Your Stripe Account
2. Activate Test Data
Once you've registered and signed in to your account, you'll be presented with your Stripe dashboard.
Stripe comes with two development modes: Test and Live – this is a great feature that enables you to build your payment engine without using real data – you can even use test credit card numbers to test different scenarios and error messages.
Go ahead and toggle the View Test Data switch in the left sidebar menu to start working in test mode.
Hint: When using Stripe in test mode, you can use the test credit card details during sign up:
Card Number: 4242 4242 4242 4242 Expiry Date: 04 24 CCV: 424 Postcode: 42424
3. Create a Product
Next, click on Billing > Products and click the New button.
Enter a product name (whatever your application is called) and click Create Product.
4. Add Pricing Plans
The next screen will prompt you to create a pricing plan.
Give your plan a nickname for your own reference and give it an ID. We recommend using something easy to identify, like plan_startup
Tip: this will make your life much easier when coding the back-end of your application.
You can also set the currency, billing interval and a trial period here. For SaaS products, keep the pricing set to Recurring quantity and set the interval to monthly or annual. You can leave "Does this pricing plan have multiple price tiers based on quantity?" set to no
You can add additional pricing plans here for your different pricing tiers.
5. Add The Webhook
Gravity uses Stripe webhooks to notify your users when a payment fails or succeeds. To add an endpoint, click on Developers > Webhooks and Add Endpoint
The URL will be your domain followed by /account/stripe
You won't need to use the webhook until you're processing payments but it makes sense to set it up now while you're here.
6. Copy The API Keys
Finally, you need to copy the API keys into Gravity. Stripe has two API keys: a Publishable Key for the front-end and a Secret Key which is used server-side.
There are a different set of keys for working with live data and test data. For building and testing your application, you can use the test keys, but when you deploy your application – ensure you switch these to the live keys.
Click on Developers > API Keys
Copy the API keys somewhere safe for now. You'll need them soon.
That's it for Stripe, there are lots of other options you can customise within Stripe. Please refer to the Stripe Documentation for further information.Setup Mailgun