@rajeev02/payments 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +139 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # @rajeev02/payments
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@rajeev02/payments.svg)](https://www.npmjs.com/package/@rajeev02/payments)
4
+ [![license](https://img.shields.io/npm/l/@rajeev02/payments.svg)](https://github.com/Rajeev02/rajeev-sdk/blob/main/LICENSE)
5
+
6
+ **India-focused payments SDK** with UPI deep links, card validation (Luhn), wallet integration, and subscription management.
7
+
8
+ Part of [Rajeev SDK](https://github.com/Rajeev02/rajeev-sdk) — cross-platform infrastructure libraries for building apps that work everywhere.
9
+
10
+ ## Why use this?
11
+
12
+ - **UPI-first** — Generate UPI intent URIs for Google Pay, PhonePe, Paytm, BHIM. VPA validation, PSP detection.
13
+ - **Card support** — Visa/Mastercard/Amex/RuPay detection, Luhn validation, formatted display
14
+ - **Wallet integration** — Paytm, PhonePe, Amazon Pay — unified checkout flow
15
+ - **Subscriptions** — Create, upgrade, downgrade, cancel — with proration and GST
16
+ - **Refunds** — Full/partial refund flow with reason tracking
17
+ - **Indian-optimized** — INR formatting, GST calculation, UPI 2.0 collect, merchant category codes
18
+ - **Pure TypeScript** — No payment gateway SDK dependency. Bring your own backend.
19
+
20
+ ## Platform Support
21
+
22
+ | Platform | Engine | Status |
23
+ | ---------- | ---------- | ------ |
24
+ | iOS 16+ | TypeScript | ✅ |
25
+ | Android 7+ | TypeScript | ✅ |
26
+ | Web | TypeScript | ✅ |
27
+ | watchOS 9+ | TypeScript | ✅ |
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ npm install @rajeev02/payments
33
+ ```
34
+
35
+ ### Peer Dependencies
36
+
37
+ - `react` >= 18.3.0
38
+ - `react-native` >= 0.84.0 _(optional)_
39
+
40
+ ## Quick Start
41
+
42
+ ### UPI Payments
43
+
44
+ ```typescript
45
+ import { generateUpiUri, validateVpa, getPspName } from "@rajeev02/payments";
46
+
47
+ // Generate UPI intent link
48
+ const uri = generateUpiUri(
49
+ { merchantVpa: "store@paytm", merchantName: "My Store" },
50
+ { amount: 499, note: "Order #1234", orderId: "ORD_1234" },
51
+ );
52
+ // → "upi://pay?pa=store%40paytm&pn=My+Store&am=499.00&cu=INR&..."
53
+
54
+ // Open with Linking.openURL(uri) on React Native
55
+ // or window.location.href = uri on Web
56
+
57
+ // Validate VPA
58
+ validateVpa("rajeev@paytm"); // → true
59
+ validateVpa("invalid"); // → false
60
+ getPspName("rajeev@paytm"); // → "Paytm"
61
+ getPspName("rajeev@okicici"); // → "iMobile Pay"
62
+ ```
63
+
64
+ ### Card Payments
65
+
66
+ ```typescript
67
+ import {
68
+ detectCardNetwork,
69
+ formatCardNumber,
70
+ validateCardNumber,
71
+ } from "@rajeev02/payments";
72
+
73
+ detectCardNetwork("4111111111111111"); // → "visa"
74
+ detectCardNetwork("5500000000000004"); // → "mastercard"
75
+ detectCardNetwork("6521000000000000"); // → "rupay"
76
+
77
+ formatCardNumber("4111111111111111"); // → "4111 1111 1111 1111"
78
+ validateCardNumber("4111111111111111"); // → true (Luhn check)
79
+ ```
80
+
81
+ ### Wallet Checkout
82
+
83
+ ```typescript
84
+ import { WalletManager } from "@rajeev02/payments";
85
+
86
+ const wallets = new WalletManager();
87
+
88
+ wallets.register({
89
+ provider: "paytm",
90
+ merchantId: "MID_123",
91
+ environment: "production",
92
+ callbackUrl: "https://myapp.com/callback",
93
+ });
94
+
95
+ const checkout = wallets.generateCheckout("paytm", {
96
+ orderId: "ORD_1234",
97
+ amount: 499,
98
+ customerId: "cust_abc",
99
+ });
100
+ ```
101
+
102
+ ### Subscriptions
103
+
104
+ ```typescript
105
+ import { SubscriptionManager } from "@rajeev02/payments";
106
+
107
+ const subs = new SubscriptionManager();
108
+
109
+ const sub = subs.create({
110
+ planId: "pro_monthly",
111
+ customerEmail: "rajeev@example.com",
112
+ amount: 999,
113
+ currency: "INR",
114
+ interval: "month",
115
+ trialDays: 14,
116
+ });
117
+ ```
118
+
119
+ ## API Reference
120
+
121
+ | Export | Type | Description |
122
+ | ---------------------- | ---------- | ------------------------------------------ |
123
+ | `generateUpiUri()` | `function` | Generate UPI deep link URI |
124
+ | `validateVpa()` | `function` | Validate UPI Virtual Payment Address |
125
+ | `getPspName()` | `function` | Get PSP name from VPA handle |
126
+ | `detectCardNetwork()` | `function` | Detect Visa/MC/Amex/RuPay from card number |
127
+ | `formatCardNumber()` | `function` | Format card with spaces |
128
+ | `validateCardNumber()` | `function` | Luhn algorithm validation |
129
+ | `WalletManager` | `class` | Register and manage wallet providers |
130
+ | `SubscriptionManager` | `class` | Subscription lifecycle management |
131
+ | `RefundManager` | `class` | Full/partial refund processing |
132
+
133
+ ## Full Documentation
134
+
135
+ 📖 [Complete API docs with all payment flows](https://github.com/Rajeev02/rajeev-sdk/blob/main/docs/usage/PAYMENTS.md)
136
+
137
+ ## License
138
+
139
+ MIT © 2026 [Rajeev Kumar Joshi](https://rajeev02.github.io)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rajeev02/payments",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Payments Abstraction SDK — UPI, wallets, cards, subscriptions, split payments (India-focused)",
5
5
  "main": "lib/index.js",
6
6
  "author": "Rajeev Kumar Joshi <rajeevjoshi91@gmail.com> (https://rajeev02.github.io)",