paypal.dotnetcore 1.1.0

dotnet add package paypal.dotnetcore --version 1.1.0                
NuGet\Install-Package paypal.dotnetcore -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="paypal.dotnetcore" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add paypal.dotnetcore --version 1.1.0                
#r "nuget: paypal.dotnetcore, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install paypal.dotnetcore as a Cake Addin
#addin nuget:?package=paypal.dotnetcore&version=1.1.0

// Install paypal.dotnetcore as a Cake Tool
#tool nuget:?package=paypal.dotnetcore&version=1.1.0                

PayPal .NET SDK

Build status

This is a fork from the original v1 PayPal SDK that seems to be abandoned by PayPal.

The old documentation is still valid and my plan is to update it as I move forward with the library.

It seemed like none of the multiple packages available on nuget.org are working well so that's the reason I created yet another fork.

Changes from original repository

Webhook event validations

In the original version, event sent by PayPal via webhooks could be validated locally based on the ceritificates provided by PayPal. However, with .NET Core things changed and that stopped working. For that reason, WebhookEvent.ValidateReceivedEvent has been removed from this library.

Now, instead of using WebhookEvent.ValidateReceivedEvent(apiContext, requestHeaders, requestBody, webhookId) you should use new VerifyWebhookSignature().Post according to the example below:

var content = "";
using (var sr = new StreamReader(request.Body, true))
{
    content = sr.ReadToEnd();
}
var paypalEvent = JsonConvert.DeserializeObject<WebhookEvent>(content);
var verificationRequest = new VerifyWebhookSignature()
{
    auth_algo = request.Headers["paypal-auth-algo"].ToString(),
    cert_url = request.Headers["paypal-cert-url"].ToString(),
    transmission_id = request.Headers["paypal-transmission-id"].ToString(),
    transmission_sig = request.Headers["paypal-transmission-sig"].ToString(),
    transmission_time = request.Headers["paypal-transmission-time"].ToString(),
    webhook_id = "YOUR_WEBHOOK_ID",
    webhook_event =  paypalEvent
};

var verification = verificationRequest.Post(GetPayPalContext()); //Pass your APIContext instance
    
if (verification.verification_status == "SUCCESS") 
    //EVENT IS VERIFIED

Troubleshooting

The moethod above will ask PayPal to verify the event for you. This verification is a constant source of pain. The primary reason is that PayPal wants to receive the event exactly in the way it sent you, meaning that field order matters in the JSON that is sent to PayPal. Verify this first if it stops working for you.

Configuration

The original configuration of the SDK was based on the old app.config paradigm and has been migrated to the new .NET Core standard.

appsettings.json example:

{
  "PayPal": {
    "mode": "sandbox",
    "connectionTimeout": 360000,
    "requestRetries": 3,
    "clientId": "AYrAaReQUybACfY3NJNZ1CNpbf8IdERKSHvA-urkP5G8YXzJd2khdkD8LT2WpDMUhXjn8NPl4sTFnYa2",
    "clientSecret": "EObW1isFRDZKO6xe2FvpwABDdOsGrhrsKqMrWzSC4Ndz8k5WeYnpYofCm9EAdibSEBv5Gel6J86TzENj"
  }
}

Running tests

As of 08/18/2019 all tests are passing. However, PayPal sandbox servers are not always in good mood so from time to time it throws some 404 or 503. If that happens with you, run the same test a couple more times and it should work.

Examples

Examples can be found inside the Samples.old folder as they are migrated. Once they are all migrated, they will live in the Samples folder.

Even though the samples provided are not really comprehensive, they are a start.

How to contribute / I want to help

There are multiple things that are necessary to bring this old library into life. Here are some if you are interested:

  • Migrate samples from old ASPX style pages into Controllers or Razor Pages
  • Provide documentation on how to setup, configure and debug the SDK (the original examples are not comprehensive enough IMO)
  • Improve the internal implementation of basic things such as HttpConnection, exception handling, logging, etc

If there is anything that should be worked on first, please open an issue and I'm happy to help. If you feel like helping with any of these tasks just send a PR 😃

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 is compatible.  netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 3,913 8/18/2019
1.0.0 620 5/24/2019