@w3payments/adapters 1.1.1 → 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.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ // src/meshpay/index.ts
2
+ import { currencyService } from "@w3payments/common";
3
+
1
4
  // src/meshpay/config/integrations.sandbox.json
2
5
  var integrations_sandbox_default = {
3
6
  content: {
@@ -3630,6 +3633,20 @@ var MeshPayAdapter = class {
3630
3633
  if (!this.config) {
3631
3634
  throw new Error("Adapter not initialized");
3632
3635
  }
3636
+ const currency = currencyService.getCurrency(intent.currency);
3637
+ const isFiatCurrency = currency?.type === "fiat";
3638
+ console.log("MeshPay createCheckoutSession:", {
3639
+ currency: intent.currency,
3640
+ amount: intent.amount,
3641
+ currencyType: currency?.type,
3642
+ isFiatCurrency,
3643
+ destinations: intent.destinations
3644
+ });
3645
+ if (isFiatCurrency && intent.currency !== "USD") {
3646
+ throw new Error(
3647
+ `MeshPay adapter only supports USD as fiat currency, received: ${intent.currency}`
3648
+ );
3649
+ }
3633
3650
  const linkTokenRequest = {
3634
3651
  userId: intent.customerId,
3635
3652
  configurationId: this.config.configurationId,
@@ -3640,15 +3657,20 @@ var MeshPayAdapter = class {
3640
3657
  return {
3641
3658
  networkId,
3642
3659
  symbol: dest.symbol,
3643
- address: dest.address
3660
+ address: dest.address,
3661
+ // For crypto transfers, include amount in the destination
3662
+ ...!isFiatCurrency && { amount: intent.amount }
3644
3663
  };
3645
3664
  }),
3646
- amountInFiat: intent.amount,
3665
+ // Only set amountInFiat for fiat currencies (USD, EUR, GBP)
3666
+ // For crypto currencies (BTC, ETH), omit this to let MeshPay handle as crypto amount
3667
+ ...isFiatCurrency && { amountInFiat: intent.amount },
3647
3668
  isInclusiveFeeEnabled: false,
3648
3669
  generatePayLink: false
3649
3670
  },
3650
3671
  disableApiKeyGeneration: false
3651
3672
  };
3673
+ console.log("MeshPay linkTokenRequest:", JSON.stringify(linkTokenRequest, null, 2));
3652
3674
  const response = await globalThis.fetch(
3653
3675
  `${this.config.baseUrl}/api/v1/linktoken`,
3654
3676
  {
@@ -3689,11 +3711,9 @@ var MeshPayAdapter = class {
3689
3711
  return new Promise((resolve, reject) => {
3690
3712
  const meshLink = createLink({
3691
3713
  clientId: session.metadata.clientId,
3692
- onIntegrationConnected: (payload) => {
3693
- console.log("MeshPay integration connected:", payload);
3714
+ onIntegrationConnected: () => {
3694
3715
  },
3695
3716
  onTransferFinished: (payload) => {
3696
- console.log("MeshPay transfer finished:", payload);
3697
3717
  const isSuccess = payload.status === "success";
3698
3718
  resolve({
3699
3719
  id: session.id,
@@ -3714,7 +3734,6 @@ var MeshPayAdapter = class {
3714
3734
  });
3715
3735
  },
3716
3736
  onExit: (error) => {
3717
- console.log("MeshPay link exited:", error);
3718
3737
  if (error) {
3719
3738
  reject(new Error(`MeshPay error: ${error.message || error}`));
3720
3739
  } else {