Click here to Skip to main content
15,881,882 members
Articles / Product Showcase
Article

Embedding PayPal Payments into Your Site

10 Mar 2011CPOL3 min read 50K   21   3
An article on embedding PayPal payments into your site

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

When a customer visits your site, you want to make it as easy and seamless as possible for your customer to find and buy what they are looking for. For obvious reasons, you want to minimize the steps and overall number of clicks required to make a purchase. But there is more to a positive site experience than limiting the steps. Requiring that a customer navigate to another site to finalize a purchase detracts from the overall experience of your site and gives your customer one more chance to possibly change his mind about following through on a given purchase. You want to keep the customer on your site and streamline how purchase information is presented to that customer.

The latest release of PayPal’s Embedded Payments now lets customers make payments using PayPal without ever leaving your site. Embedded Payments is included in the latest implementation of PayPal’s Adaptive Payments API.

Why Use Embedded Payments

Embedded Payments enables:

  • Customers to pay for digital and physical goods
  • Customers to sending money
  • You to accept guest payments
  • Supports new user signups for PayPal
  • Enables customers to add new credit cards without visiting the PayPal site
  • Enables single- or multi-recipient shopping carts

Embedded Payments enables you to offer extremely flexible payment options, including:

  • Simple payments
  • Parallel payments
  • Chained payments

Requirements

To use Adaptive Payments , you must have a PayPal business account.

PayPal provides all the code you need to implement embedded payments. Just cut and paste the script on the appropriate pages and then customize the script to your needs.

Adding Embedded Payments

To implement Embedded Payments:

  • Include JavaScript code from PayPal on your checkout or payment Web pages
  • Include the dg.js script on any page that invokes or terminates the embedded payment flow
  • Use the functions provided in the JavaScript to coordinate the PayPal flow with the appearance of your Web pages
  • Launch your preferred embedded payment flow and redirect the sender’s browser to the PayPal URL that supports embedded payments: https://paypal.com/webapps/adaptivepayment/flow/pay?paykey=...
  • Supply your custom paykey.

Executing these steps properly gives your customers the impression that the entire process is happening directly on your website. The PayPal-supplied JavaScript provides all the code required and lets you present the payment screen in one of two ways. First, you can present it as a “lightbox,” an IFRAME within sender’s browser. Second, you can present it as a pop-up mini-browser that appears in front of your website.

Either approach gives your customers a rich, seamless single-site experience.

Testing

Once you review the appropriate documentation and download the relevant materials, you can test using the Embedded Payments feature on the PayPal Sandbox site. The PayPal Sandbox site works exactly like PayPal’s live site—but no real money changes hands.

You should be aware of a couple things when testing. First, the current implementation of this feature requires that end users have third-party cookies enabled in their browsers. Second, PayPal has not yet enabled mini-browser integration on the Sandbox site. At this time, you can test only the “lightbox” experience. This will not be fixed sooner than Q2 of 2011.

Getting Help

Visit PayPal’s developer site, www.x.com, for more information about embedded payments and adaptive payments in general. PayPal’s official Embedded Payments page provides you quick access to several handy resources, including documentation for the following:

  • Embedded Payments and Payments for Digital Goods
  • Adaptive Payments
  • Embedded Payments datasheet

The Embedded Payments document is especially helpful, providing several practical coding examples, a list of available functions and what they do, and other, more general information about Embedded Payments.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow can I see the source code? Pin
Ujjup10-Apr-12 5:23
Ujjup10-Apr-12 5:23 
AnswerRe: How can I see the source code? Pin
Sean Ewington11-Apr-12 10:37
staffSean Ewington11-Apr-12 10:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.