Hacks 1917 Industrial.. Strength Tips and Tools [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Hacks 1917 Industrial.. Strength Tips and Tools [Electronic resources] - نسخه متنی

David A. Karp

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید










Hack 79 Accept PayPal Payments from Your Own Site


Integrate PayPal into your web site with a
simple HTML form.

PayPal is more than
a standalone auction payment serviceit's an
engine that you can use to power transactions on or off eBay. Any
site that sells products can accept PayPal payments, and can do so
without forcing customers to type an email address and an amount into
their browser windows.

Somewhat like an API, PayPal provides an HTTP interface to their
payment system that works just like the Pay Now button at the top of
completed eBay auctions. This allows you, as the seller, to specify
an amount, a product name, and any other bits of information
you'd like to associate with the payment.

Any seller can accept PayPal payments through their HTTP interface;
no special agreement or settings are necessary, other than a basic
PayPal account. There are two ways to integrate PayPal into your
site.


7.9.1 Just a Link


The simpler of the two methods involves nothing more than a link
placed on your site. For instance, this URL:


specifies the email address
(paybot@ebayhacks.com), the product name
(wicket), and the amount
($58.00). If you want to link the URL to an image
(like the PayPal logo), use this code:

<a href="><img src="/image/library/english/10062_
x-click-but01.gif" border=0></a>

Other Pay Now button images are available at PayPal. When your
customers click the link, they will see a window like the one in
Figure 7-11.



Figure 7-11. The PayPal checkout counter shows your product and the price


When your customers click Continue, the only thing
they'll be able to change on the next page is the
funding source and the shipping address. If you want your customers
to be able to enter a note or special instructions, remove the
&no_note=1 parameter from the URL.


Look out for devious customers who might try to shortchange you by
altering the amount in the URL. Make sure to verify the amount before
shipping your product. Use a form (described next) for a slightly
more tamper-proof solution.

You can further customize your customers' experience
by including additional fields in the URL, many of which are
discussed in the next section.


7.9.2 The Form


The more robust approach requires a
little more code:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="paybot@ebayhacks.com">
<input type="hidden" name="return"
value="http://www.ebayhacks.com/thankyoul">
<input type="hidden" name="cancel_return"
value="http://www.ebayhacks.com/cancelledl">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="item_name" value="Extra-Strenth Wicket">
<input type="hidden" name="item_number" value="63123">
<input type="hidden" name="amount" value="$77.00">
<input type="hidden" name="on0" value="Name">
<input type="hidden" name="on1" value="Color">
Please type your name:
<input name="os0" value=" maxlength=60 size=22>
<p>
Please choose a color
<select name="os1">
<option>Mustard Yellow
<option>Metallic Puce
<option>Chartreuse
<option>Clear
<option>Candy Apple Gray
</select>
<p>
<input type="submit" name="submit" value="Continue...">
</form>

The advantages of the form interface are clear: in addition to the
standard fields (listed at the beginning in the hidden
<input> tags), you can include up to two
custom fields to be filled out by your customers. The names of the
custom fields are specified in the hidden on0 and
on1 fields, and their contents are specified in
the os0 and os1 fields. In the
example, the custom fields, name and
color, are comprised of a standard text box and a
drop-down list box, respectively.

Also new in this form are the return and
cancel_return fields, which contain the URLs to
which your customers will be sent when they complete (or cancel) the
payment process, and the item_number field, which
can be your stock number (SKU) or part number.


If you don't want to build the form yourself, PayPal
will do it for you. Go to Merchant Tools Website Payments
Buy Now Buttons to choose the options you want and review
the resulting HTML code.


7.9.3 Shopping Cart


PayPal also supports a shopping cart
interface in which customers can specify and pay for
multiple items from your store. The code is nearly identical to the
form in the previous section, except for two fields. First, change
the contents of the cmd field to
_cart (with the underscore), like this:

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

Next, add the following new field:

<input type="hidden" name="add" value="1">

Finally, change the caption of the submit button like this:

<input type="submit" name="submit" value="Add to Cart...">

When your customers add items to their shopping carts,
they'll see a page like the one in Figure 7-12.


Figure 7-12. Integrate a PayPal shopping cart interface with a simple HTML form



7.9.4 See Also


You'll be notified of any completed sales with a
payment notification email to your registered PayPal email address.
To eliminate the human interaction required to process the emails and
further integrate your business with PayPal, you can use Instant
Payment Notification, as described in [Hack #80].

Also, see [Hack #49] for details on
controlling the integration of PayPal with your completed
auctions.


/ 164