Monday 23 November 2015

Stripe Payment Gateway Integrate Using PHP

There are lots of payment gateway available in the web market like PayPal, iTransact, Card Gate Plus, SagePay, ANZ eGate and many more. Today, we are going to introduce one of the most powerful payment gateway for Web and Mobile payment. Yes, we are talking about Stripe Payment Gateway.
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. 


Step 1: Create an account on Stripe https://dashboard.stripe.com/register

Step 2: Login your account and go to Account setting for API Keys.

 

 

Step 3: Download the source code and replace the secret key in payment.php:
<?php
try {  
    require_once('Stripe/lib/Stripe.php');
    Stripe::setApiKey("XXXX_YOUR_SECRET_KEY"); //Replace with your Secret Key  
    $charge = Stripe_Charge::create(array(
                "amount" => 2100,
                "currency" => "usd",
                "card" => $_POST['stripeToken'],
                "description" => "Demo Transaction"
            ));
    //send the file, this line will be reached if no error was thrown above
    echo "<h1>Your payment has been completed.</h1>";
    //you can send the file to this email:
    echo $_POST['stripeEmail'];
}

Step 4: Edit index.php file and replace with your Publishable Key

<script src="https://checkout.stripe.com/checkout.js"
    class="stripe-button"
    data-key="XXX_YOUR_PUBLISHER_KEY" //Replace with your Publishable key
    data-image="http://www.stepblogging.com/wp-content/uploads/2014/12/logo1.png"
    data-name="StepBlogging.com"
    data-description="Demo Transaction ($21.00)"
    data-amount="2100" />
</script>

The test version does not entail any actual funds. However for testing you can use below mentioned detail:
Testing Card Number - 4242424242424242
CVV Number - 1234 
Card Expiry Date - Use any future date

If you have any problem regarding this tutorial configuration please feel free to comment we love to answer your queries.

1 comment:

  1. This blog is so informative for providing a valuable information about bulk sms api php integration.

    ReplyDelete