Home » PayPal Payment Gateway PHP Source Code

PayPal Payment Gateway PHP Source Code

Today, We want to share with you PayPal Payment Gateway PHP Source Code.In this post we will show you paypal payment gateway integration in php source code download & How to Set Up Paypal Payment Gateway Integration in PHP, hear for Payment gateway integration in PHP With Database Connection we will give you demo and example for implement.In this post, we will learn about Paypal payment gateway integration code with PHP, Mysql project with an example.

PayPal Payment Gateway PHP Source Code

There are the Following The simple About payment gateway in php source code Full Information With Example and source code.

As I will cover this Post with live Working example to develop Paypal Payment Gateway Integration in PHP, so the PayPal PHP Website Integration Tutorial for this example is following below.

Read Also:  PHP Laravel Dynamically Add Active Navigation Class Example
PHP – Paypal Payment Gateway Integration Step By Step

Step 1: create a PHP file

Paypal Example PHP Source Code

CREATE TABLE `payments` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `item_number` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `txn_id` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `payment_amount` float(10,2) NOT NULL,
 `currency_code` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
 `payment_status` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Step 2: PHP Source Code

index.php

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

<title>Paypal :: PayPal Payment Gateway Integration in PHP with mysql </title> 

</head> 

<body> 

    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">        

        <input type="hidden" name="business" value="paypal_username">         

        <!--PHP Specify a Buy Now button. --> 

        <input type="hidden" name="cmd" value="_xclick">         

        <!-- Specify details about the item that buyers will purchase. --> 

        <input type="hidden" name="item_name" value="item_name"> 

        <input type="hidden" name="item_number" value="item_number"> 

        <input type="hidden" name="amount" value="Item_amount"> 

        <input type="hidden" name="currency_code" value="USD">        

        <!--PHP Specify URLs --> 

        <input type='hidden' name='cancel_return' value='https://www.pakainfo.com/paypal_integration_php/paypal_cancel.php'> 

<input type='hidden' name='return' value='https://www.pakainfo.com/paypal_integration_php/paypal_success.php'>         

        <!-- PHP Display the payment button. --> 

        <input type="image" name="submit" border="0" 

        src="https://www.pakainfo.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal Payment Gateway Integration in PHP with mysql"> 

        <img alt="" border="0" width="1" height="1" src="https://www.pakainfo.com/en_US/i/scr/pixel.gif" >     

    </form> 
</body> 

</html>

Setp 3: database connection

connection.php

define('HOST', 'localhost'); 

define('USERNAME', '{Jaydeep_gondaliya}'); 

define('PASSWORD', '{[email protected]#$%&89865}'); 

define('DATABASE_NAME', 'my_shop'); 

//MySQL Database Connect and select the database 

$db = new mysqli(HOST, USERNAME, PASSWORD, DATABASE_NAME); 

if ($db->connect_error) { 

    die("Connection failed: " . $db->connect_error); 

}

Step 4 : Save Data

Useing item_no,transaction_id,amt,currency_code,payment_status

Read Also:  Ajax File Upload without refreshing using jQuery and PHP

And then Last Step I need to make a simple success file as well as show some transaction details which data received from paypal .

<?php 

include 'connection.php'; 

//save all the Useful PHP value Trasaction information form PayPal 

$item_number = $_GET['item_number']; 

$txn_id = $_GET['Trasaction_ID']; 

$payment_gross = $_GET['AMT']; 

$currency_code = $_GET['CURRENCY_CODE']; 

$payment_status = $_GET['PAYMENT_STATUS']; 


if(!empty($txn_id)){ 

        //Insert tansaction data into the database 

        $insert = $db->query("INSERT INTO payments(item_number,txn_id,payment_amount,currency_code,payment_status) VALUES('".$item_number."','".$txn_id."','".$payment_gross."','".$currency_code."','".$payment_status."')"); 

        $result_payment_id = $db->insert_id;  

?> 
<h1>Good Luck, Your payment has been successful.</h1> 
    <h1>here display, Your Payment ID - <?php echo $result_payment_id; ?>.</h1> 
<?php 
}else{ 
?> 
<h1>Your payment has failed.</h1> 
<?php 
} 

?>

Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  PayPal Payment Gateway with PHP MySQL Database

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PayPal Payment Gateway PHP Source Code.
I would like to have feedback on my Pakainfo.com 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.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Simple Laravel CRUD Validation Tutorial
  2. Read Also:  switch statement java | java switch case
  3. Read Also:  PHP Laravel 6 Flash Message Notification
  4. Read Also:  jQuery Ajax Login Script using PHP MySQLi
  5. Read Also:  Advanced jQuery Ajax Pagination PHP MySQL using jQuery
  6. Read Also:  Dropzone Multiple File Upload using PHP Example
  7. Read Also:  Simple Vue JS MultiSelect Dropdown Example
  8. Read Also:  SQL GROUP BY and HAVING Clause with Examples
  9. Read Also:  Simple Laravel CRUD Validation Tutorial
  10. Read Also:  switch statement java | java switch case

Leave a Comment

Your email address will not be published. Required fields are marked *