EConnect.Psb.AspNetCore.Mvc 0.9.31

dotnet add package EConnect.Psb.AspNetCore.Mvc --version 0.9.31                
NuGet\Install-Package EConnect.Psb.AspNetCore.Mvc -Version 0.9.31                
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="EConnect.Psb.AspNetCore.Mvc" Version="0.9.31" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EConnect.Psb.AspNetCore.Mvc --version 0.9.31                
#r "nuget: EConnect.Psb.AspNetCore.Mvc, 0.9.31"                
#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 EConnect.Psb.AspNetCore.Mvc as a Cake Addin
#addin nuget:?package=EConnect.Psb.AspNetCore.Mvc&version=0.9.31

// Install EConnect.Psb.AspNetCore.Mvc as a Cake Tool
#tool nuget:?package=EConnect.Psb.AspNetCore.Mvc&version=0.9.31                

EConnect PSB .NET Client

A reference implementation meant as an example of how to use the PSB api using C#.

The Procurement Service Bus (PSB) provides a cloud managed connection to eDelivery networks like the Peppol network.

Requirements

  • .NET Core 2.0 or higher / .NET Framework 4.6.1 or higher

Install

  • Go through the Getting started documentation.

  • Install the package in your project, through NuGet or another tool of choice.

Install-Package EConnect.Psb

API references

For an explanation of the API please refer to the following documentation.

Setup

Make sure to initialise the service and setup the proper authentication.

Hostbuilder

The recommended way to setup the PSB APIs is to use a hostbuilder, enabling dependency injection.

builder.Services.AddPsbService(_ =>
{
    _.Username = "{username}";
    _.Password = "{password}";
    _.PsbUrl = "{psbUrl}";
    _.IdentityUrl = "{identityUrl}";
    _.ClientId = "{clientId}";
    _.ClientSecret = "{clientSecret}";
    _.SubscriptionKey = "{SubscriptionKey}";
});

After the PsbService is initialised the following APIs can be used:

  • IPsbMeApi
  • IPsbHookApi
  • IPsbPeppolApi
  • IPsbPurchaseInvoiceApi
  • IPsbPurchaseOrderApi
  • IPsbSalesInvoiceApi
  • IPsbSalesOrderApi
  • IPsbGenericApi

For example, it's now possible to inject the sales invoice API into your controller:

public YourController(IPsbSalesInvoiceApi salesInvoice)
{
    _salesInvoice = salesInvoice;
}

All API interfaces are public which makes it possible to mock them.

Example (web) hostbuilder

An example of the hostbuilder can be found in the project EConnect.Psb.Web.Example. In this project the .net client can be used to send an invoice via Peppol.
Additionally, the supplied webhook receiver shows a simple implementation to receive invoices from Peppol.

PsbServiceHost

Use the PsbServiceHost when it is not possible to use a dependency framework.

using (var psb = PsbServiceHost.Create(_ =>
    {
    _.Username = "{username}";
    _.Password = "{password}";
    _.PsbUrl = "{psbUrl}";
    _.IdentityUrl = "{identityUrl}";
    _.ClientId = "{clientId}";
    _.ClientSecret = "{clientSecret}";
    _.SubscriptionKey = "{SubscriptionKey}";
    }
))
{
    // Example for QueryRecipientParty
    var res = await psb.SalesInvoice.QueryRecipientParty("{senderPartyId}", new[] { "{receiverPartyId}"  }).ConfigureAwait(false);
    Console.WriteLine(res);
}

Example console application

An example of the PsbServiceHost can be found in the project EConnect.Psb.ConsoleNet.Example.

AspNetCore Mvc

The EConnect.Psb.AspNetCore.Mvc package makes it easy to validate a Psb webhook by simply adding an attribute on top of your method in your MVC controller. The Psb webhooks are secured by the X-EConnect-Signature. This package will validate that signature for you.

Hardcoded secret
[PsbWebhook("mySecret")]
public IActionResult Webhook([PsbWebhookValidSentOn] PsbWebHookEvent @event) 
{
  //...
}
Secret from config
[PsbWebhookOptions("webhook")]
public IActionResult Webhook([PsbWebhookValidSentOn] PsbWebHookEvent @event) 
{
  //...
}

Read more

If you want to know more about Peppol e-procurement or other procurement networks, please refer to the Procurement Service Bus introduction page.

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 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  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
0.9.31 108 6/11/2024
0.9.30 105 6/8/2024
0.9.29 131 4/4/2024
0.9.28 121 3/7/2024
0.9.27 230 6/7/2023
0.9.26 313 2/1/2023
0.9.25 458 6/20/2022
0.9.24 432 5/4/2022