PaymeMerchantHandler class

Server-side handler for the Payme Merchant API (JSON-RPC 2.0).

It implements the full transaction state machine from the official Payme integration template: authorization, amount and account checks, idempotent retries, the 12-hour timeout, cancellation before and after perform, and GetStatement. Your PaymeBackend only stores data.

final payme = PaymeMerchantHandler(key: env['PAYME_KEY']!, backend: MyBackend());
// in your route:
final res = await payme.handle(MerchantRequest(headers: headers, body: body));

Constructors

PaymeMerchantHandler({required String key, required PaymeBackend backend, String login = 'Paycom', Duration timeout = const Duration(hours: 12), String accountField = 'order_id', Set<String>? allowedIps, Future<bool> onChangePassword(String newKey)?, int clock()?})

Properties

accountField → String
The account field that identifies the order, used in error data.
final
allowedIps → Set<String>?
If set, requests from other IPs are rejected with -32504. Use paymeIps, and make sure MerchantRequest.remoteAddress is the real client IP (not your proxy's).
final
backend → PaymeBackend
final
hashCode → int
The hash code for this object.
no setterinherited
login → String
Basic-auth login. Payme always uses Paycom.
final
onChangePassword → Future<bool> Function(String newKey)?
Persists a new cashbox key sent by Payme's ChangePassword. Return true once it is stored. If null, ChangePassword is rejected.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
timeout → Duration
A created transaction that is not performed within this time is cancelled with reason 4. Payme specifies 12 hours (43 200 000 ms).
final

Methods

handle(MerchantRequest request) → Future<MerchantResponse>
Handles one HTTP request from Payme and returns the response to send.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited