About this Book
Welcome to "Practical PayPal Integration in ASP.NET Core". This book will provide useful resources on PayPal Checkout and Subscriptions
APIs and SDKs, as well as their applications in ASP.NET Core projects. I hope that this book will be useful for .NET programmers,
software developers, and students of all skill levels, who are interested in integrating the PayPal REST APIs into their ASP.NET applications.
You may often get confused with PayPal because there are so many frameworks and options to do the same thing. In fact, there are over 50
PayPal services, APIs, and SDKs out there – you just do not know which one is suitable for your applications.In this book,
I will choose the latest PayPal products, services, APIs, and SDKs, and integrate them into your ASP.NET Core applications.
Here are PayPal technologies that I plan to use:
-
PayPal Smart Payment Buttons – These new buttons, introduced in June 2018, provide a simplified and secure check out experience.
They intelligently present the most relevant payment types to your shoppers automatically.
- PayPal JavaScript SDK – This SDK integrates Smart Payment Buttons into your web site and renders them to a container DOM element.
-
PayPal Checkout .Net SDK – To simplify integrations, PayPal provides a .NET SDK for their Version 2 REST Payment API. Using the SDK over
a direct integration allows the SDK to handle authentication on the server side for you.
-
PayPal Subscriptions API – I will implement a Subscriptions .NET SDK based on PayPal Version 1 Subscriptions REST API.
This SDK allows you to easily integrate PayPal Subscriptions into .NET applications.
In the first part of this book, I will explain how to use the PayPal Checkout .NET SDK to get start with the PayPal Version 2 Payments and Orders REST APIs.
I will use various examples to demonstrate the procedures to complete a PayPal checkout transaction, including how to set up the
development environment, how to integrate and render Smart Payment Buttons, how to create and manage orders, and how to capture and
verify the transaction.In the second part of this book, I will switch to PayPal Subscriptions API. This API has not been ported to
Version 2 yet, so we have to use Version 1 API for subscription. To make matters even worse, PayPal has never released a stable
Subscriptions .NET SDK, which makes it difficult for .NET developers to integrate PayPal Subscriptions API into .NET and
.NET Core applications. Therefore, I decide to implement a simple PayPal Subscriptions .NET SDK, which simply exposes various
static methods that can be used to integrate PayPal Subscriptions API into .NET applications. I will use several examples to
illustrate how to use this SDK to complete subscription transactions.
Introduction
Welcome to Practical PayPal Integration in ASP.NET Core. This book will provide useful resources on PayPal payment APIs and SDKs,
as well as their applications in ASP.NET Core projects. I hope that this book will be useful for .NET programmers, software developers,
and students of all skill levels, who are interested in integrating the PayPal REST APIs into their ASP.NET applications.
You, like many developers, may often get confused with PayPal because there are so many frameworks and options to do the same thing.
In fact, there are over 50 PayPal services, APIs, and SDKs out there – you just do not know which one is suitable for your applications.
-
PayPal Buy Now Button: This is for single item purchase.
-
PayPal One Touch: with One Touch, customers can skip PayPal login and quickly complete their purchase on your web site or application.
-
PayPal Express Checkout: This allows merchants and developers to minimize the number of steps customers must complete when they checkout.
Customers who use Express Checkout pay on PayPal’s secure site and return to the merchant’s site to complete the transaction.
-
PayPal Checkout with checkout.js: Valid before February 2019. PayPal does not update checkout.js with new features and enhancements.
-
PayPal Payment API: this is an easy and secure way to accept online and mobile payments.
-
PayPal Payments Pro: This allows you to accept payments with a completely customizable solution.
-
PayPal Payments Advanced. Accept credit cards, PayPal, and PayPal Credit online with PayPal payments Advanced. This all-in-one solution
offers an embedded checkout that keeps customers on the merchant’s side and an internet merchant account from PayPal.
-
PayPal Smart Payment Buttons: With these smart buttons, no matter where you selling from, you can accept the payment methods
that are most relevant to your customers wherever they are buying from.
-
PayPal Credit: This is consumer credit product that allows you to offer easy financing options, so your customers can buy now and pay
over time, while you get paid up front.
-
PayPal NVP/SOUP API: This API is used for PayPal Gateway that is a secure, open payment gateway, which support for these products, including
PayPal Payments Pro, PayPal Payments Advanced, Payflow Pro, Payflow Link, etc.
-
PayPal REST API: Use this new, modern API to easily and securely accept online and mobile payments. You can accept an immediate payment
or authorize a payment and capture it later.
-
PayPal .NET SDK: This SDK makes it easy to add PayPal support to your .NET web application, and it is built on PayPal’s REST API.
-
PayPal Checkout .NET SDK: This is a part of the next major PayPal SDK. It includes a simplified interface to provide simple model
objects and blueprints for HTTP calls.
-
PayPal Subscriptions API: This allows you to process recurring PayPal payments for physical or digital goods, or services.
-
PayPal Orders API: This API allows you to create, update, retrieve, authorize, and capture orders.
There are much more PayPal, products, services, APIs, and SDKs, which are not listed here.
In this book, I will choose the latest PayPal products, services, APIs, and SDKs, and integrate them into your ASP.NET Core applications.
Here are PayPal technologies that I plan to use:
-
PayPal Smart Payment Buttons – These new buttons, introduced in June 2018, provide a simplified and secure check out experience.
They intelligently present the most relevant payment types to your shoppers automatically.
- PayPal JavaScript SDK – This SDK integrates Smart Payment Buttons into your web site and renders them to a container DOM element.
-
PayPal Checkout .Net SDK – To simplify integrations, PayPal provides a .NET SDK for their Version 2 REST Payment API. Using the
SDK over a direct integration allows the SDK to handle authentication on the server side for you. The SDK obtains the OAuth 2.0
access token and automatically reflects any orders and payments API updates.
-
PayPal Subscriptions API – I will implement a simple Subscriptions .NET SDK based on PayPal Version 1 Subscriptions REST API.
This SDK allows you to easily integrate PayPal Subscriptions into your .NET applications.
In the first part of this book, I will explain how to use the PayPal Checkout .NET SDK to get start with the PayPal Version 2 Payments
and Orders REST APIs. I will use various examples to demonstrate the procedures to complete a PayPal checkout transaction, including
how to set up the development environment, how to integrate and render Smart Payment Buttons, how to create and manage orders, and
how to capture and verify the transaction.
In the second part of this book, I will switch to PayPal Subscriptions API. I should point out that this API has not been ported to
Version 2 yet, so we have to use PayPal Version 1 API for subscription. To make matters even worse, PayPal has never released a stable
Subscriptions .NET SDK, which makes it very difficult for .NET developers to integrate PayPal Subscriptions API into .NET
and .NET Core applications.
In this book, I will implement a simple PayPal Subscriptions .NET SDK from scratch using the .NET standard class library. I will
convert it into a NuGet package later if there is still no official PayPal Subscriptions SDK available. This SDK simply exposes
various static methods, which can be used to integrate PayPal Subscriptions API into your .NET or .NET core applications.
This book is organized into eight chapters, each of which covers a different topic about PayPal REST API integration using .NET core Razor Pages.
The following summaries of each chapter should give you an overview of the book’s content:
Chapter 1: Overview of ASP.NET Core Razor Page
This chapter provides an overview of ASP.NET Core Razor Pages, which explains how to set up the tools and development environment required for
building the server-side framework using Razor Pages. It also illustrate how to create Razor Page applications using examples.
Chapter 2, Set Up PayPal Account
This chapter explains how to set up PayPal Sandbox account environment, which will be used to integrate PayPal payment API into ASP.NET Core applications.
This is a good practice to test your code without risking any actual funds.
Chapter 3. PayPal Smart Payment Buttons
This chapter discusses PayPal Smart Payment Buttons that were introduced in June 2018. I will show you how to render these buttons in your ASP.NET Core
applications and how to customize their attributes including colors, labels, shapes, and layout.
Chapter 4. Checkout with Smart Payment Buttons
This chapter presents a basic integration of the PayPal checkout with Smart Payment Buttons using PayPal JavaScript SDK on the client side.
Chapter 5, PayPal Checkout .NET SDK
This chapter demonstrates how to use PayPal Checkout .NET SDK to get started quickly with the PayPal REST APIs and complete common actions from the server side.
Using an SDK over a direct JavaScript integration allows the SDK to handle authentication for you.
Chapter 6, Payment Management using Checkout SDK
This chapter shows how to use PayPal Checkout .NET SDK to perform various actions, including retrieve information for the old orders, refund the captured funds,
update existing orders, and capture authorization. In this chapter, we will explore these features.
Chapter 7, Implement Subscription .NET SDK
In this chapter, I will show you how to implement a basic PayPal Subscriptions .NET SDK based on PayPal Version 1 REST API using the .NET standard class library.
This SDK simply exposes various static methods, which allow you to easily integrate PayPal Subscriptions API into your .NET or .NET Core applications.
Chapter 8. Subscription Examples
This chapter shows how to use the PayPal Subscriptions .NET SDK in the ASP.NET Core applications. It presents several examples in Razor Pages to demonstrate
how to create, update, and activate a product, plan, and subscription. It also provides the detailed procedures on how to perform PayPal
subscription transactions using the subscription API and Smart Payment Buttons.
This book contains many screenshot images. I have uploaded the original images to my website at https://book.gincker.com, so you can see them more clearly.
I also provide corresponding links within the book, which allows you to easily view the original images.
I should emphasize that the PayPal Subscriptions .NET SDK I implement in this book has limited functionalities, and it should be considered as a temporary solution. So use it in your applications at your own risk.
You can download the example source code for this book from https://github.com/jack1232/PaypalProject. The download includes all the supporting resources that are required to re-create the examples without having to
type them in. You do not have to download the code, but it is the easiest way of experimenting with the examples and makes it easy to copy and paste code into your own projects.