Stripe Payment API integration and Card save and delete operation in Codeigniter

Hello Coders, we all know about Stripe payment gateway which is very secure and easy to implement in any language. If you want to integrate any payment gateway on very short steps than Stripe is best.

Today we will learn about how we integrate Stripe Payment Gateway in CodeIgniter and how to add customer’s or user’s card details to the stripe account and also how we provide access to the user how they delete the card details from the stripe.

Download Stripe Library

First, we download the CodeIgniter framework from than download stripe library from link:

Setting API key on Code

On Codeigniter, you have to set API key on the path: application/config/config.php

You get those code from here, create an account on the stripe and open dashboard go to below picture path info.

After setup the API credentials you have to create route of stripe


After that, you use below code on your controller for the further process where we save card details of particular user and also delete, check code below,

Main Points for Card detail process:

    1. First thing for saving new card details on stripe account of particular user you have to use CUSTOMER ID, I give you details about after the first payment of any user you can retrieve customer id using your database, on the time of first payment you store the payment data so from there you can retrieve the CUSTOMER ID.
    2. After getting customer ID, you can save the particular customer data using below code,

    3. On the above code we save the card details using PHP library of stripe and now we create a controller for how can any user can delete the card details from sripe accunt using this API. See the code below,


And now we completed both operations with Stripe API. I hope you will find useful thing on that post. If you have any query about programming thing please visit question panel for asking anything about your programming problem.

Happy Coding..!


Subscribe For Latest Updates

Sign up to best of PHP Code Solutions, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.


  • Pingback: Google Sheet Integration with WordPress without Plugin -

  • Commenter's Avatar
    Jason — March 18, 2019 at 2:04 am

    Howdy! Someone in my Facebook group shared this site with us so I came to
    check it out. I’m definitely loving the information. I’m book-marking
    and will be tweeting this to my followers! Superb blog and great style and design. Hello would you mind letting me know which web host you’re utilizing?

    I’ve loaded your blog in 3 different web browsers and I must say this blog loads
    a lot quicker then most. Can you suggest a good internet hosting provider at a reasonable price?
    Many thanks, I appreciate it! You’ve made some decent points there.
    I looked on the internet for more information about the issue and
    found most individuals will go along with your views on this site.

  • Commenter's Avatar
    John — March 24, 2019 at 4:53 pm

    I really like what you guys tend to be up too. This sort of clever work and exposure!
    Keep up the fantastic works guys I’ve included you guys to my blogroll.
    I’ll immediately snatch your rss as I can’t in finding your e-mail subscription link or
    e-newsletter service. Do you’ve any? Kindly let me understand in order that I could subscribe.
    Thanks. I couldn’t resist commenting. Exceptionally well written!

  • Commenter's Avatar
    Kimber Pumphrey — March 25, 2019 at 5:32 am

    When someone writes an article he/she maintains the thought of
    a user in his/her brain that how a user can understand it.
    Therefore that’s why this paragraph is outstdanding.

  • Commenter's Avatar
    RobertaCausey — April 6, 2019 at 1:44 pm

    When someone writes an article he/she keeps the idea of a user in his/her mind that how a user can know it.
    Therefore that’s why this paragraph is perfect.

  • Commenter's Avatar
    Rajveer Singh — December 10, 2019 at 6:53 pm

    Its really very helpful. thanks for sharing and writing this wonderful article. Really appreciate.

  • Pingback: 4 Simple Steps To Braintree Account Setup with API - PHPCODER.TECH

Leave a Comment

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