arcpaykit 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.
package/README.md CHANGED
@@ -10,25 +10,39 @@ npm install arcpaykit
10
10
 
11
11
  ## Quick Start
12
12
 
13
+ Get started in 5 minutes:
14
+
13
15
  ```typescript
14
16
  import { ArcPay } from "arcpaykit";
15
17
 
16
18
  const arcpay = new ArcPay("your-api-key");
17
19
 
18
- // Create a payment
20
+ // Create a payment (happy path - recommended)
19
21
  const payment = await arcpay.payments.create({
20
22
  amount: "100.00",
21
23
  currency: "USDC",
22
- merchantWallet: "0x...",
23
- description: "Payment for order #123"
24
+ description: "Payment for order #123",
25
+ customerEmail: "customer@example.com"
24
26
  });
25
27
 
26
- console.log(payment.checkout_url); // Send this URL to your customer
28
+ // Redirect customer to checkout
29
+ console.log(payment.checkout_url); // https://pay.arcpaykit.com/checkout/pay_...
27
30
 
28
- // Retrieve a payment
29
- const retrieved = await arcpay.payments.retrieve(payment.id);
31
+ // That's it! ArcPay handles:
32
+ // - Merchant wallet (uses your default)
33
+ // - Test/live mode (inferred from API key)
34
+ // - Payment chain (inferred automatically)
35
+ // - Settlement currency (defaults to USDC)
30
36
  ```
31
37
 
38
+ **No need to configure:**
39
+ - ❌ Merchant wallet (uses your default)
40
+ - ❌ Test/live mode (inferred from API key: `sk_arc_test_` vs `sk_arc_live_`)
41
+ - ❌ Payment chain ID (inferred automatically)
42
+ - ❌ Settlement currency (defaults to USDC)
43
+
44
+ For advanced use cases, see `payments.createAdvanced()` below.
45
+
32
46
  ## API Reference
33
47
 
34
48
  ### ArcPay
@@ -46,14 +60,43 @@ new ArcPay(apiKey: string, baseUrl?: string)
46
60
 
47
61
  ### Payments
48
62
 
49
- #### `create(data: CreatePaymentRequest): Promise<CreatePaymentResponse>`
63
+ #### `create(data: SimpleCreatePaymentRequest): Promise<CreatePaymentResponse>`
64
+
65
+ Create a new payment (happy path - recommended for most users).
66
+
67
+ **Most users should use this method.** It only requires essential fields. All advanced fields are inferred automatically.
68
+
69
+ **Request:**
70
+ ```typescript
71
+ {
72
+ amount: string; // Required: Payment amount (e.g., "100.00")
73
+ currency?: string; // Optional: Payment currency (default: "USDC")
74
+ description?: string; // Optional: Payment description
75
+ customerEmail?: string; // Optional: Customer email
76
+ }
77
+ ```
78
+
79
+ **Example:**
80
+ ```typescript
81
+ const payment = await arcpay.payments.create({
82
+ amount: "100.00",
83
+ currency: "USDC",
84
+ description: "Order #123",
85
+ customerEmail: "customer@example.com"
86
+ });
87
+ ```
88
+
89
+ #### `createAdvanced(data: CreatePaymentRequest): Promise<CreatePaymentResponse>`
90
+
91
+ Create a new payment with full control (advanced users only).
50
92
 
51
- Create a new payment.
93
+ **Most users should use `payments.create()` instead.** This method allows full control over all payment parameters.
52
94
 
53
95
  **Request:**
54
96
  ```typescript
55
97
  {
56
98
  amount: string; // Required: Payment amount
99
+ merchantWallet?: string; // Optional: Merchant wallet (uses default if not provided)
57
100
  currency?: string; // Optional: Payment currency (default: "USDC")
58
101
  settlementCurrency?: "USDC" | "EURC"; // Optional: Settlement currency (default: "USDC")
59
102
  paymentAsset?: string; // Optional: Specific asset identifier
@@ -62,9 +105,8 @@ Create a new payment.
62
105
  estimatedFees?: string; // Optional: Estimated fees
63
106
  description?: string; // Optional: Payment description
64
107
  customerEmail?: string; // Optional: Customer email
65
- merchantWallet: string; // Required: Merchant wallet address
66
108
  expiresInMinutes?: number; // Optional: Expiration time in minutes
67
- isTest?: boolean; // Optional: Test mode flag
109
+ isTest?: boolean; // Optional: Test mode flag (inferred from API key if not provided)
68
110
  gasSponsored?: boolean; // Optional: Gas sponsorship preference
69
111
  }
70
112
  ```
@@ -139,24 +181,45 @@ import { ArcPay } from "arcpaykit";
139
181
 
140
182
  const arcpay = new ArcPay(process.env.ARCPAY_API_KEY!);
141
183
 
142
- // Create payment
184
+ // Create payment (simple - recommended)
143
185
  const payment = await arcpay.payments.create({
144
186
  amount: "50.00",
145
187
  currency: "USDC",
146
- merchantWallet: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
147
188
  description: "Monthly subscription",
148
- customerEmail: "customer@example.com",
149
- expiresInMinutes: 30
189
+ customerEmail: "customer@example.com"
150
190
  });
151
191
 
