polybrainz_now_payments library
A Dart API wrapper for NOWPayments cryptocurrency payment gateway.
This library provides a type-safe client for interacting with the NOWPayments API.
Quick Start
import 'package:polybrainz_now_payments/polybrainz_now_payments.dart';
void main() async {
final client = NowPaymentsClient(
config: NowPaymentsConfig(
apiKey: 'YOUR_API_KEY',
environment: NowPaymentsEnvironment.sandbox,
),
);
// Check API status
final status = await client.getStatus();
print('API Status: ${status.message}');
// Create a payment
final payment = await client.createPayment(
CreatePaymentRequest(
priceAmount: 100.0,
priceCurrency: FiatCurrency.usd,
payCurrency: 'btc',
),
);
print('Pay to: ${payment.payAddress}');
client.dispose();
}
Classes
- ApiStatusResponse
- Response model for API status check.
- AuthResponse
- Response model for authentication.
- BalanceResponse
- Response model for account balance.
- CreateInvoiceRequest
- Request model for creating a new invoice.
- CreatePaymentRequest
- Request model for creating a new payment.
- CreatePayoutRequest
- Request model for creating a payout.
- CurrenciesResponse
- Response model for available currencies.
- EstimatePriceRequest
- Request model for getting an estimated price.
- EstimatePriceResponse
- Response model for estimated price.
- InvoiceResponse
- Response model for an invoice.
- IpnValidator
- Utility class for validating IPN (Instant Payment Notification) callbacks.
- ListPaymentsRequest
- Request model for listing payments with optional filters.
- ListPayoutsRequest
- Request model for listing payouts with optional filters.
- MinimumAmountRequest
- Request model for getting the minimum payment amount.
- MinimumAmountResponse
- Response model for minimum payment amount.
- NowPaymentsClient
- Client for interacting with the NOWPayments API.
- NowPaymentsConfig
- Configuration for the NOWPayments API client.
- PaymentListResponse
- Response model for a list of payments.
- PaymentResponse
- Response model for a payment.
- PayoutListResponse
- Response model for a list of payouts.
- PayoutResponse
- Response model for a payout.
- SelectedCurrenciesResponse
- Response model for merchant's selected/enabled currencies.
- VerifyPayoutRequest
- Request model for verifying a payout with 2FA.
Enums
- FiatCurrency
- Supported fiat currencies for NOWPayments.
- NowPaymentsEnvironment
- NOWPayments API environment.
- PaymentStatus
- Payment status values returned by the NOWPayments API.
- PayoutStatus
- Payout status values returned by the NOWPayments API.
- SortOrder
- Sort order for list queries.
Exceptions / Errors
- AuthenticationException
- 401 - Invalid or missing API key.
- BadRequestException
- 400 - Bad request (invalid parameters).
- NotFoundException
- 404 - Resource not found.
- NowPaymentsException
- Base exception for all NOWPayments API errors.
- RateLimitException
- 429 - Rate limit exceeded.
- RequestFailedException
- 402 - Request failed (payment required or processing error).
- ServerException
- 5xx - Server error.