@caspay/sdk 1.0.2 → 1.0.4
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 +3 -4
- package/dist/caspay.min.js +1 -1
- package/dist/core/client.d.ts +1 -1
- package/dist/index.esm.js +4 -5
- package/dist/index.js +4 -5
- package/dist/types/index.d.ts +0 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ yarn add @caspay/sdk
|
|
|
18
18
|
### CDN (WordPress, HTML)
|
|
19
19
|
|
|
20
20
|
```html
|
|
21
|
-
<script src="https://cdn.jsdelivr.net/npm/@caspay/sdk@1.0.
|
|
21
|
+
<script src="https://cdn.jsdelivr.net/npm/@caspay/sdk@1.0.4/dist/caspay.min.js"></script>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## 📖 Quick Start
|
|
@@ -47,7 +47,7 @@ console.log('Payment successful:', payment);
|
|
|
47
47
|
### WordPress / HTML
|
|
48
48
|
|
|
49
49
|
```html
|
|
50
|
-
<script src="https://cdn.jsdelivr.net/npm/@caspay/sdk@1.0.
|
|
50
|
+
<script src="https://cdn.jsdelivr.net/npm/@caspay/sdk@1.0.4/dist/caspay.min.js"></script>
|
|
51
51
|
|
|
52
52
|
<button id="payBtn">Pay Now</button>
|
|
53
53
|
|
|
@@ -77,7 +77,6 @@ console.log('Payment successful:', payment);
|
|
|
77
77
|
const caspay = new CasPay({
|
|
78
78
|
apiKey: string; // Required: Your CasPay API key
|
|
79
79
|
merchantId: string; // Required: Your merchant ID
|
|
80
|
-
baseUrl?: string; // Optional: API base URL (default: https://api.caspay.link)
|
|
81
80
|
});
|
|
82
81
|
```
|
|
83
82
|
|
|
@@ -194,7 +193,7 @@ Full TypeScript support with type definitions included:
|
|
|
194
193
|
import CasPay, { PaymentCreateParams, PaymentResponse } from '@caspay/sdk';
|
|
195
194
|
|
|
196
195
|
const params: PaymentCreateParams = {
|
|
197
|
-
senderAddress: '
|
|
196
|
+
senderAddress: '0123...',
|
|
198
197
|
productId: 'prod_abc',
|
|
199
198
|
amount: 100
|
|
200
199
|
};
|
package/dist/caspay.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).CasPay=e()}(this,function(){"use strict";class t{constructor(t){if(this.
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).CasPay=e()}(this,function(){"use strict";class t{constructor(t){if(this.baseUrl="https://caspay.link/api",this.SDK_VERSION="1.0.4",this.apiKey=t.apiKey,this.merchantId=t.merchantId,!this.apiKey)throw new Error("CasPay SDK: apiKey is required");if(!this.merchantId)throw new Error("CasPay SDK: merchantId is required")}async request(t,e,r){const s=`${this.baseUrl}${e}`;try{const e=await fetch(s,{method:t,headers:{"Content-Type":"application/json","X-CasPay-Key":this.apiKey,"X-CasPay-SDK-Version":this.SDK_VERSION,"User-Agent":`CasPay-SDK-JS/${this.SDK_VERSION}`},body:r?JSON.stringify(r):void 0}),i=await e.json();if(!e.ok){throw{error:i.error||"Request failed",code:i.code||"UNKNOWN_ERROR",status:e.status}}return i}catch(t){if(t.error&&t.code)throw t;throw{error:t.message||"Network error",code:"NETWORK_ERROR",status:0}}}getMerchantId(){return this.merchantId}}class e{constructor(t){this.client=t}async create(t){if(!t.senderAddress)throw{error:"senderAddress is required",code:"INVALID_PARAMS",status:400};if(!t.amount||t.amount<=0)throw{error:"amount must be greater than 0",code:"INVALID_PARAMS",status:400};if(!t.productId&&!t.subscriptionPlanId)throw{error:"Either productId or subscriptionPlanId is required",code:"INVALID_PARAMS",status:400};const e={merchant_id:this.client.getMerchantId(),sender_address:t.senderAddress,transaction_hash:t.transactionHash||`mock_tx_${Date.now()}`,product_id:t.productId,subscription_plan_id:t.subscriptionPlanId,amount:t.amount,currency:t.currency||"USD"};return this.client.request("POST","/v1/payments/record",e)}}class r{constructor(r){this.client=new t(r),this.payments=new e(this.client)}static get version(){return"1.0.4"}}return"undefined"!=typeof window&&(window.CasPay=r),r});
|
package/dist/core/client.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { CasPayConfig } from '../types';
|
|
|
4
4
|
* Handles all API requests with authentication and error handling
|
|
5
5
|
*/
|
|
6
6
|
export declare class HttpClient {
|
|
7
|
-
private baseUrl;
|
|
7
|
+
private readonly baseUrl;
|
|
8
8
|
private apiKey;
|
|
9
9
|
private merchantId;
|
|
10
10
|
private readonly SDK_VERSION;
|
package/dist/index.esm.js
CHANGED
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
class HttpClient {
|
|
6
6
|
constructor(config) {
|
|
7
|
-
this.
|
|
8
|
-
|
|
9
|
-
this.baseUrl = config.baseUrl || 'https://api.caspay.link';
|
|
7
|
+
this.baseUrl = 'https://caspay.link/api';
|
|
8
|
+
this.SDK_VERSION = '1.0.4';
|
|
10
9
|
this.apiKey = config.apiKey;
|
|
11
10
|
this.merchantId = config.merchantId;
|
|
12
11
|
// Validate required config
|
|
@@ -116,7 +115,7 @@ class Payments {
|
|
|
116
115
|
amount: params.amount,
|
|
117
116
|
currency: params.currency || 'USD',
|
|
118
117
|
};
|
|
119
|
-
return this.client.request('POST', '/
|
|
118
|
+
return this.client.request('POST', '/v1/payments/record', payload);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
|
@@ -153,7 +152,7 @@ class CasPay {
|
|
|
153
152
|
* Get SDK version
|
|
154
153
|
*/
|
|
155
154
|
static get version() {
|
|
156
|
-
return '1.0.
|
|
155
|
+
return '1.0.4';
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
|
package/dist/index.js
CHANGED
|
@@ -8,9 +8,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
8
8
|
*/
|
|
9
9
|
class HttpClient {
|
|
10
10
|
constructor(config) {
|
|
11
|
-
this.
|
|
12
|
-
|
|
13
|
-
this.baseUrl = config.baseUrl || 'https://api.caspay.link';
|
|
11
|
+
this.baseUrl = 'https://caspay.link/api';
|
|
12
|
+
this.SDK_VERSION = '1.0.4';
|
|
14
13
|
this.apiKey = config.apiKey;
|
|
15
14
|
this.merchantId = config.merchantId;
|
|
16
15
|
// Validate required config
|
|
@@ -120,7 +119,7 @@ class Payments {
|
|
|
120
119
|
amount: params.amount,
|
|
121
120
|
currency: params.currency || 'USD',
|
|
122
121
|
};
|
|
123
|
-
return this.client.request('POST', '/
|
|
122
|
+
return this.client.request('POST', '/v1/payments/record', payload);
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
|
|
@@ -157,7 +156,7 @@ class CasPay {
|
|
|
157
156
|
* Get SDK version
|
|
158
157
|
*/
|
|
159
158
|
static get version() {
|
|
160
|
-
return '1.0.
|
|
159
|
+
return '1.0.4';
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED