how to integrate stripe payment gateway in php?

Today, We want to share with you how to integrate stripe payment gateway in php.In this post we will show you payment gateway in php and mysql, hear for Steps to integrate the Stripe payment gateway we will give you demo and example for implement.In this post, we will learn about Stripe Payment gateway integration in PHP with DEMO Examples with an example.

Stripe Payment Gateway Integration in PHP

first of all make an account in Stripe and generate the required keys. you can Generate Stripe API Keys and then GO to Go to > Developers > API Keys

Create Stripe Payment Form

Let’s make a basic html from to receive payment or make the transaction. You need from fields for card number, card expiry month, card expiry year and CVV. You need to add data-stripe tag to each from fields to our JavaScript can read the form value and validate the form without reloading the page.

Date stripe value for

  • – Card Number is data-stripe=”number”
  • – Expiry Month is data-stripe=”exp_month”
  • – Expiry Year is data-stripe=”exp_year”

Example 1:

Validate card through Stripe JavaScript library

We need to include JavaScript file provide by stripe to validate card information.

Make a payment now

In this demo i made the transaction amount fixed value as $1.00, you can create it any value, But keep it in your mind that Stripe only accept value in some of the dollar cents. If you want a transaction of $1.00 then $amount = 100; If you want a transaction of $1500 then $amount=150000; Also you required to define the currency and USD or CAD etc.

		"currency"         => "usd",
		"source"         => $tokenid,
		"description"     => $description)              
		$id            = $charge['id'];
		$amount     = $charge['amount'];
		$balance_transaction = $charge['balance_transaction'];
		$currency     = $charge['currency'];
		$status     = $charge['status'];
		$date     = date("Y-m-d H:i:s");
		$result = "succeeded";

	}catch(Stripe_CardError $e) {            
		$error = $e->getMessage();
		$result = "declined";

Test Card Details

You can use any list of all the card from the bellow as well as for CVV any 3 digit number as well as Expiry date any month with year from the current active month and year.

  • 4242424242424242 => Visa card information
  • 4000056655665556 => Visa (debit) card information
  • 5555555555554444 => Mastercard card information
  • 5200828282828210 => Mastercard (debit) card information
  • 378282246310005 => American Express card information
  • 6011111111111117 => Discover card information

I hope you get an idea about debit card payment gateway integration in php.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment