You discovered our blog Electronic Shop Discounts. Please Remember to bookmark this page Label Paypal. If you enjoy our post Label Paypal, show your love by hitting one of the social media buttons above for this page.
Label Paypal
SMS White Label Paypal Commerce Setup
Paypal transaction using PHP web application
PayPal’s “Buy Now” buttons are ideal for ecommerce impulse sales. They are easy for the customer to use and there’s no lengthy check-out procedure. One click and you’re on PayPal’s secured site. They are also very easy to install and for this reason sometimes get ignored when it comes to tracking and securing sales. This hack shows how to track and secure purchases made using “Buy Now” buttons. We will take you through the steps of creating a “Buy Now” button, modifying it in order to create a database record of the purchase and, finally, we’ll show how to secure this purchase using Instant Payment Notification (IPN).
Creating a "Buy Now" Button
We needn’t worry about manually creating the HTML form for a “Buy Now” button. We only need go to our PayPal account, choose “Merchant Tools” and click on the “Buy Now Buttons” link. Within seconds we have the HTML form to embed in our website. Our “Buy Now” button looks like .
Tracking the Sale
Briefly stated, the code in presubmit.php inserts a record into an orders table and into a related order items table. The order id is then retrieved and added to the query string constructed from the values posted to this page.
The Code
Save this code as buynow.html:
<html>
<head>
<title>Buy Now Button</title>
</head>
<body>
<!-- alter action of form-->
<form action="presubmit.php" method="post">
<label>Purchase: Object-Oriented PHP for 24.95</label>
<input value="_xclick" />
<input value="seller@netultimate.com" />
<input value="Object-Oriented PHP" />
<input value="673498" />
<input value="24.95" />
<input value="1" />
<input value="USD" />
<input src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0" alt="" />
</form>
</body>
</html>
Save this code as connection.php:
<?php
$hostname = "localhost";
$databasename = "books";
$username = "username";
$password = "password";
?>
Save this code as presubmit.php:
<?php
include "connection.php";
//create a connection using mysqli
$con = new mysqli($hostname, $username, $password, $databasename,
3306, "/var/lib/mysql/mysql.sock");
//create an order id
$strsql = "INSERT INTO tblorders SET orderdate = CURDATE()";
$con->query($strsql);
//retrieve insertid - property not method
$id = $con->insert_id;
$item_number = $_POST['item_number'];
//now add order item to db
$strsql = "INSERT INTO tblorderitems SET orderid = ?, ".
"inventorynumber = ?";
//use statement even though only one insert
$stmt = $con->stmt_init();
$stmt->prepare($strsql);
//bind integer and string values
$stmt->bind_param('ii', $id, $item_number);
$stmt->execute();
//resubmit
$querystring = "?";
//loop for posted values
foreach($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$querystring .= "$key=$value&";
}
//update querystring with order id
//use "custom" not "on0" for order id value
$querystring .= "custom=$id";
header('location:https://www.paypal.com/cgi-bin/webscr'.$querystring);
exit();
?>
For Related coding on paypal using PHP you can visit, http://www.netultimate.com
About the Author
Netultimate Services, offshore web development company offering offshore software development services for its customers worldwide and producing own software products.
If you are looking for a different item here are a list of related products on Electronic Shop Discounts, please check out the following:




