@w3payments/adapters 1.1.1 → 1.2.0
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 +17 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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,13 @@ 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
|
+
if (isFiatCurrency && intent.currency !== "USD") {
|
|
3675
|
+
throw new Error(
|
|
3676
|
+
`MeshPay adapter only supports USD as fiat currency, received: ${intent.currency}`
|
|
3677
|
+
);
|
|
3678
|
+
}
|
|
3669
3679
|
const linkTokenRequest = {
|
|
3670
3680
|
userId: intent.customerId,
|
|
3671
3681
|
configurationId: this.config.configurationId,
|
|
@@ -3676,10 +3686,14 @@ var MeshPayAdapter = class {
|
|
|
3676
3686
|
return {
|
|
3677
3687
|
networkId,
|
|
3678
3688
|
symbol: dest.symbol,
|
|
3679
|
-
address: dest.address
|
|
3689
|
+
address: dest.address,
|
|
3690
|
+
// For crypto transfers, include amount in the destination
|
|
3691
|
+
...!isFiatCurrency && { amount: intent.amount }
|
|
3680
3692
|
};
|
|
3681
3693
|
}),
|
|
3682
|
-
amountInFiat
|
|
3694
|
+
// Only set amountInFiat for fiat currencies (USD, EUR, GBP)
|
|
3695
|
+
// For crypto currencies (BTC, ETH), omit this to let MeshPay handle as crypto amount
|
|
3696
|
+
...isFiatCurrency && { amountInFiat: intent.amount },
|
|
3683
3697
|
isInclusiveFeeEnabled: false,
|
|
3684
3698
|
generatePayLink: false
|
|
3685
3699
|
},
|
|
@@ -3725,11 +3739,9 @@ var MeshPayAdapter = class {
|
|
|
3725
3739
|
return new Promise((resolve, reject) => {
|
|
3726
3740
|
const meshLink = createLink({
|
|
3727
3741
|
clientId: session.metadata.clientId,
|
|
3728
|
-
onIntegrationConnected: (
|
|
3729
|
-
console.log("MeshPay integration connected:", payload);
|
|
3742
|
+
onIntegrationConnected: () => {
|
|
3730
3743
|
},
|
|
3731
3744
|
onTransferFinished: (payload) => {
|
|
3732
|
-
console.log("MeshPay transfer finished:", payload);
|
|
3733
3745
|
const isSuccess = payload.status === "success";
|
|
3734
3746
|
resolve({
|
|
3735
3747
|
id: session.id,
|
|
@@ -3750,7 +3762,6 @@ var MeshPayAdapter = class {
|
|
|
3750
3762
|
});
|
|
3751
3763
|
},
|
|
3752
3764
|
onExit: (error) => {
|
|
3753
|
-
console.log("MeshPay link exited:", error);
|
|
3754
3765
|
if (error) {
|
|
3755
3766
|
reject(new Error(`MeshPay error: ${error.message || error}`));
|
|
3756
3767
|
} else {
|