2
2
3
3
` payto-rl ` is a TypeScript library for handling Payto Resource Locators (PRLs). This library is based on the [ URL] ( https://developer.mozilla.org/en-US/docs/Web/API/URL ) API and provides additional functionality for managing PRLs.
4
4
5
+ [ ![ npm] ( https://img.shields.io/npm/v/payto-rl?label=npm&color=cb3837&logo=npm )] ( https://www.npmjs.com/package/payto-rl )
6
+ [ ![ License: CORE] ( https://img.shields.io/badge/License-CORE-yellow?logo=googledocs )] ( LICENSE )
7
+ [ ![ Bundle Size] ( https://img.shields.io/bundlephobia/minzip/payto-rl?label=Size&logo=tsnode )] ( https://bundlephobia.com/package/payto-rl@latest )
8
+ [ ![ TypeScript] ( https://img.shields.io/badge/TypeScript-5.7-blue?logo=typescript )] ( https://www.typescriptlang.org/ )
9
+ [ ![ GitHub Sponsors] ( https://img.shields.io/github/sponsors/bchainhub?label=Sponsors&logo=githubsponsors&color=EA4AAA )] ( https://github.com/sponsors/bchainhub )
10
+
11
+ ## Features
12
+
13
+ - 🐥 ** Small** : ** [ ![ Bundle Size] ( https://img.shields.io/bundlephobia/minzip/payto-rl?label=&color=6ead0a )] ( https://bundlephobia.com/package/payto-rl@latest ) ** gzipped, distributed as minified ES modules.
14
+ - 📜 ** Standardized** : Based on the [ URL] ( https://developer.mozilla.org/en-US/docs/Web/API/URL ) Web API.
15
+ - 🏗️ ** Simple** : Easy to implement.
16
+ - 🗂 ** Typed** : Ships with types included.
17
+ - 🧪 ** Tested** : Robust test coverage.
18
+ - 🌲 ** Tree Shaking** : Zero dependencies, no side effects.
19
+
5
20
## Installation
6
21
7
- Install the ` payto-rl ` package using npm or yarn :
22
+ Install the ` payto-rl ` package using your package manager :
8
23
9
24
``` sh
10
25
npm i payto-rl
11
26
```
12
27
28
+ ``` sh
29
+ pnpm add payto-rl
30
+ ```
31
+
13
32
``` sh
14
33
yarn add payto-rl
15
34
```
@@ -37,6 +56,11 @@ payto.value = 20.02;
37
56
console .log (payto .amount ); // 'ctn:20.02'
38
57
console .log (payto .fiat ); // 'eur'
39
58
59
+ // Color customization
60
+ payto .colorBackground = ' ff0000' ; // Red background (6-character hex)
61
+ payto .colorForeground = ' 000000' ; // Black foreground
62
+ console .log (payto .colorBackground ); // 'ff0000'
63
+
40
64
// ACH payment examples
41
65
const achPayto1 = new Payto (' payto://ach/123456789/1234567' ); // With routing number
42
66
console .log (achPayto1 .routingNumber ); // 123456789
@@ -45,11 +69,11 @@ console.log(achPayto1.accountNumber); // 1234567
45
69
const achPayto2 = new Payto (' payto://ach/1234567' ); // Account number only
46
70
console .log (achPayto2 .accountNumber ); // 1234567
47
71
48
- // UPI/PIX payment examples
49
- const upiPayto = new Payto (' payto://upi/user @example.com' );
72
+ // UPI/PIX payment examples (case-insensitive email)
73
+ const upiPayto = new Payto (' payto://upi/USER @example.com' );
50
74
console .log (upiPayto .accountAlias ); // 'user@example.com'
51
75
52
- const pixPayto = new Payto (' payto://pix/user@example .com' );
76
+ const pixPayto = new Payto (' payto://pix/user@EXAMPLE .com' );
53
77
console .log (pixPayto .accountAlias ); // 'user@example.com'
54
78
55
79
// Geo location example
@@ -64,12 +88,22 @@ plusPayto.location = '8FVC9G8V+R9'; // Valid plus code
64
88
console .log (plusPayto .void ); // 'plus'
65
89
console .log (plusPayto .location ); // '8FVC9G8V+R9'
66
90
67
- // Bank details example
68
- const bankPayto = new Payto (' payto://bic/DEUTDEFF500 ' );
91
+ // Bank details example (case-insensitive BIC)
92
+ const bankPayto = new Payto (' payto://bic/deutdeff500 ' );
69
93
console .log (bankPayto .bic ); // 'DEUTDEFF500'
70
94
bankPayto .routingNumber = 123456789 ; // Valid 9-digit routing number
71
95
console .log (bankPayto .routingNumber ); // 123456789
72
96
97
+ // Value handling examples
98
+ const numericPayto = new Payto (' payto://example/address?amount=10.5' );
99
+ console .log (numericPayto .value ); // 10.5
100
+ console .log (numericPayto .amount ); // '10.5'
101
+
102
+ const tokenPayto = new Payto (' payto://example/address?amount=token:10.5' );
103
+ console .log (tokenPayto .value ); // 10.5
104
+ console .log (tokenPayto .amount ); // 'token:10.5'
105
+ console .log (tokenPayto .asset ); // 'token'
106
+
73
107
// Convert to JSON object
74
108
const jsonObj = payto .toJSONObject ();
75
109
console .log (jsonObj .colorForeground ); // Access typed properties
@@ -90,28 +124,28 @@ Creates a new Payto instance from a payto URL string.
90
124
91
125
| Property | Type | Description |
92
126
| ----------| ------| -------------|
93
- | ` accountAlias ` | ` string \| null ` | Email address for UPI/PIX payments |
127
+ | ` accountAlias ` | ` string \| null ` | Email address for UPI/PIX payments (case-insensitive) |
94
128
| ` accountNumber ` | ` number \| null ` | Account number (7-14 digits) for ACH payments |
95
129
| ` address ` | ` string \| null ` | Payment address |
96
- | ` amount ` | ` string \| null ` | Payment amount with currency |
130
+ | ` amount ` | ` string \| null ` | Payment amount with optional currency prefix |
97
131
| ` asset ` | ` string \| null ` | Asset type or contract address |
98
132
| ` barcode ` | ` 'qr' \| 'pdf417' \| 'aztec' \| 'code128' \| null ` | Barcode format |
99
- | ` bic ` | ` string \| null ` | Bank Identifier Code (8 or 11 characters) |
100
- | ` colorBackground ` | ` string \| null ` | Background color in hex format |
101
- | ` colorForeground ` | ` string \| null ` | Foreground color in hex format |
102
- | ` currency ` | ` [string \| null, string \| null] ` | Currency codes array |
133
+ | ` bic ` | ` string \| null ` | Bank Identifier Code (8 or 11 characters, case-insensitive ) |
134
+ | ` colorBackground ` | ` string \| null ` | Background color in 6-character hex format |
135
+ | ` colorForeground ` | ` string \| null ` | Foreground color in 6-character hex format |
136
+ | ` currency ` | ` [string \| null, string \| null] ` | Currency codes array [ asset, fiat ] |
103
137
| ` deadline ` | ` number \| null ` | Payment deadline (Unix timestamp) |
104
138
| ` donate ` | ` boolean \| null ` | Donation flag |
105
- | ` fiat ` | ` string \| null ` | Fiat currency code |
139
+ | ` fiat ` | ` string \| null ` | Fiat currency code (case-insensitive) |
106
140
| ` hash ` | ` string ` | URL hash component |
107
141
| ` host ` | ` string ` | Complete host (hostname: port ) |
108
- | ` hostname ` | ` string ` | Host without port |
142
+ | ` hostname ` | ` string ` | Host without port (case-insensitive) |
109
143
| ` href ` | ` string ` | Complete URL string |
110
- | ` iban ` | ` string \| null ` | International Bank Account Number |
144
+ | ` iban ` | ` string \| null ` | International Bank Account Number (case-insensitive) |
111
145
| ` item ` | ` string \| null ` | Item description (max 40 chars) |
112
146
| ` location ` | ` string \| null ` | Location data (format depends on void type) |
113
147
| ` message ` | ` string \| null ` | Payment message |
114
- | ` network ` | ` string ` | Network identifier |
148
+ | ` network ` | ` string ` | Network identifier (case-insensitive) |
115
149
| ` organization ` | ` string \| null ` | Organization name (max 25 chars) |
116
150
| ` origin ` | ` string \| null ` | URL origin |
117
151
| ` password ` | ` string ` | URL password component |
@@ -120,14 +154,14 @@ Creates a new Payto instance from a payto URL string.
120
154
| ` protocol ` | ` string ` | URL protocol (always 'payto:') |
121
155
| ` receiverName ` | ` string \| null ` | Receiver's name |
122
156
| ` recurring ` | ` string \| null ` | Recurring payment details |
123
- | ` route ` | ` string \| null ` | Additional routing information |
124
157
| ` routingNumber ` | ` number \| null ` | Bank routing number (9 digits) |
158
+ | ` rtl ` | ` boolean \| null ` | right-to-left layout |
125
159
| ` search ` | ` string ` | URL search component |
126
160
| ` searchParams ` | ` URLSearchParams ` | URL search parameters |
127
161
| ` split ` | ` [string, string, boolean] \| null ` | Payment split information |
128
162
| ` swap ` | ` string \| null ` | Swap transaction details |
129
163
| ` username ` | ` string ` | URL username component |
130
- | ` value ` | ` number \| null ` | Numeric amount value |
164
+ | ` value ` | ` number \| null ` | Numeric amount value (extracted from both simple and token : amount formats) |
131
165
| ` void ` | ` string \| null ` | Void path type (e.g., 'geo', 'plus') |
132
166
133
167
### Methods
@@ -142,18 +176,26 @@ Creates a new Payto instance from a payto URL string.
142
176
143
177
The library includes TypeScript type definitions and runtime validation for:
144
178
145
- - Bank Identifier Codes (BIC)
179
+ - Bank Identifier Codes (BIC) - 8 or 11 characters, case-insensitive
146
180
- Routing numbers (9 digits)
147
181
- Account numbers (7-14 digits)
148
- - Email addresses (for UPI/PIX)
182
+ - Email addresses (for UPI/PIX, case-insensitive )
149
183
- Geographic coordinates
150
184
- Plus codes
151
185
- Unix timestamps
152
186
- Barcode formats
153
- - IBAN format
187
+ - IBAN format (case-insensitive)
188
+ - Color formats (6-character hex)
154
189
155
190
## Payment System Support
156
191
192
+ ### IBAN
193
+
194
+ Supports two formats (case-insensitive):
195
+
196
+ - ` payto://iban/iban ` (without BIC)
197
+ - ` payto://iban/bic/iban ` (with BIC)
198
+
157
199
### ACH Payments
158
200
159
201
Supports two formats:
@@ -163,7 +205,7 @@ Supports two formats:
163
205
164
206
### UPI/PIX Payments
165
207
166
- Email-based payment identifiers:
208
+ Email-based payment identifiers (case-insensitive) :
167
209
168
210
- ` payto://upi/email@example.com `
169
211
- ` payto://pix/email@example.com `
@@ -190,4 +232,4 @@ If you find this project useful, please consider supporting it:
190
232
- [ Bitcoin] ( https://www.blockchain.com/explorer/addresses/btc/bc1pd8guxjkr2p6n2kl388fdj2trete9w2fr89xlktdezmcctxvtzm8qsymg0d )
191
233
- [ Litecoin] ( https://www.blockchain.com/explorer/addresses/ltc/ltc1ql8dvx0wv0nh2vncpt9j3zqefaehsd25cwp7pfx )
192
234
193
- List of sponsors: [ ![ GitHub Sponsors] ( https://img.shields.io/github/sponsors/bchainhub )] ( https://github.com/sponsors/bchainhub )
235
+ List of sponsors: [ ![ GitHub Sponsors] ( https://img.shields.io/github/sponsors/bchainhub?label=Sponsors&logo=githubsponsors&color=EA4AAA )] ( https://github.com/sponsors/bchainhub )
0 commit comments