Stripe Manage Subscription Payment using Codeigniter

Recurring payments also known as AutoPay are automatic payments to authorize and collect charges immediately, Stripe Subscriptions provides you the platform to set up and manage recurring payments.
In this tutorial, We will share how to integrate Stripe Manage Subscription Payment using Codeigniter. This is a very simple example, you can just copy-paste, and change it according to your requirements.
Step-1: Create a Stripe account and get API keys
  • Create a Stripe account and login to the dashboard.
  • Navigate to the Developers » API keys page.
  • There is two type of standard API keys named secret key and publishable key.To show the Secret key, click on Reveal test key token button.
  • Stripe’s php library download: click here
Before started to implement the Stripe Manage Subscription Payment using Codeigniter, look files structure:
  • stripe-manage-subscription-payment-using-codeigniter
    • application
      • config
        • autoload.php
        • constants.php
        • routes.php
      • controllers
        • Subscription.php
      • models
      • views
        • subscription
          • index.php
          • thankyou.php
        • templates
          • header.php
          • footer.php
    • system
    • index.php
    • assets
      • css
        • style.css
Step 2: Open a file constants and update
Open “application/config/constants.php” file and define constants:
Step 3: Create controllers
Create a controllers file named Subscription.php inside “application/controllers” folder.
  • The controller handles the Subscription process.
  • __construct() – Loads the required library, helper and model.
  • index() – load package data.
  • create() – create subscription.
  • thankyou() – return success payment
Step 4:Create a view(header)
Create a view file named header.php inside “application/views/templates” folder.
This view contains the header section of the webpage. The Bootstrap library is used to provide a better UI, so, include it in the header section.
Step 5: Create a view(footer)
Create a view file named footer.php inside “application/views/templates” folder.
This view contains the footer section of the webpage.
Step 6: Create views
Create a views file named index.php inside “application/views/subscription folder.
Step 7: Stripe Javascript code
You add Stripe Javascript code on your page.
Step 8: Create views
Create a views file named thankyou.php inside “application/views/subscription folder.