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

<?php
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");
}
Stripe::setApiKey(STRIPE_SECRET_KEY);
?>

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

<?php require_once('config.php'); ?>
<?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="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="stripe publish key" data-description="Add your payment description" data-amount="amount*100" data-locale="auto"></script>
</form>

Download Stripe Library