arcpaykit 0.1.0 → 0.3.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
@@ -1,6 +1,9 @@
1
1
  # arcpaykit
2
2
 
3
- Official ArcPay JavaScript SDK for accepting stablecoin payments.
3
+ Official ArcPay JavaScript/TypeScript SDK for accepting stablecoin payments.
4
+
5
+ [![npm version](https://badge.fury.io/js/arcpaykit.svg)](https://www.npmjs.com/package/arcpaykit)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
7
 
5
8
  ## Installation
6
9
 
@@ -10,25 +13,43 @@ npm install arcpaykit
10
13
 
11
14
  ## Quick Start
12
15
 
16
+ Get started in 5 minutes:
17
+
13
18
  ```typescript
14
19
  import { ArcPay } from "arcpaykit";
15
20
 
16
21
  const arcpay = new ArcPay("your-api-key");
17
22
 
18
- // Create a payment
23
+ // Verify API connectivity
24
+ const ping = await arcpay.ping();
25
+ console.log(ping.status); // "ok"
26
+
27
+ // Create a payment (happy path - recommended)
19
28
  const payment = await arcpay.payments.create({
20
29
  amount: "100.00",
21
30
  currency: "USDC",
22
- merchantWallet: "0x...",
23
- description: "Payment for order #123"
31
+ description: "Payment for order #123",
32
+ customerEmail: "customer@example.com"
24
33
  });
25
34
 
26
- console.log(payment.checkout_url); // Send this URL to your customer
35
+ // Redirect customer to checkout
36
+ console.log(payment.checkout_url); // https://arcpay.systems/checkout/pay_...
27
37
 
28
- // Retrieve a payment
29
- const retrieved = await arcpay.payments.retrieve(payment.id);
38
+ // That's it! ArcPay handles:
39
+ // - Merchant wallet (uses your default)
40
+ // - Test/live mode (inferred from API key)
41
+ // - Payment chain (inferred automatically)
42
+ // - Settlement currency (defaults to USDC)
30
43
  ```
31
44
 
45
+ **No need to configure:**
46
+ - ❌ Merchant wallet (uses your default)
47
+ - ❌ Test/live mode (inferred from API key: `sk_arc_test_` vs `sk_arc_live_`)
48
+ - ❌ Payment chain ID (inferred automatically)
49
+ - ❌ Settlement currency (defaults to USDC)
50
+
51
+ For advanced use cases, see `payments.createAdvanced()` below.
52
+
32
53
  ## API Reference
33
54
 
34
55
  ### ArcPay
@@ -42,18 +63,56 @@ new ArcPay(apiKey: string, baseUrl?: string)
42
63
  ```
43
64
 
44
65
  - `apiKey`: Your ArcPay API key
45
- - `baseUrl`: Optional base URL (defaults to `https://pay.arcpaykit.com`)
66
+ - `baseUrl`: Optional base URL (defaults to `https://arcpay.systems`)
67
+
68
+ ### ping()
69
+
70
+ Verify API connectivity.
71
+
72
+ ```typescript
73
+ const result = await arcpay.ping();
74
+ // { status: "ok", timestamp: "2024-01-02T10:00:00.000Z" }
75
+ ```
46
76
 
47
77
  ### Payments
48
78
 
49
- #### `create(data: CreatePaymentRequest): Promise<CreatePaymentResponse>`
79
+ #### `create(data: SimpleCreatePaymentRequest): Promise<CreatePaymentResponse>`
80
+
81
+ Create a new payment (happy path - recommended for most users).
82
+
83
+ **Most users should use this method.** It only requires essential fields. All advanced fields are inferred automatically.
84
+
85
+ **Request:**
86
+ ```typescript
87
+ {
88
+ amount: string; // Required: Payment amount (e.g., "100.00")
89
+ currency?: string; // Optional: Payment currency (default: "USDC")
90
+ description?: string; // Optional: Payment description
91
+ customerEmail?: string; // Optional: Customer email
92
+ }
93
+ ```
94
+
95
+ **Example:**
96
+ ```typescript
97
+ const payment = await arcpay.payments.create({
98
+ amount: "100.00",
99
+ currency: "USDC",
100
+ description: "Order #123",
101
+ customerEmail: "customer@example.com"
102
+ });
103
+ ```
104
+
105
+ #### `createAdvanced(data: CreatePaymentRequest): Promise<CreatePaymentResponse>`
50
106
 
51
- Create a new payment.
107
+ Create a new payment with full control (advanced users only).
108
+
109
+ **Most users should use `payments.create()` instead.** This method allows full control over all payment parameters.
52
110
 
53
111
  **Request:**
54
112
  ```typescript
55
113
  {
56
114
  amount: string; // Required: Payment amount
115
+ merchantWallet?: string; // Optional: Merchant wallet (uses default if not provided)
57
116
  currency?: string; // Optional: Payment currency (default: "USDC")
58
117
  settlementCurrency?: "USDC" | "EURC"; // Optional: Settlement currency (default: "USDC")
59
118
  paymentAsset?: string; // Optional: Specific asset identifier
@@ -62,9 +121,8 @@ Create a new payment.
62
121
  estimatedFees?: string; // Optional: Estimated fees
63
122
  description?: string; // Optional: Payment description
64
123
  customerEmail?: string; // Optional: Customer email
65
- merchantWallet: string; // Required: Merchant wallet address
66
124
  expiresInMinutes?: number; // Optional: Expiration time in minutes
67
- isTest?: boolean; // Optional: Test mode flag
125
+ isTest?: boolean; // Optional: Test mode flag (inferred from API key if not provided)
68
126
  gasSponsored?: boolean; // Optional: Gas sponsorship preference
69
127
  }
70
128
  ```
@@ -139,30 +197,57 @@ import { ArcPay } from "arcpaykit";
139
197
 
140
198
  const arcpay = new ArcPay(process.env.ARCPAY_API_KEY!);
141
199
 
142
- // Create payment
200
+ // Verify connectivity first
201
+ const ping = await arcpay.ping();
202
+ if (ping.status !== "ok") {
203
+ throw new Error("Cannot connect to ArcPay API");
204
+ }
205
+
206
+ // Create payment (simple - recommended)
143
207
  const payment = await arcpay.payments.create({
144
208
  amount: "50.00",
145
209
  currency: "USDC",
146
- merchantWallet: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
147
210
  description: "Monthly subscription",
148
- customerEmail: "customer@example.com",
149
- expiresInMinutes: 30
211
+ customerEmail: "customer@example.com"
150
212
  });
151
213
 
152
214
  console.log(`Payment created: ${payment.id}`);
153
215
  console.log(`Checkout URL: ${payment.checkout_url}`);
154
216
 
217
+ // Redirect customer
218
+ window.location.href = payment.checkout_url;
219
+
155
220
  // Later, check payment status
156
221
  const status = await arcpay.payments.retrieve(payment.id);
157
222
  console.log(`Payment status: ${status.status}`);
158
223
  ```
159
224
 
225
+ ### Advanced Payment Creation
226
+
227
+ For full control over payment parameters:
228
+
229
+ ```typescript
230
+ const payment = await arcpay.payments.createAdvanced({
231
+ amount: "50.00",
232
+ merchantWallet: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
233
+ currency: "USDC",
234
+ settlementCurrency: "EURC",
235
+ paymentAsset: "USDC_BASE",
236
+ paymentChainId: 8453,
237
+ description: "Monthly subscription",
238
+ customerEmail: "customer@example.com",
239
+ expiresInMinutes: 30,
240
+ isTest: false,
241
+ gasSponsored: true
242
+ });
243
+ ```
244
+
160
245
  ### Using Custom Base URL
161
246
 
162
247
  ```typescript
163
248
  const arcpay = new ArcPay(
164
249
  "your-api-key",
165
- "https://staging.arcpaykit.com"
250
+ "https://staging.arcpay.systems"
166
251
  );
167
252
  ```
168
253
 
@@ -180,9 +265,14 @@ try {
180
265
 
181
266
  ## REST API
182
267
 
183
- The SDK is a thin wrapper around the ArcPay REST API. You can also use the REST API directly if needed. See the [ArcPay API documentation](https://docs.arcpaykit.com) for more details.
268
+ The SDK is a thin wrapper around the ArcPay REST API. You can also use the REST API directly if needed. See the [ArcPay API documentation](https://arcpay.systems/docs) for more details.
269
+
270
+ ## Support
271
+
272
+ - 📚 [Documentation](https://arcpay.systems/docs)
273
+ - 💬 [Discord Community](https://discord.gg/arcpay)
274
+ - 🐛 [Report Issues](https://github.com/ArcPayKit/gateway/issues)
184
275
 
185
276
  ## License
186
277
 
187
278
  MIT
188
-
package/dist/client.d.ts CHANGED
@@ -1,6 +1,16 @@
1
+ export interface PingResponse {
2
+ status: string;
3
+ timestamp: string;
4
+ version?: string;
5
+ }
1
6
  export declare class ArcPayClient {
2
7
  private apiKey;
3
8
  private baseUrl;
4
9
  constructor(apiKey: string, baseUrl?: string);
5
10
  request<T = any>(path: string, options?: RequestInit): Promise<T>;
11
+ /**
12
+ * Ping the ArcPay API to verify connectivity
13
+ * @returns Promise with status and timestamp
14
+ */
15
+ ping(): Promise<PingResponse>;
6
16
  }
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArcPayClient = void 0;
4
4
  class ArcPayClient {
5
- constructor(apiKey, baseUrl = "https://pay.arcpaykit.com") {
5
+ constructor(apiKey, baseUrl = "https://arcpay.systems") {
6
6
  this.apiKey = apiKey;
7
7
  this.baseUrl = baseUrl;
8
8
  }
@@ -21,5 +21,37 @@ class ArcPayClient {
21
21
  }
22
22
  return res.json();
23
23
  }
24
+ /**
25
+ * Ping the ArcPay API to verify connectivity
26
+ * @returns Promise with status and timestamp
27
+ */
28
+ async ping() {
29
+ const start = Date.now();
30
+ try {
31
+ const res = await fetch(`${this.baseUrl}/api/health`, {
32
+ method: "GET",
33
+ headers: {
34
+ "Authorization": `Bearer ${this.apiKey}`,
35
+ }
36
+ });
37
+ if (res.ok) {
38
+ return {
39
+ status: "ok",
40
+ timestamp: new Date().toISOString(),
41
+ version: "1.0.0"
42
+ };
43
+ }
44
+ return {
45
+ status: "error",
46
+ timestamp: new Date().toISOString()
47
+ };
48
+ }
49
+ catch (error) {
50
+ return {
51
+ status: "error",
52
+ timestamp: new Date().toISOString()
53
+ };
54
+ }
55
+ }
24
56
  }
25
57
  exports.ArcPayClient = ArcPayClient;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,20 @@
1
+ import { PingResponse } from "./client";
1
2
  import { Payments } from "./payments";
2
3
  export declare class ArcPay {
3
4
  payments: Payments;
5
+ private client;
4
6
  constructor(apiKey: string, baseUrl?: string);
7
+ /**
8
+ * Ping the ArcPay API to verify connectivity
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const result = await arcpay.ping();
13
+ * console.log(result.status); // "ok"
14
+ * ```
15
+ */
16
+ ping(): Promise<PingResponse>;
5
17
  }
6
- export type { CreatePaymentRequest, CreatePaymentResponse, Payment, ConfirmPaymentRequest, ConfirmPaymentResponse, FailPaymentRequest, FailPaymentResponse, ExpirePaymentRequest, ExpirePaymentResponse, } from "./payments";
18
+ export type { CreatePaymentRequest, SimpleCreatePaymentRequest, CreatePaymentResponse, Payment, ConfirmPaymentRequest, ConfirmPaymentResponse, FailPaymentRequest, FailPaymentResponse, ExpirePaymentRequest, ExpirePaymentResponse, } from "./payments";
19
+ export type { PingResponse } from "./client";
7
20
  export default ArcPay;
package/dist/index.js CHANGED
@@ -5,8 +5,20 @@ const client_1 = require("./client");
5
5
  const payments_1 = require("./payments");
6
6
  class ArcPay {
7
7
  constructor(apiKey, baseUrl) {
8
- const client = new client_1.ArcPayClient(apiKey, baseUrl);
9
- this.payments = new payments_1.Payments(client);
8
+ this.client = new client_1.ArcPayClient(apiKey, baseUrl);
9
+ this.payments = new payments_1.Payments(this.client);
10
+ }
11
+ /**
12
+ * Ping the ArcPay API to verify connectivity
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const result = await arcpay.ping();
17
+ * console.log(result.status); // "ok"
18
+ * ```
19
+ */
20
+ ping() {
21
+ return this.client.ping();
10
22
  }
11
23
  }
12
24
  exports.ArcPay = ArcPay;
@@ -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,12 +1,27 @@
1
1
  {
2
2
  "name": "arcpaykit",
3
- "version": "0.1.0",
4
- "description": "Official ArcPay JavaScript SDK",
3
+ "version": "0.3.0",
4
+ "description": "Official ArcPay JavaScript SDK for accepting stablecoin payments",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "files": ["dist"],
7
+ "files": [
8
+ "dist"
9
+ ],
8
10
  "license": "MIT",
9
- "keywords": ["payments", "web3", "stablecoin", "arcpay"],
11
+ "keywords": [
12
+ "payments",
13
+ "web3",
14
+ "stablecoin",
15
+ "arcpay",
16
+ "crypto",
17
+ "usdc",
18
+ "eurc",
19
+ "blockchain"
20
+ ],
21
+ "homepage": "https://arcpay.systems",
22
+ "bugs": {
23
+ "url": "https://github.com/ArcPayKit/gateway/issues"
24
+ },
10
25
  "scripts": {
11
26
  "build": "tsc",
12
27
  "prepublishOnly": "npm run build"
@@ -16,7 +31,9 @@
16
31
  },
17
32
  "repository": {
18
33
  "type": "git",
19
- "url": "https://github.com/arcpay/gateway.git"
34
+ "url": "https://github.com/ArcPayKit/gateway.git"
35
+ },
36
+ "engines": {
37
+ "node": ">=16.0.0"
20
38
  }
21
- }
22
-
39
+ }