Important alert: (current site time 7/15/2013 8:43:06 PM EDT)
 

VB icon

Auctionpal

Email
Submitted on: 2/2/2002 12:16:12 PM
By: Robert Gilbertson 
Level: Intermediate
User Rating: Unrated
Compatibility: 5.0 (all versions)
Views: 9294
author picture
(About the author)
 
     IMPORTANT!!!! EBAY HAS CHANGED THE WAY CLOSED AUCTIONS ARE DISPLAYED, AND THIS CODE WILL NO LONGER WORK AS IT IS AT PRESENT. THE MODIFICATIONS NEEDED WILL BE MADE TO THIS CODE IN THE NEXT FEW DAYS. PLEASE BE PATIENT! This script allows you to send winning bidders a link to pay for their Ebay.com auction using Paypal. you simply send them the link in the format http://www.yoursite.com/cgi-bin/auctionpal.cgi?1234567890 (where 1234567890 is the auction number. In order to use this script, you need to have the perl LWP module installed, be an ebay.com seller (not ebay.co.uk or the such)- selling is US Dollars, and a Paypal business or premier account holder.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
=**************************************
= for :Auctionpal
=**************************************
Do what you want with this script, so long as it falls within the GPL.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
=**************************************
= Name: Auctionpal
= Description:IMPORTANT!!!! EBAY HAS CHANGED THE WAY CLOSED AUCTIONS ARE DISPLAYED, AND THIS CODE WILL NO LONGER WORK AS IT IS AT PRESENT. THE MODIFICATIONS NEEDED WILL BE MADE TO THIS CODE IN THE NEXT FEW DAYS. PLEASE BE PATIENT!
This script allows you to send winning bidders a link to pay for their Ebay.com auction using Paypal. you simply send them the link in the format http://www.yoursite.com/cgi-bin/auctionpal.cgi?1234567890 (where 1234567890 is the auction number. In order to use this script, you need to have the perl LWP module installed, be an ebay.com seller (not ebay.co.uk or the such)- selling is US Dollars, and a Paypal business or premier account holder.
= By: Robert Gilbertson
=
= Inputs:Just the auction number. The script actually checks that the auction is closed, and retrieves the winning price from Ebay.
=
= Returns:The Paypal payment screen - over Paypal's secure server.
=
= Assumes:If you can't get it to work, Email me before posting bad feedback.
=
= Side Effects:It won't work unless you have the LWP Perl module installed, don't have an appropriate PayPal account, or if Ebay changes it's route to retrieving auction data.
Also, it won't work unless you CHMOD it (or set it's attributes using the file manager) to make it executable by the end user!
=
=This code is copyrighted and has= limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=278&lngWId=6=for details.=**************************************

#!/usr/bin/perl -wT
use strict;
#Edit the above line if you have a different path to perl.
#If in doubt, contact your Internet Host.
##########################################################################
# --------------------IMPORTANT----------------
# This script requires the LWP Perl Plug-in.
# Check it's available
# before uploading this script!
##########################################################################
# AuctionPal v.1.0 - This is a Beta - not
# the official release.
# Distributed free under the GPL.
# Use at your own risk!
# This copyright notice must remain intact.
# If you modify it, you must
# append the changes to the log below. I take
# credit for writing the program.
# You take responsibility for amendments.
# © 2002 Robert Gilbertson.
# www.robert-gilbertson.co.uk
# auctionpal@robert-gilbertson.co.uk
#
# -----------Modification Log.------------
#
#
#
#
############################
# Edit the following section
############################
# Website Information
# The URL of your website"
my $homeurl = 'http://www.myweb.com';
############################
# Paypal Information
# The Email address you have registered with PayPal
my $paypalemail = 'me@myisp.com';
# The URL buyers will be directed to after payment.
my $onpay = 'http://www.myweb.com/paid.html'; 
# URL buyers directed to if they cancel payment.
my $oncancel = 'http://www.myweb.com/cancel.html'; 
############################
# Carriage Options
# A set fee is charged for carriage. What is it?
# Don't use the dollar symbol!
my $carriage = "3.00";
#############################
# DO NOT MODIFY THESE 2 LINES
use LWP::Simple;
print "Content-type: text/html\n\n";
#############################
# THIS IS THE HEADER HTML
# MODIFY IT AS YOU SEE FIT
print <<"EOF";
<HTML>
<HEAD>
	<TITLE>Ebay Auction winner - Pay now with Paypal</TITLE>
