@w3payments/adapters 1.1.0 → 1.1.2

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
@@ -34,6 +34,9 @@ __export(index_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(index_exports);
36
36
 
37
+ // src/meshpay/index.ts
38
+ var import_common = require("@w3payments/common");
39
+
37
40
  // src/meshpay/config/integrations.sandbox.json
38
41
  var integrations_sandbox_default = {
39
42
  content: {
@@ -3666,6 +3669,20 @@ var MeshPayAdapter = class {
3666
3669
  if (!this.config) {
3667
3670
  throw new Error("Adapter not initialized");
3668
3671
  }
3672
+ const currency = import_common.currencyService.getCurrency(intent.currency);
3673
+ const isFiatCurrency = currency?.type === "fiat";
3674
+ console.log("MeshPay createCheckoutSession:", {
3675
+ currency: intent.currency,
3676
+ amount: intent.amount,
3677
+ currencyType: currency?.type,
3678
+ isFiatCurrency,
3679
+ destinations: intent.destinations
3680
+ });
3681
+ if (isFiatCurrency && intent.currency !== "USD") {
3682
+ throw new Error(
3683
+ `MeshPay adapter only supports USD as fiat currency, received: ${intent.currency}`
3684
+ );
3685
+ }
3669
3686
  const linkTokenRequest = {
3670
3687
  userId: intent.customerId,
3671
3688
  configurationId: this.config.configurationId,
@@ -3676,15 +3693,20 @@ var MeshPayAdapter = class {
3676
3693
  return {
3677
3694
  networkId,
3678
3695
  symbol: dest.symbol,
3679
- address: dest.address
3696
+ address: dest.address,
3697
+ // For crypto transfers, include amount in the destination
3698
+ ...!isFiatCurrency && { amount: intent.amount }
3680
3699
  };
3681
3700
  }),
3682
- amountInFiat: intent.amount,
3701
+ // Only set amountInFiat for fiat currencies (USD, EUR, GBP)
3702
+ // For crypto currencies (BTC, ETH), omit this to let MeshPay handle as crypto amount
3703
+ ...isFiatCurrency && { amountInFiat: intent.amount },
3683
3704
  isInclusiveFeeEnabled: false,
3684
3705
  generatePayLink: false
3685
3706
  },
3686
3707
  disableApiKeyGeneration: false
3687
3708
  };
3709
+ console.log("MeshPay linkTokenRequest:", JSON.stringify(linkTokenRequest, null, 2));
3688
3710
  const response = await globalThis.fetch(
3689
3711
  `${this.config.baseUrl}/api/v1/linktoken`,
3690
3712
  {
@@ -3725,11 +3747,9 @@ var MeshPayAdapter = class {
3725
3747
  return new Promise((resolve, reject) => {
3726
3748
  const meshLink = createLink({
3727
3749
  clientId: session.metadata.clientId,
3728
- onIntegrationConnected: (payload) => {
3729
- console.log("MeshPay integration connected:", payload);
3750
+ onIntegrationConnected: () => {
3730
3751
  },
3731
3752
  onTransferFinished: (payload) => {
3732
- console.log("MeshPay transfer finished:", payload);
3733
3753
  const isSuccess = payload.status === "success";
3734
3754
  resolve({
3735
3755
  id: session.id,
@@ -3750,7 +3770,6 @@ var MeshPayAdapter = class {
3750
3770
  });
3751
3771
  },
3752
3772
  onExit: (error) => {
3753
- console.log("MeshPay link exited:", error);
3754
3773
  if (error) {
3755
3774
  reject(new Error(`MeshPay error: ${error.message || error}`));
3756
3775
  } else {