@caspay/sdk 1.0.4 → 1.1.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 +277 -53
- package/dist/browser.d.ts +0 -15
- package/dist/caspay.min.js +2 -1
- package/dist/core/client.d.ts +1 -5
- package/dist/core/transfer.d.ts +8 -0
- package/dist/index.d.ts +7 -28
- package/dist/index.esm.js +460 -62
- package/dist/index.js +460 -62
- package/dist/resources/payments.d.ts +9 -23
- package/dist/resources/subscriptions.d.ts +7 -0
- package/dist/resources/wallet.d.ts +21 -0
- package/dist/types/index.d.ts +57 -31
- package/dist/version.d.ts +1 -0
- package/package.json +9 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -1,47 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CasPay SDK Configuration
|
|
3
|
-
*/
|
|
4
1
|
export interface CasPayConfig {
|
|
5
|
-
/** Your CasPay API key (starts with cp_live_ or cp_test_) */
|
|
6
2
|
apiKey: string;
|
|
7
|
-
/** Your merchant ID (starts with MERCH_) */
|
|
8
3
|
merchantId: string;
|
|
4
|
+
walletAddress: string;
|
|
5
|
+
network?: 'mainnet' | 'testnet';
|
|
6
|
+
baseUrl?: string;
|
|
9
7
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Payment Creation Parameters
|
|
12
|
-
*/
|
|
13
8
|
export interface PaymentCreateParams {
|
|
14
|
-
/** Sender's Casper wallet address */
|
|
15
9
|
senderAddress: string;
|
|
16
|
-
/** Optional: Casper transaction hash (auto-generated in mock mode) */
|
|
17
10
|
transactionHash?: string;
|
|
18
|
-
/** Product ID for one-time payments */
|
|
19
11
|
productId?: string;
|
|
20
|
-
/** Subscription plan ID for recurring payments */
|
|
21
12
|
subscriptionPlanId?: string;
|
|
22
|
-
/** Payment amount */
|
|
23
13
|
amount: number;
|
|
24
|
-
/** Currency code (default: USD) */
|
|
25
14
|
currency?: string;
|
|
26
15
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Subscription Creation Parameters
|
|
29
|
-
*/
|
|
30
16
|
export interface SubscriptionCreateParams {
|
|
31
|
-
/** Subscriber's Casper wallet address */
|
|
32
17
|
senderAddress: string;
|
|
33
|
-
/** Optional: Casper transaction hash */
|
|
34
18
|
transactionHash?: string;
|
|
35
|
-
/** Subscription plan ID */
|
|
36
19
|
planId: string;
|
|
37
|
-
/** Payment amount */
|
|
38
20
|
amount: number;
|
|
39
|
-
/** Currency code (default: USD) */
|
|
40
21
|
currency?: string;
|
|
41
22
|
}
|
|
42
|
-
/**
|
|
43
|
-
* Payment Response
|
|
44
|
-
*/
|
|
45
23
|
export interface PaymentResponse {
|
|
46
24
|
success: boolean;
|
|
47
25
|
payment: {
|
|
@@ -61,9 +39,6 @@ export interface PaymentResponse {
|
|
|
61
39
|
duplicate?: boolean;
|
|
62
40
|
responseTime?: string;
|
|
63
41
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Subscription Response
|
|
66
|
-
*/
|
|
67
42
|
export interface SubscriptionResponse {
|
|
68
43
|
success: boolean;
|
|
69
44
|
payment: {
|
|
@@ -74,11 +49,62 @@ export interface SubscriptionResponse {
|
|
|
74
49
|
};
|
|
75
50
|
subscription_id?: string;
|
|
76
51
|
}
|
|
77
|
-
/**
|
|
78
|
-
* API Error Response
|
|
79
|
-
*/
|
|
80
52
|
export interface CasPayError {
|
|
81
53
|
error: string;
|
|
82
54
|
code: string;
|
|
83
55
|
status?: number;
|
|
84
56
|
}
|
|
57
|
+
export interface MakePaymentParams {
|
|
58
|
+
productId?: string;
|
|
59
|
+
subscriptionPlanId?: string;
|
|
60
|
+
amount: number;
|
|
61
|
+
currency?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface MakePaymentResult {
|
|
64
|
+
success: boolean;
|
|
65
|
+
transactionHash: string;
|
|
66
|
+
payment?: PaymentResponse;
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface WalletState {
|
|
70
|
+
connected: boolean;
|
|
71
|
+
address: string | null;
|
|
72
|
+
locked: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface WalletInfo {
|
|
75
|
+
isConnected: boolean;
|
|
76
|
+
address: string | null;
|
|
77
|
+
}
|
|
78
|
+
export interface WalletError {
|
|
79
|
+
code: 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'CONNECTION_REJECTED' | 'TRANSFER_REJECTED' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
|
|
80
|
+
message: string;
|
|
81
|
+
installUrl?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface TransferParams {
|
|
84
|
+
recipientAddress: string;
|
|
85
|
+
amount: number;
|
|
86
|
+
}
|
|
87
|
+
export interface TransferResult {
|
|
88
|
+
deployHash: string;
|
|
89
|
+
senderAddress: string;
|
|
90
|
+
recipientAddress: string;
|
|
91
|
+
amount: number;
|
|
92
|
+
}
|
|
93
|
+
export interface SubscriptionCheckParams {
|
|
94
|
+
subscriberAddress: string;
|
|
95
|
+
planId?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface SubscriptionCheckResponse {
|
|
98
|
+
success: boolean;
|
|
99
|
+
active: boolean;
|
|
100
|
+
subscriptions?: Array<{
|
|
101
|
+
id: string;
|
|
102
|
+
plan_id: string;
|
|
103
|
+
subscriber_address: string;
|
|
104
|
+
status: string;
|
|
105
|
+
current_period_start: string;
|
|
106
|
+
current_period_end: string;
|
|
107
|
+
created_at: string;
|
|
108
|
+
}>;
|
|
109
|
+
message?: string;
|
|
110
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "1.1.0";
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caspay/sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Official CasPay JavaScript/TypeScript SDK - Accept crypto payments with Casper blockchain",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"module": "dist/index.esm.js",
|
|
7
8
|
"browser": "dist/caspay.min.js",
|
|
@@ -12,8 +13,9 @@
|
|
|
12
13
|
"LICENSE"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
|
-
"build": "rollup -c",
|
|
16
|
+
"build": "npm run version:sync && rollup -c",
|
|
16
17
|
"dev": "rollup -c -w",
|
|
18
|
+
"version:sync": "node scripts/update-version.js",
|
|
17
19
|
"prepublishOnly": "npm run build",
|
|
18
20
|
"test": "echo \"Error: no test specified\" && exit 0"
|
|
19
21
|
},
|
|
@@ -43,11 +45,15 @@
|
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
47
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
48
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
46
49
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
47
50
|
"@rollup/plugin-typescript": "^11.1.5",
|
|
48
51
|
"rollup": "^4.9.1",
|
|
49
|
-
"rollup
|
|
52
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
50
53
|
"tslib": "^2.8.1",
|
|
51
54
|
"typescript": "^5.3.3"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"casper-js-sdk": "^5.0.5"
|
|
52
58
|
}
|
|
53
59
|
}
|