title: Stripe payment gateway integration in codeigniter
body: <p>I use Stripe payment gateway in codeigniter using stripe.js. In stripe payment process first do client side validation and then after server side validation by stripe php 2.1.1 library. Client side validation working ready but server side validation gives error. I put stripe php 2.1.1 folder in codeigniter library folder.</p>
  
  <p>I refer this link <a href="http://code.tutsplus.com/tutorials/how-to-accept-payments-with-stripe--pre-80957" rel="nofollow">http://code.tutsplus.com/tutorials/how-to-accept-payments-with-stripe--pre-80957</a></p>
  
  <p>code:</p>
  
  <pre><code>    &lt;?php
  $success = "";
  $error = "";
  
  require_once(APPPATH.'libraries/stripe/lib/Stripe.php');
  
  if ($_POST) {
    Stripe::setApiKey("dm_wsdst_yJQB5mrfjpfQX2uMQHf3CbD");
    $error = '';
    $success = '';
    try {
      if (!isset($_POST['stripeToken']))
        throw new Exception("The Stripe Token was not generated correctly");
      Stripe_Charge::create(array("amount" =&gt; 11,
                                  "currency" =&gt; "usd",
                                  "card" =&gt; $_POST['stripeToken']));
      $success = 'Your payment was successful.';
    }
    catch (Exception $e) {
      $error = $e-&gt;getMessage();
    }
  }
  
  echo "sucess". isset($success) ? $success : "";
  echo "error".isset($error) &amp;&amp; $success ? $error : "";
  
  ?&gt;
  
  
  
  &lt;script type="text/javascript" src="https://js.stripe.com/v2/"&gt;&lt;/script&gt;
  &lt;script&gt;
      Stripe.setPublishableKey('es_iksl_l5li2xygPS9cJE5MMWE8GSr');
  &lt;/script&gt; 
  
  &lt;div class="content_white register_wrapper"&gt;
      &lt;div class="content_40" style="margin-left:350px;"&gt;
              &lt;div class="content_gray" style="margin-top: 50px;"&gt;
                      &lt;form method="post" name="payment_form" id="payment_form"&gt;
                              &lt;div class="error" id="payment_error"&gt;&lt;/div&gt;
                              &lt;div class="box" style="padding: 15px 0;"&gt;    
                                      &lt;label&gt;Card Number&lt;/label&gt;
                                      &lt;input type="text" class="text_box" placeholder="Card Number" data-stripe="number" id="card_number" name="card_number" style="height: 40px;" /&gt;
                                      &lt;div class="error" id="form_fname_error"&gt;&lt;/div&gt;
                              &lt;/div&gt;
  
                              &lt;div class="box" style="padding: 15px 0;"&gt;    
                                      &lt;label&gt;Card CVC No&lt;/label&gt;
                                      &lt;input type="text" class="text_box" placeholder="CVC Number" data-stripe="cvc" id="cvc_number" name="cvc_number" style="height: 40px;" /&gt;
                                      &lt;div class="error" id="form_lname_error"&gt;&lt;/div&gt;
                              &lt;/div&gt;
                              &lt;br&gt;
                              &lt;div class="box" style="padding: 0px"&gt;
                                  &lt;label&gt;Card Expiration Month/Year (MM/YYYY)&lt;/label&gt;
                              &lt;/div&gt;
                              &lt;div class="box" style="padding: 15px 0; width: 30%;float: left;"&gt;
                                  &lt;input type="text" class="text_box" placeholder="Month-(MM)" data-stripe="exp-month" id="exp_month" name="exp_month" style="height: 40px;" /&gt;
                                      &lt;div class="error" id="email_error1"&gt;&lt;/div&gt;
                              &lt;/div&gt;
  
                              &lt;div class="box" style="padding: 15px 0; width: 50%;float: left;" &gt;
                                  &lt;input type="text" class="text_box" placeholder="Year-(YYYY)" data-stripe="exp-year" id="exp_year" name="exp_year" style="height: 40px;" /&gt;
                                      &lt;div class="error" id="form_password_error"&gt;&lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="clear"&gt;&lt;/div&gt;
                              &lt;div class="box" style="text-align:center;"&gt;
                                  &lt;div class="submit_btn"&gt;
                                      &lt;input type="submit" class="btn_blue" id="submit_btn" value="Pay $20"/&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="clear"&gt;&lt;/div&gt;
                      &lt;/form&gt;
              &lt;/div&gt;
      &lt;/div&gt; 
      &lt;div class="clear"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;script&gt;
      $(document).ready(function(){
  
  
          $('#payment_form').submit(function(event) {
          console.log("start");
          var $form = $(this);
          // Disable the submit button to prevent repeated clicks
          $form.find('#submit_btn').prop('disabled', true);
           Stripe.createToken({
                          number: $('#card_number').val(),
                          cvc: $('#cvc_number').val(),
                          exp_month: $('#exp_month').val(),
                          exp_year: $('#exp_year').val()
                      }, stripeResponseHandler);
  
          // Prevent the form from submitting with the default action
          return false;
        });
  
          });
          // Call back function for stripe response.
              function stripeResponseHandler(status, response) {
  
                  console.log("ststus"+status);
                  if (response.error) {
                      // Re-enable the submit button
                      $('#submit_btn').removeAttr("disabled");
                      // Show the errors on the form
  //                    stripeErrorDisplayHandler(response);
                      $('#payment_error').text(response.error.message);
  //                    $('.subscribe_process').hide();
                  } else {
                      var form = $("#payment_form");
                      // Getting token from the response json.
  
                      $('&lt;input&gt;', {
                              'type': 'hidden',
                              'name': 'stripeToken',
                              'value': response.id
                          }).appendTo(form);
  
                      // Doing AJAX form submit to your server.
                      form.get(0).submit();
                      return false;
                  }
              }
  &lt;/script&gt;
  </code></pre>
  
  <p>When i run this file then run ready, and when i click on pay button then check card data and expiration month and year if it is ok then return stripeToken then resubmit form again then it will return error that is </p>
  
  <blockquote>
    <p>Fatal error: Class 'Stripe' not found in
    D:\xampp\htdocs\moviesaints\application\views\user\payment_precess.php
    on line 12</p>
  </blockquote>
  
  <p>Any idea give me solution. </p>