Skip to content

Latest commit

 

History

History
76 lines (60 loc) · 1.91 KB

README.md

File metadata and controls

76 lines (60 loc) · 1.91 KB

WSPay.NET

NuGet

WSPay.NET is an async/sync client for WSPay API.

Installation

Using the .NET Core command-line interface (CLI):

dotnet add package WSPay.NET

Using the NuGet Command Line Interface (CLI):

nuget install WSPay.NET

Using the Package Manager Console:

Install-Package WSPay.NET

Configuration

WSPay can be configured to use Mode.Test (default) or Mode.Prod mode.

Using the app settings:

<appSettings>
  <add key="WSPayMode" value="Test" />
  <add key="WSPayRegularShopId" value="myShopId" />
  <add key="WSPayRegularShopSecret" value="myShopSecret" />
  <add key="WSPayTokenShopId" value="tokenShopId" />
  <add key="WSPayTokenShopSecret" value="tokenShopSecret" />
</appSettings>

Using the code configuration:

WSPayConfiguration.Mode = Mode.Test;            
WSPayConfiguration.RegularShop = new Shop("regularShopId", "regularShopSecret");
WSPayConfiguration.TokenShop = new Shop("tokenShopId", "tokenShopSecret");

Usage

var service = new WSPayService();
var status = await service.CheckStatusAsync(WSPayConfiguration.RegularShop, "myShoppingCartId");

Register services for DI

// Autofac
public void RegisterWsPayServices(ContainerBuilder builder)
{
    builder.RegisterType<SignatureFactory>()
        .As<ISignatureFactory>()
        .SingleInstance();

    builder.RegisterType<RequestFactory>()
        .As<IRequestFactory>()
        .SingleInstance();

    builder.RegisterType<WSPayApiClient>()
        .As<IWSPayClient>()
        .SingleInstance();

    builder.RegisterType<WSPayService>()
        .As<IWSPayService>()
        .SingleInstance();

    builder.RegisterType<FormSuccessResponse>();
    builder.RegisterType<FormErrorResponse>();
}