Introduction
PayPal is probably one of the first things that gets mentioned once you start discussion on online payments. It’s not so without reason – in 2008, PayPal moved over 60 billion dollars between accounts which is, you’ll agree, a respectable amount. And also, all trends show that this growth will continue – with huge number of new accounts (over 184 million accounts in 2008 compared to 96.2 million in 2005), with a new platform named PayPal X, and with more cool applications that involve paying (like Twitpay), you can bet that PayPal is here to stay. So, how can you join the whole PayPal Development movement?
Unfortunately, I would say – not so easily. When I first started with PayPal integration - it was hard, really hard. If you wish to see what I mean, just jump to the PayPal Developer Center. There is no way you’ll easily fish out what you need from that site if you are a PayPal newbie; simply - there are too many links, too many resources, and too many mixings of important and not-so-important information. So, how should you start?
Getting Started with PayPal
To those who really want to get into PayPal, and are willing to shell out some buck, I would recommend the Pro PayPal E-Commerce
book - that’s how I eventually got into understanding the concepts behind PayPal integration. For those who are not so eager to pay – don’t worry, that’s why this article is here... I'll go over most of the stuff that book covers, but in a more brief and concise manner.
First and foremost - understanding what kinds of integration PayPal offers is, I would say, the most important thing in order to successfully start your development journey. A common mistake, that happened to me also, is to start at once with the PayPal API and Express Checkout. I mean it’s natural - we are developers, and when they tell us to integrate with something, the first thing we look for is the SDK & API… the PayPal API comes up as a result… we say “That’s it” to ourselves… and start working. The problem is – the majority of payment scenarios can be handled with a way simpler approach - HTML forms that are part of the Website Payments Standard.
So, without further ado, here is a classification of PayPal integrations:
- Website Payments Standard (HTML)
- Postpayment Processing
- AutoReturn
- Payment Data Transfer (PDT)
- Instant Payment Notification (IPN)
- PayPal API
- Express Checkout
- Direct Payment (Website Payments Pro)
- Payflow Gateway
Items in classification are also ordered in a way I would suggest for everyone to follow. So, if you are new to PayPal – first learn all of the options that you have with the Website Payments Standard (HTML). Then, if you need to add some basic post-payment processing, see if Auto-Return or PDT will solve your problem… if not, IPN is a more robust option you have at your disposal.
The next level would involve the PayPal API and implementing the Express Checkout, which is the most flexible PayPal integration solution. And finally, if you long for the ability to directly process credit cards on your website, you’ll pay a monthly fee to PayPal and implement Direct Payment (effectively getting what is called Website Payments Pro).
The last item from our classification - the Payflow Gateway is, on the other hand, a different beast. It doesn’t “update the stack” in a way the previously mentioned technologies do. It is a solution aimed specifically at those businesses that have/want an Internet Merchant Account (IMA) and just need the payment gateway. In order to keep the article consistent, I’ll skip explaining the details of the Payflow Gateway. However, if you have any questions related to it, feel free to leave a message in the comments section and I’ll try to answer.
That said, let’s get to setting up a test PayPal account, and then we’ll delve deeper into describing the mentioned integrations.
Setting up a Test Account
Word of notice – you’ll want to follow this step even if you already have a live PayPal account. There are two reasons for using test accounts:
- you don’t want to test and play with real money
- you want to have access to different types of PayPal accounts
- Personal account – most people have these; just an account that allows you to use PayPal when paying for stuff online. Theoretically, you can use a Personal account to accept money; just know that you’ll be severely constrained – there is a $500 receiving limit per month, and you are only able to accept one time payments using the Website Payments Standard (HTML). The big advantage of a Personal account is that you don’t need to pay any transaction fee when receiving money. Note, however, that if you receive more than $500 in one month, you’ll be prompted to either upgrade to a Premier/Business account or reject the payment.
- Premier account – step up from a personal account; for anyone who wants to run a personal online business. This type of account has all of the integration options (accepting credit cards, recurring payments, PayPal API). However, most people skip directly from Personal to Business account as Premier account has the same transaction fees (in most cases, 2.9% + $0.30 per transaction) while lacking reporting, multi-user access, and other advanced merchant services of the Business account.
- Business account – it has all of the features of the Premier account plus a few more (ability to operate under your business’s name is one of them). If you are developing a website that needs to accept payments in 99% of situations, you’ll go with this type of account.
To start, visit the PayPal Sandbox and sign-up for a new account. The process is straightforward, and most developers should have no trouble finishing it. However, here are the pictures that will help you navigate through the process:
Signing up for a Sandbox account
Filling in the details of your Sandbox account
Once done with entering the details for your Sandbox account, you'll need to check the email you provided in order to complete the registration. After that, you'll be able to login and start creating Sandbox PayPal accounts. Clicking onTest Accounts (menu on the left), and then Create Account: Preconfigured - will get you a form like the one on the image below:
Creating a Sandbox test account
Clarification of Account Type radio buttons: by selecting Buyer, you'll create a Personal account, and by selecting Seller, you'll create a Business account. For testing most integration scenarios, you'll need both accounts, so be sure to create them. Here is what you should eventually have on your screen after you click on Test Accounts:
Overview of your testing accounts
Checking the radio button next to any of the accounts from the list and clicking on Enter Sandbox Test Site should bring up the Sandbox PayPal site which will allow you to login and administer your account in the same way as with a regular PayPal account. The only difference is that you'll have a huge PayPal Sandbox header and text that displays the email address of your developer account. To see what I'm talking about, check the image below:
Administering a PayPal Sandbox account
Last but not least - in order to use your Sandbox account for testing, you need to be logged in with your developer account. If you are not logged in and you follow some payment link, you'll get the following screen:
Login to use the PayPal Sandbox features
Website Payments Standard (HTML)
In this section, I'll provide you with a number of examples that will show how to create your own HTML form for receiving money over PayPal. You'll see how to use different variables in order to influence payment details. Before we delve into details, let's take a look at the two most basic variables:
- form's
actionattribute - in most cases, it should be https://www.paypal.com/cgi-bin/webscr. If you are using Sandbox for testing payments, you'll change it to https://www.sandbox.paypal.com/cgi-bin/webscr - effectively, you just insert the word sandbox into the URL (this is also true for some other integrations; e.g., the PayPal API). For upcoming examples, I won't be using the Sandbox URL because most of you would just get that "Login to use the PayPal Sandbox features" screen (look up for the image). - form's business child - I'll use youremailaddress@yourdomain.com for most examples; if you copy-paste the code, you'll want to replace that with the email of your PayPal account.
Basic Payment
OK, let’s say you have an opened PayPal account and you just wish to be able to accept a $0.01 payment for a painting you are selling through your site. Just insert the following HTML into your page and you are set to go:
here is my source :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Paypal.aspx.cs" Inherits="Paypal" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Paypal</title>
</head>
<body>
<form id="paypalForm" method="post" action="<%Response.Write(URL);%>">
<input type="hidden" name="cmd" value="<%Response.Write(cmd);%>" />
<input type="hidden" name="business" value="<%Response.Write(business);%>" />
<input type="hidden" name="item_name" value="<%Response.Write(item_name);%>" />
<input type="hidden" name="amount" value="<%Response.Write(amount);%>" />
<input type="hidden" name="no_shipping" value="<%Response.Write(no_shipping);%>" />
<input type="hidden" name="return" value="<%Response.Write(return_url);%>" />
<input type="hidden" name="rm" value="<%Response.Write(rm);%>" />
<input type="hidden" name="notify_url" value="<%Response.Write(notify_url);%>" />
<input type="hidden" name="cancel_return" value="<%Response.Write(cancel_url);%>" />
<input type="hidden" name="currency_code" value="<%Response.Write(currency_code);%>" />
<input type="hidden" name="custom" value="<%Response.Write(request_id);%>" />
</form>
<script language="javascript">
document.forms["paypalForm"].submit ();
</script>
</html>
here is my C# Code : Here u need to send some important paramenters which is use for Transaction.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.VisualBasic;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
public partial class Paypal : System.Web.UI.Page
{
//"_notify-validate"
protected string cmd = "_xclick";
protected string business = "your-sandboxmailID@mail.com";
protected string item_name = "Payment for Registration";
protected string amount;
protected string return_url = "http://yourwebURL/Paypal/Paypal.aspx";
protected string notify_url = "http://yourwebURL/Paypal/Paypal.aspx";
protected string cancel_url = "http://yourwebURL/Paypal/Paypal.aspx";
protected string currency_code = "USD";
protected string no_shipping = "1";
protected string URL;
protected string request_id;
protected string rm;
protected void Page_Load(object sender, EventArgs e)
{
URL = "https://www.sandbox.paypal.com/cgi-bin/webscr";
//This parameter determines the was information about successfull transaction will be passed to the script
// specified in the return_url parameter.
// "1" - no parameters will be passed.
// "2" - the POST method will be used.
// "0" - the GET method will be used.
// The parameter is "0" by deault.
rm = "2";
// the total cost of the cart
amount = 0.01;
//Session("Amount")
// the identifier of the payment request
request_id = 1;
//Session("request_id")
} } enjoy the code.