@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.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,13 @@ 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
|
+
if (isFiatCurrency && intent.currency !== "USD") {
|
|
3639
|
+
throw new Error(
|
|
3640
|
+
`MeshPay adapter only supports USD as fiat currency, received: ${intent.currency}`
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3633
3643
|
const linkTokenRequest = {
|
|
3634
3644
|
userId: intent.customerId,
|
|
3635
3645
|
configurationId: this.config.configurationId,
|
|
@@ -3640,10 +3650,14 @@ var MeshPayAdapter = class {
|
|
|
3640
3650
|
return {
|
|
3641
3651
|
networkId,
|
|
3642
3652
|
symbol: dest.symbol,
|
|
3643
|
-
address: dest.address
|
|
3653
|
+
address: dest.address,
|
|
3654
|
+
// For crypto transfers, include amount in the destination
|
|
3655
|
+
...!isFiatCurrency && { amount: intent.amount }
|
|
3644
3656
|
};
|
|
3645
3657
|
}),
|
|
3646
|
-
amountInFiat
|
|
3658
|
+
// Only set amountInFiat for fiat currencies (USD, EUR, GBP)
|
|
3659
|
+
// For crypto currencies (BTC, ETH), omit this to let MeshPay handle as crypto amount
|
|
3660
|
+
...isFiatCurrency && { amountInFiat: intent.amount },
|
|
3647
3661
|
isInclusiveFeeEnabled: false,
|
|
3648
3662
|
generatePayLink: false
|
|
3649
3663
|
},
|
|
@@ -3689,11 +3703,9 @@ var MeshPayAdapter = class {
|
|
|
3689
3703
|
return new Promise((resolve, reject) => {
|
|
3690
3704
|
const meshLink = createLink({
|
|
3691
3705
|
clientId: session.metadata.clientId,
|
|
3692
|
-
onIntegrationConnected: (
|
|
3693
|
-
console.log("MeshPay integration connected:", payload);
|
|
3706
|
+
onIntegrationConnected: () => {
|
|
3694
3707
|
},
|
|
3695
3708
|
onTransferFinished: (payload) => {
|
|
3696
|
-
console.log("MeshPay transfer finished:", payload);
|
|
3697
3709
|
const isSuccess = payload.status === "success";
|
|
3698
3710
|
resolve({
|
|
3699
3711
|
id: session.id,
|
|
@@ -3714,7 +3726,6 @@ var MeshPayAdapter = class {
|
|
|
3714
3726
|
});
|
|
3715
3727
|
},
|
|
3716
3728
|
onExit: (error) => {
|
|
3717
|
-
console.log("MeshPay link exited:", error);
|
|
3718
3729
|
if (error) {
|
|
3719
3730
|
reject(new Error(`MeshPay error: ${error.message || error}`));
|
|
3720
3731
|
} else {
|