Regira-Packages

Regira Payments

Regira Payments provides payment processing via Mollie and POM, built on the shared payment contracts from Regira.Invoicing.

Projects

Project Package Backend
Common.Payments Regira.Payments Packaging only (build targets, AI docs — no code)
Payments.Mollie Regira.Payments.Mollie Mollie API
Payments.Pom Regira.Payments.Pom POM payment gateway

Installation

<PackageReference Include="Regira.Payments.Mollie" Version="6.*" />
<PackageReference Include="Regira.Payments.Pom"    Version="6.*" />

Mollie

MollieConfig

Property Type Description
Api string Not read: the underlying PaymentClient is constructed from Key only
Key string Mollie API key. A test_… key is test mode — there is no separate switch; a live_… key takes real payments
MaxPageSize int Default 250
RedirectFactory Func<IPayment, string>? Builds redirect URL per payment. It runs before Mollie assigns the payment’s Id, so build it from the app’s own reference in Metadata
WebhookFactory Func<IPayment, string>? Builds webhook URL per payment, before its Id is set too. Mollie posts the payment id to it as the form field id

PaymentService

var svc = new Regira.Payments.Mollie.Services.PaymentService(new MollieConfig
{
    Key             = configuration["Mollie:Key"]!,
    RedirectFactory = p => $"https://myapp.com/payment/return/{p.Metadata!["orderId"]}",
    WebhookFactory  = _ => "https://myapp.com/payment/webhook"
});

// CRUD
IPayment?             payment  = await svc.Details(paymentId);
IEnumerable<IPayment> list     = await svc.List();
newPayment.Metadata = new Dictionary<string, object?> { ["orderId"] = orderId }; // the factories above read it
var response = await svc.Save(newPayment); // creates payment, sets newPayment.Id
var checkoutUrl = response.CheckoutUrl;    // redirect the customer here
// or Save(newPayment, orderId): a repeat with the same idempotency key returns the first payment
await svc.Delete(payment!);                // cancels the payment

// Handle webhook: paymentId is the form field "id" Mollie posts; WebHook reads the payment back from Mollie
await svc.WebHook(paymentId, async p =>
{
    if (p?.Status == PaymentStatus.Paid)
        await orderService.MarkPaid(p.Metadata!["orderId"]!.ToString()!);
});

Every instance sends through a connection pool the package shares, so it can be registered with any lifetime. Never repeat a Save without an idempotency key: the second creates a second payment.


POM

PomSettings

Property Type Description
SenderId string? POM sender ID
SenderContractNumber string? Contract number, sent with every payment
Username string? API username
Password string? API password
AppName string? Sent when authenticating
Platform string? Sent when authenticating
EnvironmentId string? Sent when authenticating
ExpiresIn int Sent with the authentication request. It does not set a link’s expiry: Payment.ExpiresAt does
Mode string? "live" or "test"
AuthApi string? Authentication endpoint
CreatePaylinkApi string Create payment link endpoint
PaylinkStatusApi string Payment status endpoint, with a {paymentId} placeholder
WebhookKey string? Not read by PaymentService: there is no POM webhook handling, so poll Details(id)

There is no Add… extension, configuration section or default endpoint: take the three endpoints from POM and bind a section yourself.

PaymentService

var pomSettings = new PomSettings { /* sender + API credentials, endpoints */ };
ISerializer jsonSerializer = new JsonSerializer(); // Regira.Serializing.Newtonsoft.Json
var svc = new Regira.Payments.Pom.PaymentService(pomSettings, jsonSerializer);

// Get payment status
IPayment? existing = await svc.Details("pom-payment-id");

// Create a payment link
var payment = new Payment // Regira.Invoicing.Payments.Models
{
    Amount    = 49.99m,
    Currency  = "EUR",
    ExpiresAt = DateTime.Now.AddDays(30)   // the link's expiry; one day after it is created when unset
};
var response = await svc.CreatePaylink(payment); // sets payment.Id
var paylink = response.Paylink;                  // send the payer here

CreatePaylink sends Amount, Currency and ExpiresAt (one day after creation when unset), the sender contract number coming from PomSettings, sets the payment’s Id to POM’s document id and returns POM’s PomPaymentResponse. Save, the IPaymentService method, does the same without returning the link. Neither sends Description or Metadata, so a POM payment carries no reference of yours: keep POM’s id on your own record. Every instance sends through a connection pool the package shares. An instance keeps its POM token and, when POM refuses it (401), authenticates again and sends the request once more, so it can be registered as a singleton. PomException is thrown on API errors; check StatusCode and PomResponse for details.


Notes

License

Apache License 2.0 — this package contains no license validation and no runtime limits. See LICENSE. A few companion packages are commercially licensed with a free tier; see the licensing overview.