@settlr/sdk 0.6.3 → 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 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
- if (this.validated) return;
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;
@@ -616,6 +626,13 @@ function SettlrProvider({
616
626
  }, [config]);
617
627
  (0, import_react.useEffect)(() => {
618
628
  let cancelled = false;
629
+ if (config.merchant.walletAddress) {
630
+ console.log(
631
+ "[Settlr] Wallet address provided in config, skipping API validation"
632
+ );
633
+ setReady(true);
634
+ return;
635
+ }
619
636
  settlr.validateApiKey().then(() => {
620
637
  if (!cancelled) {
621
638
  setReady(true);
@@ -633,7 +650,7 @@ function SettlrProvider({
633
650
  return () => {
634
651
  cancelled = true;
635
652
  };
636
- }, [settlr, config.apiKey]);
653
+ }, [settlr, config.apiKey, config.merchant.walletAddress]);
637
654
  const value = (0, import_react.useMemo)(
638
655
  () => ({
639
656
  settlr,
@@ -739,11 +756,10 @@ function BuyButton({
739
756
  const handleClick = (0, import_react2.useCallback)(async () => {
740
757
  if (disabled || loading) return;
741
758
  if (!ready) {
742
- const notReadyError = new Error(
743
- sdkError?.message || "Settlr SDK not ready. Please check your API key configuration."
744
- );
759
+ const errorMsg = sdkError?.message || "Settlr SDK not ready. Please check your API key configuration.";
760
+ console.error("[Settlr BuyButton]", errorMsg);
761
+ const notReadyError = new Error(errorMsg);
745
762
  onError?.(notReadyError);
746
- return;
747
763
  }
748
764
  setLoading(true);
749
765
  setStatus("processing");
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
- if (this.validated) return;
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;
@@ -558,6 +568,13 @@ function SettlrProvider({
558
568
  }, [config]);
559
569
  useEffect(() => {
560
570
  let cancelled = false;
571
+ if (config.merchant.walletAddress) {
572
+ console.log(
573
+ "[Settlr] Wallet address provided in config, skipping API validation"
574
+ );
575
+ setReady(true);
576
+ return;
577
+ }
561
578
  settlr.validateApiKey().then(() => {
562
579
  if (!cancelled) {
563
580
  setReady(true);
@@ -575,7 +592,7 @@ function SettlrProvider({
575
592
  return () => {
576
593
  cancelled = true;
577
594
  };
578
- }, [settlr, config.apiKey]);
595
+ }, [settlr, config.apiKey, config.merchant.walletAddress]);
579
596
  const value = useMemo(
580
597
  () => ({
581
598
  settlr,
@@ -685,11 +702,10 @@ function BuyButton({
685
702
  const handleClick = useCallback(async () => {
686
703
  if (disabled || loading) return;
687
704
  if (!ready) {
688
- const notReadyError = new Error(
689
- sdkError?.message || "Settlr SDK not ready. Please check your API key configuration."
690
- );
705
+ const errorMsg = sdkError?.message || "Settlr SDK not ready. Please check your API key configuration.";
706
+ console.error("[Settlr BuyButton]", errorMsg);
707
+ const notReadyError = new Error(errorMsg);
691
708
  onError?.(notReadyError);
692
- return;
693
709
  }
694
710
  setLoading(true);
695
711
  setStatus("processing");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@settlr/sdk",
3
- "version": "0.6.3",
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",