Send payment instructions to your customers automatically.
Here's a simple script that will scan all your auctions that have ended in the last 24 hours and send a payment-instructions email to each high bidder:
#!/usr/bin/perl require 'ebay.pl'; $template = "template.txt"; $today = &formatdate(time); $yesterday = &formatdate(time - 864000); my $page_number = 1; PAGE: while (1) { my $rsp = call_api({ Verb => 'GetSellerList', DetailLevel => 8, UserId => $user_id, EndTimeFrom => $yesterday, EndTimeTo => $today, PageNumber => $page_number }); if ($rsp->{Errors}) { print_error($rsp); last PAGE; } foreach (@{$rsp->{SellerList}{Item}}) { my %i = %$_; ($id, $title, $currency, $price, $highbidder, $checkout) = @i{qw/Id Title CurrencyId CurrentPrice HighBidder Checkout/}; $bidder email = $highbidder->{User}{Email}; if ($bidderemail =~ "\@") { $shipping = $checkout->{Details}{ShippingHandlingCosts}; $total = $price + $shipping; open(MAIL,"|/usr/sbin/sendmail -t"); print MAIL "To: $bidderemail\n"; print MAIL "From: $selleremail\n"; print MAIL "Reply-To: $selleremail\n"; print MAIL "Subject: $title\n\n"; open (COVER, "$localdir/$template"); while ( $line = <COVER> ) { if ($line eq "<insert title here>\n") { print MAIL $title; } elsif ($line eq "<insert item here>\n") { print MAIL $id; } elsif ($line eq "<insert shipping here>\n") { print MAIL $currency . sprintf("%0.2f", $shipping); } elsif ($line eq "<insert total here>\n") { print MAIL $currency . sprintf("%0.2f", $total); } else { if ($line eq "\n") { $line = "$line\n"; } else { chomp $line; } print MAIL $line; } } close(COVER); close(MAIL); } } last PAGE unless $rsp->{SellerList}{HasMoreItems}; $page_number++; }
This script requires the email template from "Streamline Payment
Instructions" [Hack #95] ; just place it in the
directory specified by $localdir
in
your config.pl include file.
The amount charged for shipping is taken from the Checkout. Details. ShippingHandlingCosts
field, which is suitable if you've specified fixed shipping costs. If
you're using eBay's Calculated Shipping feature [Hack
#59] , then you'll need to use the GetShippingRates
function. Simply pass it
these fields (all children of Checkout.Details
), and it will give you the
same information your winning bidder sees:
ShipFromZipCode, ShipToZipCode, ShippingPackage, WeightUnit, WeightMajor, and WeightMinor
Note also that this script will need to be modified in order to
accommodate Dutch auctions. Use the GetHighBidders
API call to retrieve multiple
high bidders and the quantities they purchased for any single Dutch
auction. Naturally, you'll need to supplement the shipping cost
calculations to account for any per-item shipping expenses.
The script in this hack retrieves the list of completed auctions
for the last 24 hours, just like most of the other scripts in this
chapter that use GetSellerList.
Refer to "Automatically Keep Track of Auctions You've Won" [Hack #110] for details on scheduling and running the script at regular intervals.
There is another approach. Sign up to receive notifications such
as AuctionEndOfAuction,
CheckoutBuyerRequestsTotal, AuctionCheckoutComplete,
and
FixedPriceEndOfTransaction,
and
eBay's server will send the appropriate information to you as soon as
the event is triggered, and you can then do your post-auction
processing on an auction-by-auction basis.
Unfortunately, notifications are not available to developers with the free Individual license (discussed at the beginning of this chapter), but if you're operating under a Basic, Professional, or Enterprise license, you can sign up to receive notifications at developer.ebay.com. Look up "Getting Started with eBay Platform Notifications" in the API documentation for details.