TailoredApps.Shared.Payments.Provider.CashBill 2.1.2

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package TailoredApps.Shared.Payments.Provider.CashBill --version 2.1.2
                    
NuGet\Install-Package TailoredApps.Shared.Payments.Provider.CashBill -Version 2.1.2
                    
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="TailoredApps.Shared.Payments.Provider.CashBill" Version="2.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TailoredApps.Shared.Payments.Provider.CashBill" Version="2.1.2" />
                    
Directory.Packages.props
<PackageReference Include="TailoredApps.Shared.Payments.Provider.CashBill" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TailoredApps.Shared.Payments.Provider.CashBill --version 2.1.2
                    
#r "nuget: TailoredApps.Shared.Payments.Provider.CashBill, 2.1.2"
                    
#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.
#:package TailoredApps.Shared.Payments.Provider.CashBill@2.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TailoredApps.Shared.Payments.Provider.CashBill&version=2.1.2
                    
Install as a Cake Addin
#tool nuget:?package=TailoredApps.Shared.Payments.Provider.CashBill&version=2.1.2
                    
Install as a Cake Tool

TailoredApps.Shared.Payments.Provider.CashBill

CashBill is a Polish operator of one-time payments. This package plugs the CashBill REST API into TailoredApps.Shared.Payments: it lists the payment channels of a shop, starts payments, reads their status, and verifies and handles CashBill status notifications.

Installation

dotnet add package TailoredApps.Shared.Payments.Provider.CashBill   # brings TailoredApps.Shared.Payments with it

Registration

using TailoredApps.Shared.Payments;
using TailoredApps.Shared.Payments.Provider.CashBill;

builder.Services.AddPayments().RegisterCashbillProvider();

The call registers the provider with its dependencies and adds it to IPaymentService. Several providers chain: .AddPayments().RegisterCashbillProvider().RegisterTpayProvider(). Mind the spelling: the extension method, the options class (CashbillServiceOptions) and the provider key use Cashbill; the provider class is CashBillProvider.

Configuration

Options are bound from the Payments:Providers:Cashbill section (CashbillServiceOptions).

{
  "Payments": {
    "Providers": {
      "Cashbill": {
        "ServiceUrl": "https://<cashbill-rest-api-address>/",
        "ShopId": "<shop-id>",
        "ShopSecretPhrase": "<shop-secret-phrase>",
        "ReturnUrl": "https://shop.example/payment/return",
        "NegativeReturnUrl": "https://shop.example/payment/failed"
      }
    }
  }
}
Key Required Meaning Default
ServiceUrl yes Base URL of the CashBill REST API; end it with /, request addresses are resolved relative to it -
ShopId yes Shop identifier -
ShopSecretPhrase yes Secret that signs the requests and verifies notifications -
ReturnUrl no Return address after a payment. Not validated at startup, but RegisterPayment fails unless it is an absolute URL empty
NegativeReturnUrl no Return address after a failed or cancelled payment empty

A required key that is missing stops the host at startup with OptionsValidationException. The other keys are not validated.

Usage

// payments is an injected IPaymentService
var channels = await payments.GetChannels("Cashbill", "PLN", cancellationToken);   // read from the CashBill API

var response = await payments.RegisterPayment(new PaymentRequest("Cashbill", 49.99m, "PLN")
{
    Title = "Order 7",
    Description = "Order 7 at shop.example",
    Email = "buyer@example.com",
    PaymentChannel = channels.First().Id,
    AdditionalData = "order-7",
}, cancellationToken);

return Redirect(response.RedirectUrl);

response.PaymentUniqueId is the CashBill payment id; pass it to GetStatus("Cashbill", paymentId).

Webhooks

CashBill calls the notification address (GET or POST) with three query-string parameters: cmd, args (the payment id) and sign. The provider reads them from PaymentWebhookRequest.Query; it does not read the body or the headers. sign must equal the hex MD5 of cmd + args + ShopSecretPhrase (compared in constant time). For an authentic notification the provider then reads the current status of the payment from the CashBill API.

var result = await payments.HandleWebhookAsync("Cashbill", new PaymentWebhookRequest
{
    HttpMethod = Request.Method,
    Query = Request.Query.ToDictionary(q => q.Key, q => q.Value),
}, cancellationToken);

return result is PaymentWebhookRejected ? BadRequest() : Ok();
Outcome Result
signature valid PaymentWebhookProcessed with the current status of the payment (Created, Processing, Finished or Rejected)
args missing PaymentWebhookRejected (MalformedPayload)
sign missing or wrong PaymentWebhookRejected (InvalidSignature)
ShopSecretPhrase not configured PaymentWebhookRejected (NotConfigured)

This provider never returns PaymentWebhookIgnored: check Payment.PaymentStatus before acting on a processed result.

Good to know

  • Every CashBill answer outside 2xx throws PaymentGatewayException (derives from HttpRequestException) - from GetChannels, RegisterPayment, GetStatus and also from HandleWebhookAsync, which queries the status. The state of the payment is then not known. Failures are logged without the query string, which carries the request signature.
  • Requests go through the named HTTP client CashBill (CashbillHttpClient.HttpClientName) from IHttpClientFactory, so the handlers and timeouts the host configures for it apply.
  • After creating a payment the provider sets its return address to {ReturnUrl}/{paymentId}: the payer comes back to ReturnUrl with the payment id appended as a path segment.
  • Status mapping: PreStart and Start are Created; PositiveAuthorization and NegativeAuthorization are Processing; PositiveFinish is Finished; NegativeFinish, CriticalError, Abort, Fraud and TimeExceeded are Rejected.
  • The provider key is "Cashbill" and it is compared case-sensitively: "CashBill" does not find the provider.

Documentation

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
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
3.0.0-preview.3 40 12/2/2026
3.0.0-preview.2 60 11/12/2026
3.0.0-preview.1 64 11/12/2026
2.1.2 46 12/2/2026
2.1.1 68 12/2/2026
2.1.0 115 11/12/2026
2.0.1 98 11/12/2026
2.0.0 136 11/12/2026
1.6.0 218 11/12/2026
1.4.19 247 10/26/2026
1.4.18 348 10/23/2026
1.4.17 439 10/6/2026
1.4.16 114 9/28/2026
1.4.15 120 9/21/2026
1.4.14 124 8/20/2026
1.4.13 130 8/20/2026
1.4.12 138 8/20/2026
1.4.11 137 8/7/2026
1.4.10 160 7/8/2026
1.4.9 145 7/8/2026
Loading failed