Borek Bernard
Borek Bernard

Reputation: 53352

How to integrate PayPal Express Checkout with ASP.NET Web Pages site ("Razor")

I have an ASP.NET Razor / Web Pages site that I need to integrate with PayPal Express Checkout. Edit: this integration requires more than just a simple PayPal-generated button, e.g., I need to dynamically set the price, item description, tax etc.

I am quite new to both Web Pages and PayPal integration so would like to ask what the preferred approach would be.

So far, I have found there are these options:

  1. Use PayPal Helper for WebMatrix
  2. Just read the PayPal spec and create a form with hidden fields etc.
  3. Use some of the NuGet packages from PayPal
  4. Inspire in some custom code like this one

No. 1 is probably some outdated code (both the release date and recent reviews suggest that), no. 2 will certainly work but I'll be on my own, I'm hoping that no. 3 would be the best answer but there are many of those NuGet packages and I haven't found any good examples yet, and 4 is an option if no other works.

Any suggestions? The goal is to have a simple form, below it my custom "Pay Now" button (preferably; could be also a PayPal-provided button) and when user clicks it, the website should redirect him to PayPal, process the payment notification / approval etc.

Upvotes: 2

Views: 6463

Answers (3)

Jason Z
Jason Z

Reputation: 874

I realize this question is old, but if you're looking for SDKs provided by PayPal that support Express Checkout, then you have the following two options:

  1. PayPal .NET SDK

    This SDK (formerly known as the "RestApiSdk") is built on the newer PayPal REST APIs and provides support for Express Checkout through the Payments API. All API calls use an OAuth token for security and the calls (and associated code) are a bit cleaner than its Classic counterpart. While some aspects of the REST services are still not quite up to par compared to Classic (e.g. Subscriptions), the Payments portion of the REST APIs is mostly at parity with Classic. Moving forward, this is the SDK that PayPal will be investing in and improving, so it's recommended that any new integrations use this SDK.

    Recently, the .NET SDK repo on GitHub was updated with a Wiki that should hopefully make it easier to get started using the SDK. Also, a lot of work has also been put into the included samples project to help show how to use SDK with various use cases. And if there's a use case that's missing or needs better/more explanation, definitely don't hesitate to let me know on there. :)

  2. PayPal Classic Merchant SDK

    The Merchant SDK has been around for awhile and all the classes are auto-generated from PayPal's publicly-available WSDL schema files. While it provides support for every Express Checkout-related feature, using it is a bit more cumbersome than the REST-based SDK.

    PayPal is no longer actively supporting the Merchant SDK and will only be providing bug fixes when necessary. For this reason, PayPal doesn't recommend using this SDK for new integrations.

    If you find a feature that you enjoy using in this SDK that isn't available in the REST counterpart, please let me know here or on GitHub. One issue we've noticed for people looking to switch is the REST API does not provide payment history details for payments made via Classic calls. The PayPal SDK team is currently looking into ways this support can be added to the REST-based SDKs to make it easier for developers to make the transition.

Upvotes: 1

kestrelb
kestrelb

Reputation: 246

Borek,

if you just want PayPal Express Checkout the easiest way to do it is to simply create a PayPal "Buy It Now" button. You don't need to code anything.

You can find out how to do it here https://developer.paypal.com/docs/classic/paypal-payments-standard/ht_create-pps-buttons/ but the basic steps are:

  1. Create the button inside PayPal.
  2. Copy the button code inside PayPal.
  3. Paste it into your website/email whatever.

Hope that helps!

Upvotes: 0

Jalpesh Vadgama
Jalpesh Vadgama

Reputation: 14266

The only option you have is to call rest api from asp.net web pages.

You can find the source code of rest api at following places.

https://github.com/paypal/rest-api-sdk-dotnet

http://paypal.github.io/sdk/

Upvotes: 0

Related Questions