flutter_paytorl 0.1.1

SDKflutter
Platformandroidioswindowslinuxmacosweb

A Flutter library for handling Payto Resource Locators (PRLs). Based on the URL API and provides additional functionality for managing PRLs.

Flutter PaytoRL

flutter_paytorl is a Flutter library for handling Payto Resource Locators (PRLs). This library is based on the URL API and provides additional functionality for managing PRLs.

pub package License: CORE Publisher Flutter Platform GitHub Sponsors

Features

  • 🐥 Small: Minimal footprint, distributed as optimized Dart package
  • 📜 Standardized: Based on the URL Web API
  • 🏗️ Simple: Easy to implement in Flutter applications
  • 🗂 Typed: Ships with strong type definitions
  • 🧪 Tested: Comprehensive test coverage
  • 🌲 Tree Shaking: Zero dependencies, no side effects
  • 📱 Cross Platform: Supports Android, iOS, Web, macOS, Windows, Linux, and Wasm

Installation

Add flutter_paytorl to your pubspec.yaml:

dependencies:
  flutter_paytorl: ^0.1.0

Or install via command line:

flutter pub add flutter_paytorl

Usage

Here's an example of how to use the flutter_paytorl package:

import 'package:flutter_paytorl/flutter_paytorl.dart';

void main() {
  // Basic payment URL
  final paytoString = 'payto://xcb/cb7147879011ea207df5b35a24ca6f0859dcfb145999?amount=ctn:10.01&fiat=eur';
  final payto = Payto(paytoString);

  // Standard payment properties
  print(payto.address);  // 'cb7147879011ea207df5b35a24ca6f0859dcfb145999'
  print(payto.amount);   // 'ctn:10.01'
  print(payto.value);    // 10.01
  print(payto.network);  // 'xcb'
  print(payto.currency); // ['ctn', 'eur']

  // Update payment amount
  payto.value = 20.02;
  print(payto.amount);   // 'ctn:20.02'
  print(payto.fiat);     // 'eur'

  // Color customization
  payto.colorBackground = 'ff0000';  // Red background (6-character hex)
  payto.colorForeground = '000000';  // Black foreground
  print(payto.colorBackground); // 'ff0000'

  // ACH payment examples
  final achPayto1 = Payto('payto://ach/123456789/1234567'); // With routing number
  print(achPayto1.routingNumber); // 123456789
  print(achPayto1.accountNumber); // 1234567

  // UPI/PIX payment examples (case-insensitive email)
  final upiPayto = Payto('payto://upi/USER@example.com');
  print(upiPayto.accountAlias); // 'user@example.com'

  // Geo location example
  final geoPayto = Payto('payto://void/geo');
  geoPayto.location = '51.5074,0.1278';  // Valid coordinates
  print(geoPayto.void_);     // 'geo'
  print(geoPayto.location); // '51.5074,0.1278'
}

API Reference

Constructor

Payto(String paytoString)

Creates a new Payto instance from a payto URL string.

Properties

PropertyTypeDescription
accountAliasString?Email address for UPI/PIX payments (case-insensitive)
accountNumberint?Account number (7-14 digits) for ACH payments
addressString?Payment address
amountString?Payment amount with optional currency prefix
assetString?Asset type or contract address
barcodeString?Barcode format
bicString?Bank Identifier Code (8 or 11 characters, case-insensitive)
colorBackgroundString?Background color in 6-character hex format
colorForegroundString?Foreground color in 6-character hex format
currencyList<String?>?Currency codes array [asset, fiat]
deadlineint?Payment deadline (Unix timestamp)
donatebool?Donation flag
fiatString?Fiat currency code (case-insensitive)
ibanString?International Bank Account Number (case-insensitive)
locationString?Location data (format depends on void type)
messageString?Payment message
networkString?Network identifier (case-insensitive)
routingNumberint?Bank routing number (9 digits)
valuedouble?Numeric amount value
void_String?Void path type (e.g., 'geo', 'plus')

Methods

MethodReturn TypeDescription
toString()StringReturns the complete payto URL string
toJson()StringReturns a JSON string representation
toJsonObject()PaytoJsonReturns a typed object with all properties

Platform Support

AndroidiOSWebmacOSWindowsLinuxWasm
✅✅✅✅✅✅✅

License

This project is licensed under the CORE License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Acknowledgments

  • Based on the URL Web API
  • Implements RFC 8905 - The 'payto' URI Scheme

Funding

If you find this project useful, please consider supporting it:

List of sponsors: GitHub Sponsors