Stripe Subscriptions using php – Download Full Source Code

Hi Guys,

In This blog article i am going to explain about STRIPE SUBSCRIPTIONS USING PHP and making available the source code also. by extending this code you can make a complete subscription management script.

Here in this article about

stripe subscriptions using php ,

i am going to create a pricing table where 3 type of plans are defined that plan will create on stripe if plan not exists on stripe panel and then create a customer and create a subscription in that customers reference.

Note: the Stripe account is the pre requisite for you , where we will require stripe publishable key and secret key.

and the stripe php library will be require for including in config file so dont worry about the stripe php library it will be available in full source code download of this article.

Step 1: Create a config file and put following code :

Note : you need to change the publishable key and secret key in this config file

Step 2:  Create a file index.php where pricing table and stripe client side code will come as following :

Note : here you have 3 plans listed with different subscription plan and data(like plan name,plan price,plan interval [month/year/week/day] and currency)  which are defined in hidden fields in every stripe form tag inside every pricing options.

Step 3: Now the Stripe Server Side code where after inputing the card details Actyual payment need to be done

So create a file create-subscription.php which is already included in index.php code in top lines, and this file wil have following Code:

Now you are Ready  it will look like this :

stripe subscriptions preview
stripe subscriptions preview

and if we click on any subscription button it will prompt a stripe popup like this

stripe subscriptions credit card promt by stripe
stripe subscriptions credit card prompt by stripe

Click HERE to download full source code

Note: this is completely Free script.

if you have any trouble in download this then please contact me at or ask query in comments below

Implement Stripe in 3 steps using php

Hi Geeks,
This Article is focused on Implement Stripe in 3 steps using php, where you can easily accept payments through stripe by using this code. the stripe checkout.js
is used here with server side code also.

Step 1: Create a product list page named index.php with following code:

Output Screen for this will look like this:


Note: you can get products from database also,but here for demonstration i am showing these static.

Step 2: Create a Checkout Page with name pay.php, here you need to replace the stripe public key mention in the comment also.

Output Screen:


Step 3: Create a server side script for charge customer named as charge.php with following code, here you need to replace the Stripe private key mention in comment also:

Output Screen:


Note: there should be a stripe library in the root folder you can download it from here:
and extract it with name stripe as you can see in following screenshot


Still you have any problem in integrating you can directly call me and i will send you the complete working code,

you can comment here or send me a email on



Radio and Checkbox use in Angularjs Post method

Hi Geeks,

When I was working with angular form posts then I was tried  radio and checkboxes as normal inputs in angular js form post then it is sending [Object Object] to the webservices and that object couldn’t be parsed by the server-end , and also inserted [Object Object] text into the database also.

But I need to send the controls in key val pair So I Write following code written to sent it, These are the steps which I follow to achieve it.

First  I created the Html controls like this :


Now in your Controller ‘s  submit function ( I am assuming that you have already go through my previous article for form process in angular js or you already aware with form processing in angular js ) as following:


Now complete post action  inside the respective controller will look like this

you can ask any confusion and if something not clear then put your query in comments , i will type to reply on same and try to resolve your problem where you stucked




Image or file Upload in angular js

This tutorial is based on Image or file Upload in angular js . i am providing simple steps to image or file upload , I am assuming that you have already submitted the form using angular js, i have provided all steps in my previous tutorial
Now follow these steps in existing one:

add input type file inside your form as following:

In above code we have passed a method name  ‘uploadedFile’ in onchange of that input type file so need to create that function in our existing controller as following:

now we need to make some modification(related to add files and header info) and need to add transformRequest param, in our http post method as following:

Now we can easily Recieve the image or file with ‘file_upload’ named field in php $_FILES array in our webservice, we need to save the file in uploads or any other folder and save its name to database as follow.



Form Processing and validation in Angular js

Hi Geeks,

In this tutorial you will learn form processing and validation in angular js. where i have focused on validation in angular js, and after validation save the formdata to server/database using webservice.

Step 1: Include the angular js in head section by

Step 2:Define app name in body tag

Step 3: Create a controller div, and for this controller we will write handler in javascript code

Step 4 : Create your form inside controller div and take name of that form it will use in validation the form fields

here we’ll create a submit form named function in controller of this view to submit the information over server.

but this function will call only when our form passes all validations.

All data will binds to super object named formdata which we have used in every ng-model
by using that single object we will send data to server. it will very usefull to collect data from every fields and create a bunch. thats why we have used formdata.{field_name} in every ng-model

Now validation directives used in this form are following:

>Define form name attribute is must for validation , we have take myform as form name.

>For making a field required , we need to use required attribute
>For patter use ng-pattern , following pattern is a email syntax


>ng-minlength is use for minimum length of input number/characters
>ng-maxlength is for maximum length of input number/characters

we have used minimum and maximum length of mobile number as per indian mobile standards
ng-minlength=”10″ ng-maxlength=”10″

Showing a message below of each field

ng-show=”{form_name}.{field_name}.$invalid && !{form_name}.{field_name}.$pristine”

