eQuantic.Payment
1.3.0
dotnet add package eQuantic.Payment --version 1.3.0
NuGet\Install-Package eQuantic.Payment -Version 1.3.0
<PackageReference Include="eQuantic.Payment" Version="1.3.0" />
<PackageVersion Include="eQuantic.Payment" Version="1.3.0" />
<PackageReference Include="eQuantic.Payment" />
paket add eQuantic.Payment --version 1.3.0
#r "nuget: eQuantic.Payment, 1.3.0"
#:package eQuantic.Payment@1.3.0
#addin nuget:?package=eQuantic.Payment&version=1.3.0
#tool nuget:?package=eQuantic.Payment&version=1.3.0
eQuantic.Payment
One contract for every payment gateway: the same request, the same response, and the provider and API version that answered, always. The gateways live in their own packages and plug into this one.
Install
dotnet add package eQuantic.Payment
dotnet add package eQuantic.Payment.Stripe # or any other provider package
Register
using eQuantic.Payment.DependencyInjection;
using eQuantic.Payment.Stripe;
services.AddPayments(payments => payments
.AddStripe(o => o.ApiKey = configuration["Stripe:ApiKey"]!, asDefault: true));
Charge
using eQuantic.Payment.Abstractions;
using eQuantic.Payment.Models;
using eQuantic.Payment.Models.Requests;
var provider = factory.GetDefault(); // IPaymentProviderFactory, from DI
var response = await provider.Charges.CreateAsync(new CreateChargeRequest
{
Amount = Money.Brl(49.90m),
Method = PaymentMethodType.Pix,
});
if (response.Success)
{
Console.WriteLine($"{response.Data!.Id} via {response.Provider.Key}");
}
What is in it
- Contracts:
IPaymentProviderwith itsCharges,Refunds,Customers,PaymentMethodsandNotificationsoperations, andIPaymentProviderFactory, which resolves a provider by name, by name and version, or the default.Notifications.Verifychecks that a webhook came from the gateway before parsing it;PaymentMethodssaves a customer's card to charge it later with the customer away (CreateChargeRequest.OffSession);Customers.UpdateAsynckeeps a customer in step. A provider that does not do one of these yet answers with a failure. - The unified model:
CreateChargeRequest,CaptureRequest,CancelRequest,RefundRequest,CustomerRequest;Charge,Customer,Refund, with the Pix, boleto and card details each method returns;Moneyin centavos. PaymentResponse<T>: the result or aPaymentError, the provider and version that answered, and the gateway's raw body for auditing. A failure can still carry what the gateway returned about the object: a declined charge comes back with its id and status.- The registration:
AddPayments(...)and thePaymentBuilderthe provider packages extend.
Retries
What moves money (create, capture, cancel and refund) takes an IdempotencyKey, so a retry after a timeout
is answered with the first result instead of charging twice. Use one key per operation, derived from your own
id for the attempt and the operation (attempt-42:create, attempt-42:refund), and reuse it only to retry
that same request: a gateway refuses a key reused with other parameters. Set AttemptedAt with the key, to
the moment of the first try, and send it again with every retry, so what counts from the moment of the request
(a Pix expiry, a boleto's days) comes out the same; left out, each call counts from its own moment. Keep the
key to 64 characters, Adyen's limit. The table below says what each gateway gets. A customer's creation takes
a key too (CustomerRequest.IdempotencyKey): Stripe sends it, and the other gateways ignore it.
Providers
| Package | Gateway | Idempotency key |
|---|---|---|
eQuantic.Payment.Stripe |
Stripe | Idempotency-Key, the caller's; none without one |
eQuantic.Payment.Pagarme |
Pagar.me | none sent |
eQuantic.Payment.MercadoPago |
Mercado Pago | X-Idempotency-Key, the caller's; without one, a fresh key, except on a Payments API capture or cancel, which carries none |
eQuantic.Payment.PagSeguro |
PagSeguro / PagBank | x-idempotency-key, the caller's or a fresh one |
eQuantic.Payment.Cielo |
Cielo | none sent |
eQuantic.Payment.Adyen |
Adyen | Idempotency-Key, the caller's or a fresh one |
eQuantic.Payment.Asaas |
Asaas | none sent |
eQuantic.Payment.Efi |
Efí (Gerencianet) | none sent |
Source, design notes and the other packages: https://github.com/eQuantic/core-payment.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
NuGet packages (8)
Showing the top 5 NuGet packages that depend on eQuantic.Payment:
| Package | Downloads |
|---|---|
|
eQuantic.Payment.Stripe
Stripe API client for eQuantic.Payment. Versioned client (REST v1, pinned Stripe-Version) plus the unified IPaymentProvider adapter. |
|
|
eQuantic.Payment.Pagarme
Pagar.me API client for eQuantic.Payment. Versioned clients (Core API v4 and v5) plus the unified IPaymentProvider adapter. |
|
|
eQuantic.Payment.PagSeguro
PagSeguro / PagBank API client for eQuantic.Payment. Modern Orders/Charges API (versioned) plus the unified IPaymentProvider adapter. |
|
|
eQuantic.Payment.Asaas
Asaas API client for eQuantic.Payment. Versioned client (API v3) plus the unified IPaymentProvider adapter with real customer support (PIX, boleto, credit card). |
|
|
eQuantic.Payment.Cielo
Cielo E-commerce API client for eQuantic.Payment. Versioned client (API 3.0) plus the unified IPaymentProvider adapter. |
GitHub repositories
This package is not used by any popular GitHub repositories.