Codeexecute | Online Forum To Support Coders With Technical Assistance

Stripe payment gateway integration in php

Stripe is one of the best payment gateways for online transactions. It allows credits cards directly through websites to your stripe account.

Create a file name config.php and write some configuration

require_once('your stripe library path/stripe.php');

define("STRIPE_MODE", "test"); //live

define('STRIPE_SECRET_KEY', "Your test stripe secret key");
define('STRIPE_PUBLISH_KEY', "Your test stripe publish key");

if(STRIPE_MODE == "live")
	define('STRIPE_SECRET_KEY', "Your live stripe secret key");
	define('STRIPE_PUBLISH_KEY', "Your live stripe publish key");



Create a new file name form.php and write following code

<?php require_once('config.php'); ?>


$aAmount = your amount*100; // you need to multiple your usd amount to 100 for stripe api

if(isset($_POST['stripeToken']) && isset($_POST['stripeEmail']))
	$aToken  = $_POST['stripeToken'];
	$aEmail  = $_POST['stripeEmail'];
	$aCustomer = Stripe_Customer::create(array(
		'email' => $aEmail,
		'source'  => $aToken

	$aCharge = Stripe_Charge::create(array(
		'customer' => $aCustomer->id,
		'amount'   => $aAmount,
		'currency' => 'usd'

	// Add your code for further development


<form action="" method="post">
  <script src="" class="stripe-button" data-key="stripe publish key" data-description="Add your payment description" data-amount="amount*100" data-locale="auto"></script>

Download Stripe Library


Useful shortcodes for woocommerce plugin

Woo-commerce is an open source WordPress plugin to build own online store. Woo-commerce is the more popular eCommerce solution.It comes with many shortcodes that help to expand functionality

My Account Page


Cart Page


Checkout Page


Products Display


Add to cart

[add_to_cart id="product id"]

For more details click here


How to declare a function in Javascript using constructor method?

In class-based object-oriented programming, a constructor is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.

Since JavasScript is also an object-oriented programming launguage, there is also constructor methods in JS to create an object.
As we know everyting in JS is an object including fucntion , so can we declare the function as constructor in JS. The answer is yes.

Traditional Syntax

function sum(x, y) {
return x + y;

Constructor Syntax

let sum_ctr = new Function("x", "y", "return x + y;");

Send email using gmail in CodeIgniter

You can send email using gmail by using below code.


$aConfig = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://',
'smtp_port' => 465,
'smtp_user' => 'Your gmail email',
'smtp_pass' => 'Your gmail password',
'mailtype' => 'html',
'charset' => 'utf-8'
$this->email->from('Your from email', 'Your from name');
$this->email->to("Your receiver email");
$this->email->bcc("Your bcc email"); // optional
$this->email->subject("Your email subject");
$this->email->message("Your email body");
	echo "email sent";
	echo "email not sent";

Remove public from url in laravel

By using following steps we can remove public from url

  • Rename server.php to index.php at laravel root folder
  • Copy .htaccess file from public folder to root folder and update code mentioned below

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]