152
192
  console.log(`Payment created: ${payment.id}`);
153
193
  console.log(`Checkout URL: ${payment.checkout_url}`);
154
194
 
195
+ // Redirect customer
196
+ window.location.href = payment.checkout_url;
197
+
155
198
  // Later, check payment status
156
199
  const status = await arcpay.payments.retrieve(payment.id);
157
200
  console.log(`Payment status: ${status.status}`);
158
201
  ```
159
202
 
203
+ ### Advanced Payment Creation
204
+
205
+ For full control over payment parameters:
206
+
207
+ ```typescript
208
+ const payment = await arcpay.payments.createAdvanced({
209
+ amount: "50.00",
210
+ merchantWallet: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
211
+ currency: "USDC",
212
+ settlementCurrency: "EURC",
213
+ paymentAsset: "USDC_BASE",
214
+ paymentChainId: 8453,
215
+ description: "Monthly subscription",
216
+ customerEmail: "customer@example.com",
217
+ expiresInMinutes: 30,
218
+ isTest: false,
219
+ gasSponsored: true
220
+ });
221
+ ```
222
+
160
223
  ### Using Custom Base URL
161
224
 
162
225
  ```typescript
@@ -9,11 +9,21 @@ export interface CreatePaymentRequest {
9
9
  estimatedFees?: string;
10
10
  description?: string;
11
11
  customerEmail?: string;
12
- merchantWallet: string;
12
+ merchantWallet?: string;
13
13
  expiresInMinutes?: number;
14
14
  isTest?: boolean;
15
15
  gasSponsored?: boolean;
16
16
  }
17
+ /**
18
+ * Simple payment creation request (happy path)
19
+ * Only requires essential fields - all others are inferred
20
+ */
21
+ export interface SimpleCreatePaymentRequest {
22
+ amount: string;
23
+ currency?: string;
24
+ description?: string;
25
+ customerEmail?: string;
26
+ }
17
27
  export interface CreatePaymentResponse {
18
28
  id: string;
19
29
  status: string;
@@ -80,9 +90,33 @@ export declare class Payments {
80
90
  private client;
81
91
  constructor(client: ArcPayClient);
82
92
  /**
83
- * Create a new payment
93
+ * Create a new payment (happy path - recommended for most users)
94
+ *
95
+ * This method only requires essential fields. All advanced fields are inferred:
96
+ * - merchantWallet: Uses merchant's default wallet from profile
97
+ * - isTest: Inferred from API key prefix (sk_arc_test_ / sk_arc_live_)
98
+ * - paymentAsset: Defaults to ARC USDC
99
+ * - settlementCurrency: Defaults to USDC
100
+ * - paymentChainId: Inferred automatically
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const payment = await arcpay.payments.create({
105
+ * amount: "100.00",
106
+ * currency: "USDC",
107
+ * description: "Payment for order #123",
108
+ * customerEmail: "customer@example.com"
109
+ * });
110
+ * ```
111
+ */
112
+ create(data: SimpleCreatePaymentRequest): Promise<CreatePaymentResponse>;
113
+ /**
114
+ * Create a new payment with full control (advanced users only)
115
+ *
116
+ * Most users should use payments.create() instead.
117
+ * This method allows full control over all payment parameters.
84
118
  */
85
- create(data: CreatePaymentRequest): Promise<CreatePaymentResponse>;
119
+ createAdvanced(data: CreatePaymentRequest): Promise<CreatePaymentResponse>;
86
120
  /**
87
121
  * Retrieve a payment by ID
88
122
  */
package/dist/payments.js CHANGED
@@ -6,9 +6,44 @@ class Payments {
6
6
  this.client = client;
7
7
  }
8
8
  /**
9
- * Create a new payment
9
+ * Create a new payment (happy path - recommended for most users)
10
+ *
11
+ * This method only requires essential fields. All advanced fields are inferred:
12
+ * - merchantWallet: Uses merchant's default wallet from profile
13
+ * - isTest: Inferred from API key prefix (sk_arc_test_ / sk_arc_live_)
14
+ * - paymentAsset: Defaults to ARC USDC
15
+ * - settlementCurrency: Defaults to USDC
16
+ * - paymentChainId: Inferred automatically
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const payment = await arcpay.payments.create({
21
+ * amount: "100.00",
22
+ * currency: "USDC",
23
+ * description: "Payment for order #123",
24
+ * customerEmail: "customer@example.com"
25
+ * });
26
+ * ```
10
27
  */
11
28
  create(data) {
29
+ return this.client.request("/api/payments/create", {
30
+ method: "POST",
31
+ body: JSON.stringify({
32
+ amount: data.amount,
33
+ currency: data.currency || "USDC",
34
+ description: data.description,
35
+ customerEmail: data.customerEmail,
36
+ // All other fields are inferred server-side
37
+ })
38
+ });
39
+ }
40
+ /**
41
+ * Create a new payment with full control (advanced users only)
42
+ *
43
+ * Most users should use payments.create() instead.
44
+ * This method allows full control over all payment parameters.
45
+ */
46
+ createAdvanced(data) {
12
47
  return this.client.request("/api/payments/create", {
13
48
  method: "POST",
14
49
  body: JSON.stringify(data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arcpaykit",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Official ArcPay JavaScript SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",