Saturday, 1 August 2015

How to integrate stripe payment gateway in php

Stripe Checkout New
No need to design payment forms from scratch. Stripe Checkout offers a beautiful, customizable payment flow that works great across desktop and mobile. When you use Checkout, you’re always up-to-date, with no extra code required.
Explore Checkout

Total control with Stripe.js

Stripe.js securely transmits card details from browsers to Stripe. Use it to control every pixel of the experience and let Stripe take care of the pesky processing and compliance.
This is very simple coding for integrate stripe payment in php. please look the copy the code and paste in your working file.           READ MORE

<?php   require 'stripe/lib/Stripe.php';
if ($_POST) {
 // Stripe::setApiKey("pk_test_RLTidE9AhJ0DENd5pLCieMpm");
  $error = '';
  $success = '';
  try {
    if (!isset($_POST['stripeToken']))
      throw new Exception("The Stripe Token was not generated correctly");
    Stripe_Charge::create(array("amount" => 10,
                                "currency" => "usd",
                               "card" => $_POST['stripeToken']));
    $success = 'Your payment was successful.'.$_POST['stripeToken'];
  catch (Exception $e) {
    $error = $e->getMessage();
<!DOCTYPE html>
<html lang="en">
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <title>Stripe Getting Started Form</title>

  <!-- The required Stripe lib -->
  <script type="text/javascript" src=""></script>

  <!-- jQuery is used only for this example; it isn't required to use Stripe -->
  <script type="text/javascript" src=""></script>

  <script type="text/javascript">
    // This identifies your website in the createToken call below
    var stripeResponseHandler = function(status, response) {
      var $form = $('#payment-form');
      if (response.error) {
        // Show the errors on the form
        $form.find('button').prop('disabled', false);
      } else {
        // token contains id, last4, and card type
        var token =;
        // Insert the token into the form so it gets submitted to the server
        $form.append($('<input type="hidden" name="stripeToken" />').val(token));
        // and re-submit
    jQuery(function($) {
      $('#payment-form').submit(function(e) {
        var $form = $(this);
        // Disable the submit button to prevent repeated clicks
        $form.find('button').prop('disabled', true);
        Stripe.card.createToken($form, stripeResponseHandler);
        // Prevent the form from submitting with the default action
        return false;
  <h1>Charge $10 with Stripe</h1>
<span class="payment-errors"><?= $error ?></span>
        <span class="payment-success"><?= $success ?></span>

<form action="" method="POST" id="payment-form">
    src="" class="stripe-button"
    data-name="online Pay with stripe"
    data-description="Your Card items payment"