How to integrate stripe payment gateway in PHP ?

In this tutorial I will explain you how to integrate stripe payment gateway in PHP. There are lots of payment gateway available in the web market like PayPal and many more. Stripe is one of the most powerful payment gateway for Web and Mobile payment.Integration of Stripe payment gateway using PHP is very easy. Just follow few steps and it will be ready.
Stripe take care the processing and keeping client’s card data so no information of essence would be stored on our server and you would not have to comply with all the rules that come with storing credit/debit cards.Stripe is the easiest way to accept credit and debit card payments online. With Stripe, you can create exactly the payment experience you want in your website or mobile app, and we handle everything from security to daily transfers to your bank account.

First create a stripe account on After registration click on my account

stripe payment gateway in php

Once you click on the account setting  click on the app keys to get secret key and publishable key. You will see the screen below

stripe gateway in PHP

Now create a file name index.php and write down the below code

<!DOCTYPE html>
<html lang="en">
<div class='web'>	
	<form action="payment.php" method="POST">
		<script src="" 
		data-image="your site image" 
		data-description="Demo Transaction ($100.00)"
		data-amount="10000" />

Create a new file name and copy the below code

try {	
	Stripe::setApiKey("YOUR_SECRET_KEY"); //Replace with your Secret Key
	$charge = Stripe_Charge::create(array(
		"amount" => 10000,
		"currency" => "usd",
		"card" => $_POST['stripeToken'],
		"description" => "Demo Transaction"
	echo "<h1>Your payment has been completed.</h1>";	
catch(Stripe_CardError $e) {
catch (Stripe_InvalidRequestError $e) {
} catch (Stripe_AuthenticationError $e) {
} catch (Stripe_ApiConnectionError $e) {
} catch (Stripe_Error $e) {
} catch (Exception $e) {

Now download the stripe library from GITHUB and place in the your PHP folder. Your file structure should be like this


stripe payment gateway in PHP

Now you can integrate you payment using stripe.

Testing Card Number – 4242424242424242
CVV Number – 1234 
Card Expiry Date – Use any future date

Hope this tutorial how to integrate stripe payment gateway in PHP will help you.