</HEAD>
<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#000088 VLINK=#000088 ALINK=#000088>
<body topmargin="0" leftmargin="0" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<div align="left">
 <table border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFF55" width="100%">
 <tr>
 <td>
 <div align="left">
 <table border="0" cellspacing="0" cellpadding="0" width="100%">
 <tr>
 <td rowspan="2"><img border="0" src="../logo.gif" </td>
 <td width="100%">
 
 </td>
 </tr>
 <tr>
 <td>
 <p align="right"> <H3>Pay for your auction using Paypal! </H3></font></td>
 </tr>
 </table>
 </div>
 </td>
 </tr>
 </table>
</div>
EOF
###
my $url = "http://cgi.ebay.com/aw-cgi/eBayISAPI.dll?ViewItem&item=" . $ENV{'QUERY_STRING'};
if($url eq "http://cgi.ebay.com/aw-cgi/eBayISAPI.dll?ViewItem&item=") {
 print "You didn't enter an auction number!\n";
 exit;
}
my $html = get($url);
my @html = split(/\n/,$html);
my $pricefound = 0;
my $finalprice = "$0.00";
if($html !~ /Auction has ended/i) {
 print "<H2>Sorry!</h2><p> I can't find a finished auction with that number</p>.\n";
 exit;
 }
my $line;
my $status = 0;
my $count = 0;
foreach $line(@html) {
 $count++;
 if($line =~ /Item Price/i) {
 $status = 1;
 }
 if($status == 1) {
 $pricefound = 1;
 if($line =~ /\$/i) {
 $finalprice = $line;
 $status = 0;
 }
 }
 }
####################################
# You don't need to modify anything 
# under this line. If you do, you
# might kill the script, but you
# may also learn something!
#
	my @amt = split(/\$/, $finalprice);
$finalprice = $amt[1]; 
if($count == 0) {
 print "<h2> Error:</h2> <p>Unable to contact Ebay, please try later</p>\n";
 exit;
}
if($pricefound == 0) {
 print "<h2> Error:</h2> Unable to get price from Ebay. Please try later!\n";
 exit;
}
print "Your High Bid was \$$finalprice plus \$$carriage Carriage";
my $total = &parseprice($finalprice + $carriage);
print " making a Grand Total of \$$total";
&paypal;
#-#############################################
# Sub: parse bid
# This formats a bid amount to look good...
# ie. $###.##
sub parseprice {
	$_[0] =~ s/\,//g; 
	my @gtotal = split(/\./, $_[0]);
	$gtotal[0] = "0" if (!($gtotal[0]));
	$gtotal[0] = int($gtotal[0]);
	$gtotal[1] = substr($gtotal[1], 0, 2);
	$gtotal[1] = "00" if (length($gtotal[1]) == 0);
	$gtotal[1] = "$gtotal[1]0" if (length($gtotal[1]) == 1);
	return "$gtotal[0].$gtotal[1]";
}
sub paypal {
my $refno = $ENV{'QUERY_STRING'};
my $shop = "Ebay Auction Number " . $ENV{'QUERY_STRING'};
print <<PPL;
<h3 align="center"><font color="#000080"><b>Paypal payment<P></b>
Click the logo below to process your payment!</font></h3><hr>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<p align="center">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="$paypalemail">
<input type="hidden" name="item_name" value="$shop">
<input type="hidden" name="item_number" value="$refno">
<input type="hidden" name="amount" value="$total">
<input type="hidden" name="return" value="$onpay">
<input type="hidden" name="cancel_return" value="$oncancel">
<input type="image" src="http://images.paypal.com/images/x-click-butcc.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, and secure!" width="73" height="44">
</form>
PPL
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.