Stripe Payment gateway integration in PHP with DEMO Examples

Stripe Payment gateway integration in PHP with DEMO Examples

In this Post We Will Explain About is Stripe Payment gateway integration in PHP with DEMO Examples With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Integrating Payments with the Stripe APIExample

In this post we will show you Best way to implement Stripe payment gateway integration in php source code, hear for How to Integrate Stripe Payment Gateway in PHPwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Stripe payment gateway There are following 2 ways of simple integration using PHP.
1.Stripe checkout integration using PHP
2.Stripe custom integration using (Stripe.js)

Integrate Stripe Payment Gateway Using PHP and JavaScript

Below source code to example learn the custom stripe integration with stripe.js as well as stripe_payment_aip_checkout_example.php.





Live24u Stripe Pay Checkout using PHP


Live24u Stripe Pay Checkout using PHP

<script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="" data-amount="6925" data-name="Pakainfo.com" data-description="Donation" data-image="https://www.pakainfo.com/w3free/img/angular.jpg" data-locale="auto" data-zip-code="true">

stripe_payment_aip_checkout_example.php

	
<?php
/**
 * Pakainfo.com Source Code - Stripe - Payment Gateway integration using PHP (Stripe Checkout)
 * ==============================================================================
 * 
 * @version v8.0: stripe_payment_aip_checkout_example.php 2018/10/05
 * @copyright Copyright (c) 2018, http://www.Pakainfo.com
 * @author DSP Patel 
 * You are very 100% free to use, simple distribute, as well as modify your Source Code
 * ==============================================================================
 *
 */

// simple include Stripe library
require 'stripe/Stripe.php';

$liveparam = array(
	"testmode"   => "on",
	"private_live_key" => "sk_test_a12RX6Z48Jdkl6mEag4Gd6al",
	"public_live_key"  => "pk_test_a12RX6Z48Jdkl6mEag4Gd6al",
	"private_test_key" => "sk_test_a12RX6Z48Jdkl6mEag4Gd6al",
	"public_test_key"  => "pk_test_a12RX6Z48Jdkl6mEag4Gd6al"
);

if ($liveparam['testmode'] == "on") {
	Stripe::setApiKey($liveparam['private_test_key']);
	$pubkey = $liveparam['public_test_key'];
} else {
	Stripe::setApiKey($liveparam['private_live_key']);
	$pubkey = $liveparam['public_live_key'];
}

if(isset($_POST['stripeToken']))
{
	$amount_cents = str_replace(".","","600.52");  // your Chargeble amount
	$invoiceid = "14526321";                      // your Live Invoice ID
	$description = "Invoice #" . $invoiceid . " - " . $invoiceid;

	try {
		$success_payments = Stripe_Charge::create(array(		 
			  "amount" => $amount_cents,
			  "currency" => "usd",
			  "source" => $_POST['stripeToken'],
			  "description" => $description)			  
		);

		if ($success_payments->card->address_zip_check == "fail") {
			throw new Exception("zip_check_invalid");
		} else if ($success_payments->card->address_line1_check == "fail") {
			throw new Exception("address_check_invalid");
		} else if ($success_payments->card->cvc_check == "fail") {
			throw new Exception("cvc_check_invalid");
		}
		// PHP Payment has succeeded simple, no exceptions were any more thrown as well as otherwise caught				

		$result = "success";

	} catch(Stripe_CardError $e) {			

	$error = $e->getMessage();
		$result = "declined";

	} catch (Stripe_InvalidRequestError $e) {
		$result = "declined";		  
	} catch (Stripe_AuthenticationError $e) {
		$result = "declined";
	} catch (Stripe_ApiConnectionError $e) {
		$result = "declined";
	} catch (Stripe_Error $e) {
		$result = "declined";
	} catch (Exception $e) {

		if ($e->getMessage() == "zip_check_invalid") {
			$result = "declined";
		} else if ($e->getMessage() == "address_check_invalid") {
			$result = "declined";
		} else if ($e->getMessage() == "cvc_check_invalid") {
			$result = "declined";
		} else {
			$result = "declined";
		}		  
	}
	
	echo "
Pakainfo.com - Stripe Payment Status : ".$result; echo "
Pakainfo.com Stripe Response : "; print_r($success_payments); exit; } ?>

Browse source code in github :
Example

I hope you have Got What is Integrate Stripe Payment Gateway Using PHP and JavaScript And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment