CodeIgniter Stripe Payment Gateway Api Integration

CodeIgniter Stripe Payment Gateway Api Integration

In this Post We Will Explain About is CodeIgniter Stripe Payment Gateway Api Integration With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Stripe payment gateway integration – Codeigniter – PHP Example

In this post we will show you Best way to implement Integration Stripe payment gateway in codeigniter, hear for Create integrate stripe payment gateway in Codeigniterwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Stripe Payment API integration in CodeIgniter

Stripe is simple and one of the most powerful secure payment gateway for Web-application and Mobile payment.

Now you can download the stripe PHP library from here GITHUB Download and place in the your directory libraries directory in PHP codeigniter location Like as a(codeigniter/application/libraries) and rename the directory to Stripe.

stripe payment gateway in php

Once we click on the create account setting as well as click on the simple app keys get to get secret key and config and simple put publishable key. we will see simple the screen source code below

stripe gateway in PHP

And then create a new file name like as a stripe.php in the view HTML Directory and simple put down the Like this below source code.

<span style="font-size:12px;"><span style="font-family:arial,helvetica,sans-serif;"><!DOCTYPE html>
<html lang="en">
<body>
<div class='web'>
<form action="<?php echo site_url('Stripe_payment/checkout');?>" method="POST">
<script src="https://checkout.stripe.com/checkout.js"
class="stripe-button"
data-key="XXX_YOUR_PUBLISHER_KEY"
data-image="https://www.pakainfo.com/w3free/img/angular.jpg"
data-name="Pakainfo.com"
data-description="Pakainfo.com ($100.00)"
data-amount="485265" />
</script>
</form>
</div>
</body>
</html></span></span>

Now simple create a new controller name Stripe_payment.php and then copy the following simple source code Below:

<span style="font-size:13px;"><span style="font-family:arial,helvetica,sans-serif;"><?php
defined('BASEPATH') OR exit('No direct script access allowed');
//in controller  
class Stripe_payment extends CI_Controller {
 //in __construct
 public function __construct() {
  
 parent::__construct();
  
 }
  //call routing First index function using CI
          public function index()
         {
             $this->load->view(stripe);
          }
  
 public function checkout()
 {
 try 
 { 
	 require_once(APPPATH.'libraries/Stripe/lib/Stripe.php');//or we
	 Stripe::setApiKey("YOUR_SECRET_KEY"); //create new app to Replace with your stripe Secret Key
	 //pass param to create a user 
	 $charge = Stripe_Charge::create(array(
	 "amount" => 10000,
	 "currency" => "usd",
	 "card" => $_POST['stripeToken'],
	 "description" => "Demo Live24u"
	 ));
	 echo "<h1>Pakainfo.com - > Your payment has been completed.</h1>"; 
 }
  //catch part
 catch(Stripe_CardError $e) {
 
	 // Since it's a decline, \Stripe\Error\Card will be caught
		  $body = $e->getJsonBody();
		  $err  = $body['error'];

		  print('Status is:' . $e->getHttpStatus() . "\n");
		  print('Type is:' . $err['type'] . "\n");
		  print('Code is:' . $err['code'] . "\n");
		  // param is '' in this case
		  print('Param is:' . $err['param'] . "\n");
		  print('Message is:' . $err['message'] . "\n");
  
 }
	 catch (Stripe_InvalidRequestError $e) {
	 } 
	 catch (Stripe_AuthenticationError $e) 
	 {
	 } 
	 catch (Stripe_ApiConnectionError $e) 
	 {
	 } 
	 catch (Stripe_Error $e) 
	 {
	 } 
	 catch (Exception $e) 
	 {
	 }
 }
  
}</span></span>

Example

I hope you have Got What is php – Stripe payment gateway integration in codeigniter And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.


Related FAQ

Here are some more FAQ related to this Article:

  1.   ng-table using Angular Example
  2.   How to Get Codeigniter last inserted ID from database
  3.   CodeIgniter CRUD Example Tutorial From Scratch
  4.   User Profile Edit Script Update Script Laravel 7/6
  5.   Convert Array to XML and XML to Array using PHP
  6.   VueJS Conditional Show And Hide, v-if multiple conditions
  7.   Laravel Ajax Upload file image without submitting form
  8.   Stripe Payment gateway integration in PHP with DEMO Examples
  9.   PHP Stripe api Send Accept Payment Integration
  10.   Dynamic breadcrumbs in Vue JS