@caspay/sdk 1.0.3 → 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 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.2/dist/caspay.min.js"></script>
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.2/dist/caspay.min.js"></script>
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
 
@@ -80,8 +80,6 @@ const caspay = new CasPay({
80
80
  });
81
81
  ```
82
82
 
83
- **Note:** API endpoint is fixed to `https://caspay.link/api` for all requests.
84
-
85
83
  ### Get API Keys
86
84
 
87
85
  1. Sign up at [caspay.link](https://caspay.link)
@@ -195,7 +193,7 @@ Full TypeScript support with type definitions included:
195
193
  import CasPay, { PaymentCreateParams, PaymentResponse } from '@caspay/sdk';
196
194
 
197
195
  const params: PaymentCreateParams = {
198
- senderAddress: '0x123...',
196
+ senderAddress: '0123...',
199
197
  productId: 'prod_abc',
200
198
  amount: 100
201
199
  };
@@ -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.baseUrl="https://caspay.link/api",this.SDK_VERSION="1.0.3",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","/api/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.0"}}return"undefined"!=typeof window&&(window.CasPay=r),r});
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/index.esm.js CHANGED
@@ -5,7 +5,7 @@
5
5
  class HttpClient {
6
6
  constructor(config) {
7
7
  this.baseUrl = 'https://caspay.link/api';
8
- this.SDK_VERSION = '1.0.3';
8
+ this.SDK_VERSION = '1.0.4';
9
9
  this.apiKey = config.apiKey;
10
10
  this.merchantId = config.merchantId;
11
11
  // Validate required config
@@ -115,7 +115,7 @@ class Payments {
115
115
  amount: params.amount,
116
116
  currency: params.currency || 'USD',
117
117
  };
118
- return this.client.request('POST', '/api/v1/payments/record', payload);
118
+ return this.client.request('POST', '/v1/payments/record', payload);
119
119
  }
120
120
  }
121
121
 
@@ -152,7 +152,7 @@ class CasPay {
152
152
  * Get SDK version
153
153
  */
154
154
  static get version() {
155
- return '1.0.0';
155
+ return '1.0.4';
156
156
  }
157
157
  }
158
158
 
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
9
  class HttpClient {
10
10
  constructor(config) {
11
11
  this.baseUrl = 'https://caspay.link/api';
12
- this.SDK_VERSION = '1.0.3';
12
+ this.SDK_VERSION = '1.0.4';
13
13
  this.apiKey = config.apiKey;
14
14
  this.merchantId = config.merchantId;
15
15
  // Validate required config
@@ -119,7 +119,7 @@ class Payments {
119
119
  amount: params.amount,
120
120
  currency: params.currency || 'USD',
121
121
  };
122
- return this.client.request('POST', '/api/v1/payments/record', payload);
122
+ return this.client.request('POST', '/v1/payments/record', payload);
123
123
  }
124
124
  }
125
125
 
@@ -156,7 +156,7 @@ class CasPay {
156
156
  * Get SDK version
157
157
  */
158
158
  static get version() {
159
- return '1.0.0';
159
+ return '1.0.4';
160
160
  }
161
161
  }
162
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caspay/sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Official CasPay JavaScript/TypeScript SDK - Accept crypto payments with Casper blockchain",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",