Hack 77 Use Mass Pay to Create an Affiliate System

 < Day Day Up > 

figs/moderate.gif figs/hack77.gif

Automate payout incentives to affiliates and resellers with PayPal's Mass Pay feature .

A great way to increase your sales is to provide incentives for other people to promote your products and services. This is typically done with an affiliate program, in which you reward those who send traffic to your site by paying them a small fee, usually either a fixed amount per sale or a percentage of the items sold as a result of the affiliate's efforts.

Managing an affiliate system involves tracking all the successful sales from referrals by your affiliates and then paying the affiliates their due on a regular basis. This hack uses IPN [Hack #65] to track affiliate referrals and PayPal's Mass Pay feature to pay all your affiliates at once.

When you use Mass Pay, you (the sender) pay the PayPal fees [Hack #14] .

7.17.1 Creating Your Business Model

The following code employs a simple business model, in which each affiliate gets one dollar for each sale you receive as a result of their referral, regardless of the amount of the sale.

Here's how it works:

  1. Create a sign-up system on your web site, in which prospective affiliates enter their email addresses. Instruct each affiliate to open a PayPal account with that email address.

  2. Generate a custom button [Hack #28] for each affiliate, as described in the next section.

  3. Instruct the affiliate to place the button on his site. If you want to be creative, supply some custom payment button images [Hack #29] to spruce up the button appearance and help attract attention.

  4. Visitors to your affiliate's site see your product advertisement, crave it instantly, and click the Buy Now button. The payment is sent to you and you deliver the product.

  5. Use IPN to record the affiliate's email address (and any other relevant information) into a database.

  6. Use Mass Pay to send a buck per sale to the affiliate responsible.

7.17.2 Building a Button for Your Affiliate

Each affiliate's button should be like any other Buy Now button [Hack #28] , with two important exceptions.

First, include the email address of your affiliate in the custom variable of the button (make sure the payment still goes to you, however). Second, specify the location of your IPN script for handling affiliate program payments in the notify_URL variable:

 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="sales@superfreaker.com"> <input type="hidden" name="item_name" value="Widget"> <input type="hidden" name="item_number" value="Item-123"> <input type="hidden" name="amount" value="10"> <input type="image" name="Submit" value="Submit" src="buynow.gif">  <input type="hidden" name="notify_url"                  value="   http://yoursite/affiliate_ipn.asp   ">   <input type="hidden" name="custom"                  value="   affiliate@theirisp.com   ">  </form> 

Save this button code into a text file and email it to each affiliate. Better yet, create a script on your server that does this automatically, and take yourself out of the loop entirely.

7.17.3 Recording Referred Purchases

The IPN script specified in the notify_url variable receives a post of the transaction details from PayPal when a sale is made from the affiliate's site. The script writes the affiliate tracking information to a tab-delimited text file, along with the amount of the reseller incentive. This example is written in Microsoft VBScript and uses a Windows File System Object to manipulate the file.

Use the following VBScript code in conjunction with a standard IPN validation script, such as the one in [Hack #65] :

 Const fsoForWriting = 2 Dim objFSO Dim objTextStream Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 'Open the text file 1.  vFilePath = "   C:\InetPub\yoursite\affiliates\output\MassPay.txt   " Set objTextStream = objFSO.OpenTextFile(vFilePath, fsoForWriting, True) 'Write the new line to the file 2.  objTextStream.WriteLine custom & "       " &           (rsAffiliateFees.Fields.Item("AffiliateFee").Value) 'Close the file and clean up objTextStream.Close Set objTextStream = Nothing Set objFSO = Nothing 

Replace the example filename on line 1 with the full path of the file in which to save your affiliate data. Make sure you have the proper permissions to write to the file on your server. When using IIS on Windows, for example, you'll probably need to set IUSER (Internet guest) write permissions.

The long space in quotation marks, used to separate the custom variable (here, the affiliate's email address) from the dollar amount paid to the affiliate, is really a tab (ASCII code 9). See http://www.paypal.com/cgi-bin/webscr?cmd=p/ema/batch_format-outside for the latest updates to the specification.

7.17.4 Notifying Your Affiliates

You might want to let your affiliates know whenever you've received a payment as a result of an affiliate referral. They'll be more likely to stay enthusiastic about your affiliate program if they can see it working. Add the following code to your IPN script, after the main IPN processing code [Hack #65] :

 Dim InvCDO Set InvCDO = Server.CreateObject("CDONTS.NewMail") InvCDO.From = receiver_email InvCDO.To = custom InvCDO.Subject = "Affiliate Sale" InvCDO.Body = "You have an affiliate sale. Your affiliate account has       been credited and will be paid according to the schedule       in the affiliate program aggreement." InvCDO.Send( ) Set InvCDO = Nothing 

7.17.5 Paying Your Affiliates en Mass

Making a Mass Payment is easy, especially since the file in which you've recorded your affiliate sales, MassPay.txt , already contains the information in the proper format.

Because sales sometimes fall through (due to customer returns, problems with payments, etc.), you might prefer to wait a good period of time (e.g., 30 days) after the sale before paying your affiliates. And for bookkeeping purposes, you might want to schedule affiliate payments to occur quarterly.

To make the affiliate payments, upload your data file, and PayPal does the rest:

  1. Download the MassPay.txt file from your server and save it on your local hard disk.

  2. Log into your PayPal account, and click the Mass Pay link near the bottom of the page.

  3. On the Mass Payment Overview page, click Make a Mass Payment.

  4. Click Browse to locate the MassPay.txt file, or type the full path of the file in the box, and then click Continue when you're done.

  5. Review the details of the transaction and the first few lines of the MassPay.txt file you just uploaded, and then send your payment. You and your affiliates will be notified by PayPal that the payments have been made.

7.17.6 Hacking the Hack

You can further enhance this system with the following:

  • Create a statistics page on the fly so that affiliates can see their sales figures and possibly fine-tune their earnings (and thus boost your sales).

  • Use a task scheduler (or a Unix cron job) on your server to mail the MassPay.txt file to yourself each week.

  • This hack is only the beginning; you can use Mass Pay for customer rebates, pay-to-surf rewards, employee benefits, survey incentives, and more.

 < Day Day Up > 

PayPal Hacks
PayPal Hacks
ISBN: 0596007515
EAN: 2147483647
Year: 2004
Pages: 169

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net