for example of full_name in this form we will use >> ng-show=”myform.full_name.$invalid && !myform.full_name.$pristine”

Step 5: Now write angular controller code for form processing:

Create a module for the ng-app

Now after it define the controller method body

Now create a method which we have used in form tag ng-submit directive name ‘submit_form()’
so create a method submit_form() inside the controller as following

this function send your data to server and get response in json and handle the response in success callback
if all data is fine then we will save it to db in webservices and return 1 and reset the formdata and show success message that is returned by webservice in alert with following:

If In status ,any error then we will return status 0 and failed message also. We will show that failed message in alert as following

Note: there is a error callback for any unexpected error from webservices that time we have alert following message:

Now in your web_services/add_enquiry.php
you can use following code :

Note: Or write your own code just like a normal post of form.

Now complete index.html code is following:

Comment here if you face any problem in this Thanks.


Url rewriting example in angular js

Hi Geeks,

I am sharing  Url rewriting example in angular js with complete steps to achieve it . If you are beginner with angular js then you might faced some issues with hash(#) in angular. So i am proving you the complete snippet and steps for making your url clean/pretty to make your angular js website seo friendly.

you can download full source code from here or you can follow the steps, leave comments in comment box  if you face any problem to achieve this

Step 1 . for your index.html file write following code in your htaccess file.

Step 2.  In index.html head section please put following lines :

Note : in base href you need to provide your project url if on local, and for server you can set it only slash (/) .

Step 3. Now according to the uri we need to load the page content , So we need to create a dynamic view and it will load the content as per the uri component :

Step 4: write the Routing for load different different html views as per the uri component, in index.html

So wee need to initialize and use this code for configure and defining route provider and need to enable the html5 mode to true.

Here locationprovider and routeprovider and http angular predefined directves wil be use here

define app name in body using  ng-app directive using as follow:

and include the angular and routing libraries as follow :

Now we initialize and define configuration for the MyApp as follow with injecting the ngRoute Directive:

Note: I specify the url slugs and assign the template url according to the uri . you need to make each page to load the content as per the url.

You have sucessfully done the url rewriting in angular js . Now full code of your index.html

Download full source code here


Codeigniter best tricks and hacks

Hi Friends,
Today I am sharing you some best tricks i have used in couple of projects, may be these things are common but we need these in all of our projects and we can find it on google but by different different authors, i am providing all the codeigniter tips tricks and hacks in this single article. if i missed any other trick then please let me know through comments, I will update it to my article.

Now please find the

Codeigniter best tricks and hacks

1: Remove index.php from url codeigniter

Solution : we need to update the .htaccess with following code:

2: Call Controller function or varriable from view

Solution : We need to pass the controller self object to its view to call the function or varriable of that controller . please follow instructions:

3: Db prefix in core queries

Solution : in database.php we need to pass swap_pre in configuration index in db config array. please see example:
In database.php there is a config array start with following:

So in this list there is a index named db_prefix
this is general usage in CI auto qyuiry builder class
but if we are writing the core queries then we need to pass any string like:

now we can use the swap_pre value appending before table name in our query as following:

4: Call model and its function from library and helpers

Solution : we can load any model from helper or library by instantiating the ci global object using call by refrence as following:

5: Get rendered html of your view in a Controller’s varriable

Solution : Use third parameter as true in this load view


check value already exists in codeigniter

Callback function of codeigniter which checks whether the value already exists in particular column of table or not.

This function work on add and edit both cases,it return false if value exists and return true if value not exists.

following is the function that you need to put in your controller file:

Note: change the table name in function and in edit case you can change the primary key!= with your table’s key name.

Now time to using this callback function for adding and editing forms.We need to pass the callback function in validation rules.

For the time of adding you can pass the rule in your add action like as:

and in your edit action you can use the rule as following:

Thanks for reading full article , Now use it in your project and if you face any trouble then comment here.


Hi Geeks,
I am sharing you a program for creating a captcha script using php and javascript. Following are the simple steps to create captcha in php

Step 1: Create a php script named ‘captcha.php’ with following code that generate and return a captcha image.

Step 2: Now create a captcha.js file and put following code in the file.

Step 3: Now we need to create a Placeholder Element inside the form as following:

Step 4: Now after submitting you from validate the captcha was right or not. So in your form submit action use following code.

Note 1: In which page/form you are using the capcha , there should be session start in top of the file as following:

and also include the js file in your php page head section. jquery should be available before the captcha.js inclusion as following:



Pagination code using php and mysql

Hi Geeks,
We have gone through some user requests for pagination code for php mysql project.So we have created a simple class where you can easily create pagination for any grid or listing. following are the simple steps for making a pagination system in php.

Step 1: Create a class file ‘Paginator.class.php’ in your project with following code snippet

Step 2: Include the paging class before extracting data to show

Step 3: Now extract the data for any page as following

Step 4 : Now we are ready with data. So just showing the data and links as following

> Show the data first and after it showing the pagination links as following:

> Show the paging links after the data