@settlr/sdk 0.6.5 → 0.6.6
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/dist/index.js +11 -1
- package/dist/index.mjs +11 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -209,8 +209,13 @@ var Settlr = class {
|
|
|
209
209
|
* Fetches merchant wallet address if not provided in config.
|
|
210
210
|
*/
|
|
211
211
|
async validateApiKey() {
|
|
212
|
-
|
|
212
|
+
console.log("[Settlr] validateApiKey called, validated:", this.validated, "apiBaseUrl:", this.apiBaseUrl);
|
|
213
|
+
if (this.validated) {
|
|
214
|
+
console.log("[Settlr] Already validated, skipping. merchantWallet:", this.merchantWallet?.toString(), "merchantWalletFromValidation:", this.merchantWalletFromValidation);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
213
217
|
try {
|
|
218
|
+
console.log("[Settlr] Fetching validation from:", `${this.apiBaseUrl}/sdk/validate`);
|
|
214
219
|
const response = await fetch(`${this.apiBaseUrl}/sdk/validate`, {
|
|
215
220
|
method: "POST",
|
|
216
221
|
headers: {
|
|
@@ -226,16 +231,19 @@ var Settlr = class {
|
|
|
226
231
|
throw new Error(error.error || "API key validation failed");
|
|
227
232
|
}
|
|
228
233
|
const data = await response.json();
|
|
234
|
+
console.log("[Settlr] Validation response:", data);
|
|
229
235
|
if (!data.valid) {
|
|
230
236
|
throw new Error(data.error || "Invalid API key");
|
|
231
237
|
}
|
|
232
238
|
this.validated = true;
|
|
233
239
|
this.merchantId = data.merchantId;
|
|
234
240
|
this.tier = data.tier;
|
|
241
|
+
console.log("[Settlr] Setting wallet. data.merchantWallet:", data.merchantWallet, "this.merchantWallet:", this.merchantWallet?.toString());
|
|
235
242
|
if (data.merchantWallet && !this.merchantWallet) {
|
|
236
243
|
this.merchantWallet = new import_web32.PublicKey(data.merchantWallet);
|
|
237
244
|
this.merchantWalletFromValidation = data.merchantWallet;
|
|
238
245
|
this.config.merchant.walletAddress = data.merchantWallet;
|
|
246
|
+
console.log("[Settlr] Wallet SET! merchantWallet:", this.merchantWallet.toString(), "merchantWalletFromValidation:", this.merchantWalletFromValidation);
|
|
239
247
|
}
|
|
240
248
|
if (data.merchantName && !this.config.merchant.name) {
|
|
241
249
|
this.config.merchant.name = data.merchantName;
|
|
@@ -276,8 +284,10 @@ var Settlr = class {
|
|
|
276
284
|
*/
|
|
277
285
|
getCheckoutUrl(options) {
|
|
278
286
|
const { amount, memo, orderId, successUrl, cancelUrl } = options;
|
|
287
|
+
console.log("[Settlr] getCheckoutUrl - config.wallet:", this.config.merchant.walletAddress, "merchantWalletFromValidation:", this.merchantWalletFromValidation, "validated:", this.validated);
|
|
279
288
|
const walletAddress = this.config.merchant.walletAddress?.toString() || this.merchantWalletFromValidation;
|
|
280
289
|
if (!walletAddress) {
|
|
290
|
+
console.error("[Settlr] No wallet address available!");
|
|
281
291
|
throw new Error("Wallet address not available. Either provide walletAddress in config or call validateApiKey() first.");
|
|
282
292
|
}
|
|
283
293
|
const baseUrl = this.config.testMode ? SETTLR_CHECKOUT_URL.development : SETTLR_CHECKOUT_URL.production;
|
package/dist/index.mjs
CHANGED
|
@@ -145,8 +145,13 @@ var Settlr = class {
|
|
|
145
145
|
* Fetches merchant wallet address if not provided in config.
|
|
146
146
|
*/
|
|
147
147
|
async validateApiKey() {
|
|
148
|
-
|
|
148
|
+
console.log("[Settlr] validateApiKey called, validated:", this.validated, "apiBaseUrl:", this.apiBaseUrl);
|
|
149
|
+
if (this.validated) {
|
|
150
|
+
console.log("[Settlr] Already validated, skipping. merchantWallet:", this.merchantWallet?.toString(), "merchantWalletFromValidation:", this.merchantWalletFromValidation);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
149
153
|
try {
|
|
154
|
+
console.log("[Settlr] Fetching validation from:", `${this.apiBaseUrl}/sdk/validate`);
|
|
150
155
|
const response = await fetch(`${this.apiBaseUrl}/sdk/validate`, {
|
|
151
156
|
method: "POST",
|
|
152
157
|
headers: {
|
|
@@ -162,16 +167,19 @@ var Settlr = class {
|
|
|
162
167
|
throw new Error(error.error || "API key validation failed");
|
|
163
168
|
}
|
|
164
169
|
const data = await response.json();
|
|
170
|
+
console.log("[Settlr] Validation response:", data);
|
|
165
171
|
if (!data.valid) {
|
|
166
172
|
throw new Error(data.error || "Invalid API key");
|
|
167
173
|
}
|
|
168
174
|
this.validated = true;
|
|
169
175
|
this.merchantId = data.merchantId;
|
|
170
176
|
this.tier = data.tier;
|
|
177
|
+
console.log("[Settlr] Setting wallet. data.merchantWallet:", data.merchantWallet, "this.merchantWallet:", this.merchantWallet?.toString());
|
|
171
178
|
if (data.merchantWallet && !this.merchantWallet) {
|
|
172
179
|
this.merchantWallet = new PublicKey2(data.merchantWallet);
|
|
173
180
|
this.merchantWalletFromValidation = data.merchantWallet;
|
|
174
181
|
this.config.merchant.walletAddress = data.merchantWallet;
|
|
182
|
+
console.log("[Settlr] Wallet SET! merchantWallet:", this.merchantWallet.toString(), "merchantWalletFromValidation:", this.merchantWalletFromValidation);
|
|
175
183
|
}
|
|
176
184
|
if (data.merchantName && !this.config.merchant.name) {
|
|
177
185
|
this.config.merchant.name = data.merchantName;
|
|
@@ -212,8 +220,10 @@ var Settlr = class {
|
|
|
212
220
|
*/
|
|
213
221
|
getCheckoutUrl(options) {
|
|
214
222
|
const { amount, memo, orderId, successUrl, cancelUrl } = options;
|
|
223
|
+
console.log("[Settlr] getCheckoutUrl - config.wallet:", this.config.merchant.walletAddress, "merchantWalletFromValidation:", this.merchantWalletFromValidation, "validated:", this.validated);
|
|
215
224
|
const walletAddress = this.config.merchant.walletAddress?.toString() || this.merchantWalletFromValidation;
|
|
216
225
|
if (!walletAddress) {
|
|
226
|
+
console.error("[Settlr] No wallet address available!");
|
|
217
227
|
throw new Error("Wallet address not available. Either provide walletAddress in config or call validateApiKey() first.");
|
|
218
228
|
}
|
|
219
229
|
const baseUrl = this.config.testMode ? SETTLR_CHECKOUT_URL.development : SETTLR_CHECKOUT_URL.production;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@settlr/sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "Settlr SDK - Accept Solana USDC payments with privacy. Email checkout, gasless transactions, FHE-encrypted receipts. Private on-chain, compliant off-chain.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|