coinley-pay 0.0.2 → 0.0.4
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.esm.js +1025 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +11 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -45505,7 +45505,7 @@ const DepositAddressDisplay = ({
|
|
|
45505
45505
|
}
|
|
45506
45506
|
);
|
|
45507
45507
|
};
|
|
45508
|
-
const queryClient = new QueryClient();
|
|
45508
|
+
const queryClient$1 = new QueryClient();
|
|
45509
45509
|
const EnhancedSimpleCoinleyPaymentInternal = ({
|
|
45510
45510
|
publicKey: publicKey2,
|
|
45511
45511
|
// New: Single public key for authentication (recommended)
|
|
@@ -46483,7 +46483,7 @@ const EnhancedSimpleCoinleyPaymentInternal = ({
|
|
|
46483
46483
|
] });
|
|
46484
46484
|
};
|
|
46485
46485
|
const EnhancedSimpleCoinleyPayment = (props) => {
|
|
46486
|
-
return /* @__PURE__ */ jsx(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(EnhancedSimpleCoinleyPaymentInternal, { ...props }) }) });
|
|
46486
|
+
return /* @__PURE__ */ jsx(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient$1, children: /* @__PURE__ */ jsx(EnhancedSimpleCoinleyPaymentInternal, { ...props }) }) });
|
|
46487
46487
|
};
|
|
46488
46488
|
const CoinleyContext = createContext(null);
|
|
46489
46489
|
const CoinleyProvider = ({
|
|
@@ -46886,6 +46886,1028 @@ class PaymentAPI {
|
|
|
46886
46886
|
}
|
|
46887
46887
|
}
|
|
46888
46888
|
}
|
|
46889
|
+
const queryClient = new QueryClient();
|
|
46890
|
+
const PAYMENT_TABS = {
|
|
46891
|
+
WALLET: "wallet",
|
|
46892
|
+
QR: "qr",
|
|
46893
|
+
TRANSFER: "transfer"
|
|
46894
|
+
};
|
|
46895
|
+
const RedesignedCoinleyPaymentInternal = ({
|
|
46896
|
+
publicKey: publicKey2,
|
|
46897
|
+
apiKey,
|
|
46898
|
+
apiSecret,
|
|
46899
|
+
apiUrl,
|
|
46900
|
+
config,
|
|
46901
|
+
onSuccess,
|
|
46902
|
+
onError,
|
|
46903
|
+
onClose,
|
|
46904
|
+
isOpen,
|
|
46905
|
+
theme = "light"
|
|
46906
|
+
}) => {
|
|
46907
|
+
const paymentFlow = usePaymentFlow(apiUrl, publicKey2 || apiKey, publicKey2 ? null : apiSecret);
|
|
46908
|
+
const walletConnection = useWalletConnection();
|
|
46909
|
+
const solanaWallet = useSolanaWallet();
|
|
46910
|
+
const chainType = useMemo(() => {
|
|
46911
|
+
if (!paymentFlow.selectedNetwork) return CHAIN_TYPES.EVM;
|
|
46912
|
+
return getChainType(paymentFlow.selectedNetwork.type || paymentFlow.selectedNetwork.shortName || paymentFlow.selectedNetwork.id);
|
|
46913
|
+
}, [paymentFlow.selectedNetwork]);
|
|
46914
|
+
const isSolana = chainType === CHAIN_TYPES.SOLANA;
|
|
46915
|
+
const detectSolanaDevnet = (network) => {
|
|
46916
|
+
if (!network) return false;
|
|
46917
|
+
const isTestnet = network.isTestnet === true || network.isTestnet === "true";
|
|
46918
|
+
const nameHasDevnet = (network.name || "").toLowerCase().includes("devnet");
|
|
46919
|
+
const shortNameHasDevnet = (network.shortName || "").toLowerCase().includes("devnet");
|
|
46920
|
+
const typeHasDevnet = (network.type || "").toLowerCase().includes("devnet");
|
|
46921
|
+
const idHasDevnet = (network.id || "").toLowerCase().includes("devnet");
|
|
46922
|
+
const isDevnet = isTestnet || nameHasDevnet || shortNameHasDevnet || typeHasDevnet || idHasDevnet;
|
|
46923
|
+
return isDevnet;
|
|
46924
|
+
};
|
|
46925
|
+
const isSolanaDevnet = useMemo(() => {
|
|
46926
|
+
if (!isSolana || !paymentFlow.selectedNetwork) return false;
|
|
46927
|
+
return detectSolanaDevnet(paymentFlow.selectedNetwork);
|
|
46928
|
+
}, [isSolana, paymentFlow.selectedNetwork]);
|
|
46929
|
+
const solanaRpcEndpoints = useMemo(() => {
|
|
46930
|
+
if (!isSolana || !paymentFlow.selectedNetwork) return [];
|
|
46931
|
+
return getSolanaRpcEndpoints();
|
|
46932
|
+
}, [isSolana, paymentFlow.selectedNetwork, isSolanaDevnet]);
|
|
46933
|
+
const solanaTransaction = useSolanaTransaction(solanaRpcEndpoints, solanaWallet.connectedWallet);
|
|
46934
|
+
const [activeTab, setActiveTab] = useState(PAYMENT_TABS.WALLET);
|
|
46935
|
+
const [networkSearch, setNetworkSearch] = useState("");
|
|
46936
|
+
const [showWalletConfirm, setShowWalletConfirm] = useState(false);
|
|
46937
|
+
const [qrCodeDataUrl, setQrCodeDataUrl] = useState("");
|
|
46938
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
46939
|
+
const [mobilePaymentStarted, setMobilePaymentStarted] = useState(() => {
|
|
46940
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
46941
|
+
return sessionStorage.getItem("coinley_mobile_payment_started") === "true";
|
|
46942
|
+
}
|
|
46943
|
+
return false;
|
|
46944
|
+
});
|
|
46945
|
+
const [verifyingPayment, setVerifyingPayment] = useState(false);
|
|
46946
|
+
useEffect(() => {
|
|
46947
|
+
setIsMobile(detectMobile());
|
|
46948
|
+
}, []);
|
|
46949
|
+
const {
|
|
46950
|
+
currentStep,
|
|
46951
|
+
networks,
|
|
46952
|
+
tokens,
|
|
46953
|
+
selectedNetwork,
|
|
46954
|
+
selectedToken,
|
|
46955
|
+
paymentData,
|
|
46956
|
+
loading,
|
|
46957
|
+
error,
|
|
46958
|
+
paymentType,
|
|
46959
|
+
loadData,
|
|
46960
|
+
createPayment,
|
|
46961
|
+
createDepositPayment,
|
|
46962
|
+
failPayment,
|
|
46963
|
+
resetState,
|
|
46964
|
+
setSelectedNetwork,
|
|
46965
|
+
setSelectedToken,
|
|
46966
|
+
setCurrentStep,
|
|
46967
|
+
setError
|
|
46968
|
+
} = paymentFlow;
|
|
46969
|
+
const {
|
|
46970
|
+
connectedWallet,
|
|
46971
|
+
address,
|
|
46972
|
+
connectWallet,
|
|
46973
|
+
handleWalletSelection,
|
|
46974
|
+
resetState: resetWalletState
|
|
46975
|
+
} = walletConnection;
|
|
46976
|
+
const transactionHandling = useTransactionHandling(
|
|
46977
|
+
paymentData,
|
|
46978
|
+
selectedToken,
|
|
46979
|
+
selectedNetwork,
|
|
46980
|
+
address,
|
|
46981
|
+
paymentFlow.api,
|
|
46982
|
+
walletConnection
|
|
46983
|
+
);
|
|
46984
|
+
const {
|
|
46985
|
+
executePaymentTransaction,
|
|
46986
|
+
processFinalPayment,
|
|
46987
|
+
transactionStep,
|
|
46988
|
+
transactionError,
|
|
46989
|
+
currentTransactionHash
|
|
46990
|
+
} = transactionHandling;
|
|
46991
|
+
useEffect(() => {
|
|
46992
|
+
if (paymentData && selectedToken && selectedNetwork && activeTab === PAYMENT_TABS.QR) {
|
|
46993
|
+
generateQRCode();
|
|
46994
|
+
}
|
|
46995
|
+
}, [paymentData, selectedToken, selectedNetwork, activeTab]);
|
|
46996
|
+
const generateQRCode = async () => {
|
|
46997
|
+
if (!paymentData) return;
|
|
46998
|
+
try {
|
|
46999
|
+
const paymentUrl = `https://payment.coinley.io/?paymentId=${paymentData.id}&amount=${paymentData.totalAmount || paymentData.amount}&token=${selectedToken == null ? void 0 : selectedToken.symbol}&network=${selectedNetwork == null ? void 0 : selectedNetwork.shortName}`;
|
|
47000
|
+
const dataUrl = await QRCode.toDataURL(paymentUrl, {
|
|
47001
|
+
width: 200,
|
|
47002
|
+
margin: 2,
|
|
47003
|
+
color: {
|
|
47004
|
+
dark: "#000000",
|
|
47005
|
+
light: "#ffffff"
|
|
47006
|
+
}
|
|
47007
|
+
});
|
|
47008
|
+
setQrCodeDataUrl(dataUrl);
|
|
47009
|
+
} catch (err) {
|
|
47010
|
+
console.error("Error generating QR code:", err);
|
|
47011
|
+
}
|
|
47012
|
+
};
|
|
47013
|
+
useEffect(() => {
|
|
47014
|
+
if (currentStep === PAYMENT_STEPS.SUCCESS && typeof window !== "undefined" && window.sessionStorage) {
|
|
47015
|
+
sessionStorage.removeItem("coinley_mobile_payment_started");
|
|
47016
|
+
}
|
|
47017
|
+
}, [currentStep]);
|
|
47018
|
+
useEffect(() => {
|
|
47019
|
+
if (isOpen) {
|
|
47020
|
+
loadData();
|
|
47021
|
+
resetState();
|
|
47022
|
+
sdkAnalytics.trackModalOpened(config == null ? void 0 : config.merchantName, config == null ? void 0 : config.amount);
|
|
47023
|
+
const scrollY = window.scrollY;
|
|
47024
|
+
document.body.style.position = "fixed";
|
|
47025
|
+
document.body.style.top = `-${scrollY}px`;
|
|
47026
|
+
document.body.style.width = "100%";
|
|
47027
|
+
document.body.style.overflow = "hidden";
|
|
47028
|
+
} else {
|
|
47029
|
+
const scrollY = document.body.style.top;
|
|
47030
|
+
document.body.style.position = "";
|
|
47031
|
+
document.body.style.top = "";
|
|
47032
|
+
document.body.style.width = "";
|
|
47033
|
+
document.body.style.overflow = "";
|
|
47034
|
+
window.scrollTo(0, parseInt(scrollY || "0") * -1);
|
|
47035
|
+
}
|
|
47036
|
+
return () => {
|
|
47037
|
+
if (isOpen) {
|
|
47038
|
+
const scrollY = document.body.style.top;
|
|
47039
|
+
document.body.style.position = "";
|
|
47040
|
+
document.body.style.top = "";
|
|
47041
|
+
document.body.style.width = "";
|
|
47042
|
+
document.body.style.overflow = "";
|
|
47043
|
+
window.scrollTo(0, parseInt(scrollY || "0") * -1);
|
|
47044
|
+
}
|
|
47045
|
+
};
|
|
47046
|
+
}, [isOpen]);
|
|
47047
|
+
useEffect(() => {
|
|
47048
|
+
if (transactionStep === "processing" || transactionStep === "approve" || transactionStep === "splitPayment") {
|
|
47049
|
+
const timeout = setTimeout(() => {
|
|
47050
|
+
setError("Transaction timed out. Please try again.");
|
|
47051
|
+
setCurrentStep(PAYMENT_STEPS.CONFIRM);
|
|
47052
|
+
transactionHandling.resetTransaction();
|
|
47053
|
+
}, 12e4);
|
|
47054
|
+
return () => clearTimeout(timeout);
|
|
47055
|
+
}
|
|
47056
|
+
}, [transactionStep]);
|
|
47057
|
+
useEffect(() => {
|
|
47058
|
+
if (currentStep !== PAYMENT_STEPS.PROCESSING || paymentType !== PAYMENT_TYPES.DEPOSIT || !(paymentData == null ? void 0 : paymentData.id)) {
|
|
47059
|
+
return;
|
|
47060
|
+
}
|
|
47061
|
+
const pollInterval = setInterval(async () => {
|
|
47062
|
+
try {
|
|
47063
|
+
const statusResult = await paymentFlow.api.getDepositStatus(paymentData.id);
|
|
47064
|
+
if (statusResult.success && statusResult.payment) {
|
|
47065
|
+
const status = statusResult.payment.status;
|
|
47066
|
+
const txHash = statusResult.payment.depositTxHash || statusResult.payment.sweepTxHash || statusResult.payment.transactionHash;
|
|
47067
|
+
if ((status === "completed" || status === "swept") && txHash) {
|
|
47068
|
+
clearInterval(pollInterval);
|
|
47069
|
+
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
47070
|
+
if (onSuccess) {
|
|
47071
|
+
onSuccess({
|
|
47072
|
+
paymentId: paymentData.id,
|
|
47073
|
+
transactionHash: txHash,
|
|
47074
|
+
depositAddress: statusResult.payment.depositAddress,
|
|
47075
|
+
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
47076
|
+
currency: selectedToken == null ? void 0 : selectedToken.symbol,
|
|
47077
|
+
paymentDetails: statusResult.payment
|
|
47078
|
+
});
|
|
47079
|
+
}
|
|
47080
|
+
} else if (status === "failed" || status === "sweep_failed") {
|
|
47081
|
+
clearInterval(pollInterval);
|
|
47082
|
+
setError("Payment failed. Please try again.");
|
|
47083
|
+
setCurrentStep(PAYMENT_STEPS.CONFIRM);
|
|
47084
|
+
}
|
|
47085
|
+
}
|
|
47086
|
+
} catch (error2) {
|
|
47087
|
+
console.warn("[DepositPolling] Error checking status:", error2.message);
|
|
47088
|
+
}
|
|
47089
|
+
}, 5e3);
|
|
47090
|
+
return () => clearInterval(pollInterval);
|
|
47091
|
+
}, [currentStep, paymentType, paymentData == null ? void 0 : paymentData.id, selectedNetwork, selectedToken, onSuccess]);
|
|
47092
|
+
const resetAllTransactionState = () => {
|
|
47093
|
+
var _a2;
|
|
47094
|
+
transactionHandling.resetTransaction();
|
|
47095
|
+
(_a2 = solanaTransaction.resetTransaction) == null ? void 0 : _a2.call(solanaTransaction);
|
|
47096
|
+
resetWalletState == null ? void 0 : resetWalletState();
|
|
47097
|
+
setError("");
|
|
47098
|
+
setVerifyingPayment(false);
|
|
47099
|
+
setMobilePaymentStarted(false);
|
|
47100
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
47101
|
+
sessionStorage.removeItem("coinley_mobile_payment_started");
|
|
47102
|
+
}
|
|
47103
|
+
if (typeof window !== "undefined") {
|
|
47104
|
+
window.coinleyPendingSplitPayment = null;
|
|
47105
|
+
}
|
|
47106
|
+
};
|
|
47107
|
+
const handleCancel = async () => {
|
|
47108
|
+
sdkAnalytics.trackModalClosed("user_cancelled");
|
|
47109
|
+
resetAllTransactionState();
|
|
47110
|
+
await failPayment();
|
|
47111
|
+
onClose();
|
|
47112
|
+
};
|
|
47113
|
+
const handleConnect = async (connector) => {
|
|
47114
|
+
await connectWallet(connector, selectedNetwork);
|
|
47115
|
+
};
|
|
47116
|
+
const filteredNetworks = useMemo(() => {
|
|
47117
|
+
if (!networkSearch) return networks;
|
|
47118
|
+
const search = networkSearch.toLowerCase();
|
|
47119
|
+
return networks.filter(
|
|
47120
|
+
(n2) => {
|
|
47121
|
+
var _a2;
|
|
47122
|
+
return n2.name.toLowerCase().includes(search) || ((_a2 = n2.shortName) == null ? void 0 : _a2.toLowerCase().includes(search));
|
|
47123
|
+
}
|
|
47124
|
+
);
|
|
47125
|
+
}, [networks, networkSearch]);
|
|
47126
|
+
const availableTokens = useMemo(() => {
|
|
47127
|
+
if (!selectedNetwork) return [];
|
|
47128
|
+
return tokens.filter(
|
|
47129
|
+
(token) => {
|
|
47130
|
+
var _a2;
|
|
47131
|
+
return ((_a2 = token.Network) == null ? void 0 : _a2.shortName) === (selectedNetwork == null ? void 0 : selectedNetwork.shortName) || token.networkId === (selectedNetwork == null ? void 0 : selectedNetwork.id);
|
|
47132
|
+
}
|
|
47133
|
+
);
|
|
47134
|
+
}, [tokens, selectedNetwork]);
|
|
47135
|
+
const handleNetworkSelect = (network) => {
|
|
47136
|
+
resetAllTransactionState();
|
|
47137
|
+
setSelectedNetwork(network);
|
|
47138
|
+
setSelectedToken(null);
|
|
47139
|
+
sdkAnalytics.trackNetworkSelected(network == null ? void 0 : network.name, config == null ? void 0 : config.merchantName);
|
|
47140
|
+
};
|
|
47141
|
+
const handleTokenSelect = (token) => {
|
|
47142
|
+
setSelectedToken(token);
|
|
47143
|
+
sdkAnalytics.trackTokenSelected(token == null ? void 0 : token.symbol, selectedNetwork == null ? void 0 : selectedNetwork.name, config == null ? void 0 : config.merchantName);
|
|
47144
|
+
};
|
|
47145
|
+
const handleConnectWallet = async () => {
|
|
47146
|
+
if (!selectedNetwork || !selectedToken) return;
|
|
47147
|
+
if (!paymentData) {
|
|
47148
|
+
await createPayment(config);
|
|
47149
|
+
}
|
|
47150
|
+
setShowWalletConfirm(true);
|
|
47151
|
+
};
|
|
47152
|
+
const handleBackFromWalletConfirm = () => {
|
|
47153
|
+
setShowWalletConfirm(false);
|
|
47154
|
+
resetAllTransactionState();
|
|
47155
|
+
};
|
|
47156
|
+
const executePayment = async () => {
|
|
47157
|
+
if (isSolana) {
|
|
47158
|
+
if (!solanaWallet.publicKey || !solanaWallet.connectedWallet) {
|
|
47159
|
+
setError("Please connect your Solana wallet first");
|
|
47160
|
+
return;
|
|
47161
|
+
}
|
|
47162
|
+
try {
|
|
47163
|
+
setCurrentStep(PAYMENT_STEPS.PROCESSING);
|
|
47164
|
+
const result2 = await solanaTransaction.executeSplitPayment(
|
|
47165
|
+
paymentData,
|
|
47166
|
+
selectedToken,
|
|
47167
|
+
selectedNetwork
|
|
47168
|
+
);
|
|
47169
|
+
if (result2.success) {
|
|
47170
|
+
const finalResult = await paymentFlow.api.processPayment(
|
|
47171
|
+
paymentData.id,
|
|
47172
|
+
result2.signature,
|
|
47173
|
+
solanaWallet.publicKey
|
|
47174
|
+
);
|
|
47175
|
+
if (finalResult.success) {
|
|
47176
|
+
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
47177
|
+
if (onSuccess) {
|
|
47178
|
+
onSuccess({
|
|
47179
|
+
paymentId: paymentData.id,
|
|
47180
|
+
transactionHash: result2.signature,
|
|
47181
|
+
senderAddress: solanaWallet.publicKey,
|
|
47182
|
+
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
47183
|
+
currency: selectedToken == null ? void 0 : selectedToken.symbol
|
|
47184
|
+
});
|
|
47185
|
+
}
|
|
47186
|
+
} else {
|
|
47187
|
+
throw new Error(finalResult.message || "Failed to process payment");
|
|
47188
|
+
}
|
|
47189
|
+
} else {
|
|
47190
|
+
throw new Error(result2.error || "Transaction failed");
|
|
47191
|
+
}
|
|
47192
|
+
} catch (err) {
|
|
47193
|
+
setError(err.message || "Transaction failed");
|
|
47194
|
+
setCurrentStep(PAYMENT_STEPS.CONFIRM);
|
|
47195
|
+
}
|
|
47196
|
+
} else {
|
|
47197
|
+
if (!connectedWallet || !address) {
|
|
47198
|
+
setError("Please connect your wallet first");
|
|
47199
|
+
return;
|
|
47200
|
+
}
|
|
47201
|
+
try {
|
|
47202
|
+
setCurrentStep(PAYMENT_STEPS.PROCESSING);
|
|
47203
|
+
const result2 = await executePaymentTransaction();
|
|
47204
|
+
if ((result2 == null ? void 0 : result2.success) && (result2 == null ? void 0 : result2.transactionHash)) {
|
|
47205
|
+
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
47206
|
+
if (onSuccess) {
|
|
47207
|
+
onSuccess({
|
|
47208
|
+
paymentId: paymentData.id,
|
|
47209
|
+
transactionHash: result2.transactionHash,
|
|
47210
|
+
senderAddress: address,
|
|
47211
|
+
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
47212
|
+
currency: selectedToken == null ? void 0 : selectedToken.symbol
|
|
47213
|
+
});
|
|
47214
|
+
}
|
|
47215
|
+
} else if (result2 == null ? void 0 : result2.error) {
|
|
47216
|
+
throw new Error(result2.error);
|
|
47217
|
+
}
|
|
47218
|
+
} catch (err) {
|
|
47219
|
+
setError(err.message || "Transaction failed");
|
|
47220
|
+
setCurrentStep(PAYMENT_STEPS.CONFIRM);
|
|
47221
|
+
}
|
|
47222
|
+
}
|
|
47223
|
+
};
|
|
47224
|
+
const handlePaymentConfirmation = async () => {
|
|
47225
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
47226
|
+
if (!(paymentData == null ? void 0 : paymentData.id)) {
|
|
47227
|
+
setError("Payment ID not found. Please refresh and try again.");
|
|
47228
|
+
return;
|
|
47229
|
+
}
|
|
47230
|
+
try {
|
|
47231
|
+
setVerifyingPayment(true);
|
|
47232
|
+
setCurrentStep(PAYMENT_STEPS.PROCESSING);
|
|
47233
|
+
setError("");
|
|
47234
|
+
const statusResult = await paymentFlow.api.checkPaymentStatus(paymentData.id);
|
|
47235
|
+
const isPaymentSuccess = ((_a2 = statusResult.payment) == null ? void 0 : _a2.status) === "completed" || ((_b = statusResult.payment) == null ? void 0 : _b.status) === "swept";
|
|
47236
|
+
const txHash = ((_c = statusResult.payment) == null ? void 0 : _c.transactionHash) || ((_d = statusResult.payment) == null ? void 0 : _d.sweepTxHash) || ((_e = statusResult.payment) == null ? void 0 : _e.depositTxHash);
|
|
47237
|
+
if (isPaymentSuccess && txHash) {
|
|
47238
|
+
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
47239
|
+
if (onSuccess) {
|
|
47240
|
+
onSuccess({
|
|
47241
|
+
paymentId: paymentData.id,
|
|
47242
|
+
transactionHash: txHash,
|
|
47243
|
+
senderAddress: statusResult.payment.senderWalletAddress || statusResult.payment.fromAddress,
|
|
47244
|
+
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
47245
|
+
currency: selectedToken == null ? void 0 : selectedToken.symbol,
|
|
47246
|
+
paymentDetails: statusResult.payment
|
|
47247
|
+
});
|
|
47248
|
+
}
|
|
47249
|
+
} else if (((_f = statusResult.payment) == null ? void 0 : _f.status) === "pending") {
|
|
47250
|
+
const verificationResult = await paymentFlow.api.verifyQRPayment(paymentData.id);
|
|
47251
|
+
const verifyTxHash = ((_g = verificationResult.onChainData) == null ? void 0 : _g.transactionHash) || ((_h = verificationResult.payment) == null ? void 0 : _h.transactionHash);
|
|
47252
|
+
if (verificationResult.success && verificationResult.verified && verifyTxHash) {
|
|
47253
|
+
setCurrentStep(PAYMENT_STEPS.SUCCESS);
|
|
47254
|
+
if (onSuccess) {
|
|
47255
|
+
onSuccess({
|
|
47256
|
+
paymentId: paymentData.id,
|
|
47257
|
+
transactionHash: verifyTxHash,
|
|
47258
|
+
senderAddress: ((_i = verificationResult.onChainData) == null ? void 0 : _i.from) || ((_j = verificationResult.payment) == null ? void 0 : _j.senderWalletAddress),
|
|
47259
|
+
network: selectedNetwork == null ? void 0 : selectedNetwork.shortName,
|
|
47260
|
+
currency: selectedToken == null ? void 0 : selectedToken.symbol,
|
|
47261
|
+
paymentDetails: verificationResult.payment
|
|
47262
|
+
});
|
|
47263
|
+
}
|
|
47264
|
+
} else {
|
|
47265
|
+
const message = verificationResult.message || "Payment not yet confirmed on blockchain";
|
|
47266
|
+
setError(`${message}. Please complete the payment and try again.`);
|
|
47267
|
+
setCurrentStep(PAYMENT_STEPS.CONFIRM);
|
|
47268
|
+
}
|
|
47269
|
+
} else {
|
|
47270
|
+
setError("Payment not found or failed. Please try again.");
|
|
47271
|
+
setCurrentStep(PAYMENT_STEPS.CONFIRM);
|
|
47272
|
+
}
|
|
47273
|
+
} catch (error2) {
|
|
47274
|
+
setError(`Verification failed: ${error2.message}. Please try again.`);
|
|
47275
|
+
setCurrentStep(PAYMENT_STEPS.CONFIRM);
|
|
47276
|
+
} finally {
|
|
47277
|
+
setVerifyingPayment(false);
|
|
47278
|
+
}
|
|
47279
|
+
};
|
|
47280
|
+
const copyToClipboard = async (text) => {
|
|
47281
|
+
try {
|
|
47282
|
+
await navigator.clipboard.writeText(text);
|
|
47283
|
+
} catch (err) {
|
|
47284
|
+
console.error("Failed to copy:", err);
|
|
47285
|
+
}
|
|
47286
|
+
};
|
|
47287
|
+
const truncateAddress = (addr) => {
|
|
47288
|
+
if (!addr) return "";
|
|
47289
|
+
return `${addr.slice(0, 12)}......${addr.slice(-12)}`;
|
|
47290
|
+
};
|
|
47291
|
+
if (!isOpen) return null;
|
|
47292
|
+
if (currentStep === PAYMENT_STEPS.PROCESSING) {
|
|
47293
|
+
return /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50", children: [
|
|
47294
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50", onClick: handleCancel }),
|
|
47295
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 flex items-center justify-center p-4", style: { zIndex: 51 }, children: /* @__PURE__ */ jsx("div", { className: "bg-white rounded-2xl p-8 max-w-md w-full", children: /* @__PURE__ */ jsx(
|
|
47296
|
+
PaymentStatus,
|
|
47297
|
+
{
|
|
47298
|
+
status: "processing",
|
|
47299
|
+
message: activeTab === PAYMENT_TABS.TRANSFER ? "Transfer received! Confirming on blockchain..." : isSolana ? "Processing your Solana payment..." : "Processing your payment...",
|
|
47300
|
+
theme,
|
|
47301
|
+
transactionHash: isSolana ? solanaTransaction.txSignature : currentTransactionHash,
|
|
47302
|
+
selectedNetwork
|
|
47303
|
+
}
|
|
47304
|
+
) }) })
|
|
47305
|
+
] });
|
|
47306
|
+
}
|
|
47307
|
+
if (currentStep === PAYMENT_STEPS.SUCCESS) {
|
|
47308
|
+
return /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50", children: [
|
|
47309
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50" }),
|
|
47310
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 flex items-center justify-center p-4", style: { zIndex: 51 }, children: /* @__PURE__ */ jsx("div", { className: "bg-white rounded-2xl p-8 max-w-md w-full", children: /* @__PURE__ */ jsx(
|
|
47311
|
+
PaymentStatus,
|
|
47312
|
+
{
|
|
47313
|
+
status: "success",
|
|
47314
|
+
message: "Payment completed successfully!",
|
|
47315
|
+
theme,
|
|
47316
|
+
payment: paymentData,
|
|
47317
|
+
transactionHash: isSolana ? solanaTransaction.txSignature || (paymentData == null ? void 0 : paymentData.transactionHash) : currentTransactionHash || (paymentData == null ? void 0 : paymentData.transactionHash),
|
|
47318
|
+
selectedPaymentMethod: selectedToken,
|
|
47319
|
+
selectedNetwork,
|
|
47320
|
+
merchantName: (config == null ? void 0 : config.merchantName) || "Merchant",
|
|
47321
|
+
onClose
|
|
47322
|
+
}
|
|
47323
|
+
) }) })
|
|
47324
|
+
] });
|
|
47325
|
+
}
|
|
47326
|
+
return /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50", style: { fontFamily: FONT_FAMILY }, children: [
|
|
47327
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50", onClick: handleCancel }),
|
|
47328
|
+
/* @__PURE__ */ jsx("div", { className: "fixed inset-0 flex items-center justify-center p-4", style: { zIndex: 51 }, children: /* @__PURE__ */ jsxs("div", { className: "bg-gray-50 rounded-2xl shadow-2xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex", children: [
|
|
47329
|
+
/* @__PURE__ */ jsxs("div", { className: "w-48 bg-gray-50 p-6 flex flex-col border-r border-gray-200", children: [
|
|
47330
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-500 mb-4", children: "Pay With :" }),
|
|
47331
|
+
/* @__PURE__ */ jsxs(
|
|
47332
|
+
"button",
|
|
47333
|
+
{
|
|
47334
|
+
onClick: () => setActiveTab(PAYMENT_TABS.WALLET),
|
|
47335
|
+
className: `flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all mb-2 ${activeTab === PAYMENT_TABS.WALLET ? "bg-white text-[#7042D2] border-l-4 border-[#7042D2] shadow-sm" : "text-gray-400 hover:bg-gray-100"}`,
|
|
47336
|
+
children: [
|
|
47337
|
+
/* @__PURE__ */ jsx("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" }) }),
|
|
47338
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Wallet extension" })
|
|
47339
|
+
]
|
|
47340
|
+
}
|
|
47341
|
+
),
|
|
47342
|
+
/* @__PURE__ */ jsxs(
|
|
47343
|
+
"button",
|
|
47344
|
+
{
|
|
47345
|
+
onClick: () => setActiveTab(PAYMENT_TABS.QR),
|
|
47346
|
+
className: `flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all mb-2 ${activeTab === PAYMENT_TABS.QR ? "bg-white text-[#7042D2] border-l-4 border-[#7042D2] shadow-sm" : "text-gray-400 hover:bg-gray-100"}`,
|
|
47347
|
+
children: [
|
|
47348
|
+
/* @__PURE__ */ jsx("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 20h4M4 12h4m12 0h.01M5 8h2a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1zm12 0h2a1 1 0 001-1V5a1 1 0 00-1-1h-2a1 1 0 00-1 1v2a1 1 0 001 1zM5 20h2a1 1 0 001-1v-2a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1z" }) }),
|
|
47349
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Scan QR to pay" })
|
|
47350
|
+
]
|
|
47351
|
+
}
|
|
47352
|
+
),
|
|
47353
|
+
/* @__PURE__ */ jsxs(
|
|
47354
|
+
"button",
|
|
47355
|
+
{
|
|
47356
|
+
onClick: () => setActiveTab(PAYMENT_TABS.TRANSFER),
|
|
47357
|
+
className: `flex items-center gap-3 px-4 py-3 rounded-xl text-left transition-all ${activeTab === PAYMENT_TABS.TRANSFER ? "bg-white text-[#7042D2] border-l-4 border-[#7042D2] shadow-sm" : "text-gray-400 hover:bg-gray-100"}`,
|
|
47358
|
+
children: [
|
|
47359
|
+
/* @__PURE__ */ jsx("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" }) }),
|
|
47360
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Transfer to address" })
|
|
47361
|
+
]
|
|
47362
|
+
}
|
|
47363
|
+
)
|
|
47364
|
+
] }),
|
|
47365
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 bg-white rounded-r-2xl p-6 overflow-y-auto", children: [
|
|
47366
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center mb-6", children: [
|
|
47367
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
47368
|
+
/* @__PURE__ */ jsx("img", { src: logo, alt: "Coinley", className: "w-6 h-6" }),
|
|
47369
|
+
/* @__PURE__ */ jsx("span", { className: "text-lg font-semibold text-gray-800", children: "coinley" })
|
|
47370
|
+
] }),
|
|
47371
|
+
/* @__PURE__ */ jsx(
|
|
47372
|
+
"button",
|
|
47373
|
+
{
|
|
47374
|
+
onClick: handleCancel,
|
|
47375
|
+
className: "w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center hover:bg-gray-200 transition-colors",
|
|
47376
|
+
children: /* @__PURE__ */ jsx("svg", { className: "w-4 h-4 text-gray-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
47377
|
+
}
|
|
47378
|
+
)
|
|
47379
|
+
] }),
|
|
47380
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-gray-50 rounded-xl p-4 mb-6", children: [
|
|
47381
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500 mb-2", children: "Payment summary" }),
|
|
47382
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-3", children: [
|
|
47383
|
+
/* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" }) }),
|
|
47384
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
47385
|
+
"Payment to: ",
|
|
47386
|
+
(config == null ? void 0 : config.merchantName) || "Merchant"
|
|
47387
|
+
] })
|
|
47388
|
+
] }),
|
|
47389
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between", children: [
|
|
47390
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
47391
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-400", children: "Base amount:" }),
|
|
47392
|
+
/* @__PURE__ */ jsxs("p", { className: "text-3xl font-bold text-gray-900", children: [
|
|
47393
|
+
"$",
|
|
47394
|
+
formatAmount((config == null ? void 0 : config.amount) || 0)
|
|
47395
|
+
] }),
|
|
47396
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-green-600", children: "+$0.05 Processing Fee" })
|
|
47397
|
+
] }),
|
|
47398
|
+
(paymentData == null ? void 0 : paymentData.id) && /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
|
|
47399
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-400", children: "Transaction Hash:" }),
|
|
47400
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-600", children: truncateAddress(paymentData.id) })
|
|
47401
|
+
] })
|
|
47402
|
+
] })
|
|
47403
|
+
] }),
|
|
47404
|
+
activeTab === PAYMENT_TABS.WALLET && !showWalletConfirm && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47405
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
|
|
47406
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-1", children: "Select a network" }),
|
|
47407
|
+
/* @__PURE__ */ jsxs("div", { className: "relative mb-4", children: [
|
|
47408
|
+
/* @__PURE__ */ jsx("svg", { className: "absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" }) }),
|
|
47409
|
+
/* @__PURE__ */ jsx(
|
|
47410
|
+
"input",
|
|
47411
|
+
{
|
|
47412
|
+
type: "text",
|
|
47413
|
+
placeholder: "Search Network",
|
|
47414
|
+
value: networkSearch,
|
|
47415
|
+
onChange: (e) => setNetworkSearch(e.target.value),
|
|
47416
|
+
className: "w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:border-transparent"
|
|
47417
|
+
}
|
|
47418
|
+
)
|
|
47419
|
+
] }),
|
|
47420
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3", children: filteredNetworks.map((network) => /* @__PURE__ */ jsxs(
|
|
47421
|
+
"button",
|
|
47422
|
+
{
|
|
47423
|
+
onClick: () => handleNetworkSelect(network),
|
|
47424
|
+
className: `flex items-center gap-3 p-4 rounded-xl border-2 transition-all ${(selectedNetwork == null ? void 0 : selectedNetwork.id) === network.id ? "border-[#7042D2] bg-purple-50" : "border-gray-100 hover:border-[#7042D2] hover:bg-purple-50"}`,
|
|
47425
|
+
children: [
|
|
47426
|
+
/* @__PURE__ */ jsx(
|
|
47427
|
+
"img",
|
|
47428
|
+
{
|
|
47429
|
+
src: getNetworkLogoUrl(network),
|
|
47430
|
+
alt: network.name,
|
|
47431
|
+
className: "w-10 h-10 rounded-full",
|
|
47432
|
+
onError: (e) => {
|
|
47433
|
+
e.target.src = `https://ui-avatars.com/api/?name=${network.shortName}&background=7042D2&color=fff`;
|
|
47434
|
+
}
|
|
47435
|
+
}
|
|
47436
|
+
),
|
|
47437
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left", children: [
|
|
47438
|
+
/* @__PURE__ */ jsx("p", { className: "font-semibold text-gray-900", children: network.name }),
|
|
47439
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-400", children: "Blockchain network" })
|
|
47440
|
+
] })
|
|
47441
|
+
]
|
|
47442
|
+
},
|
|
47443
|
+
network.id
|
|
47444
|
+
)) })
|
|
47445
|
+
] }),
|
|
47446
|
+
selectedNetwork && availableTokens.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
|
|
47447
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-1", children: "Choose a token" }),
|
|
47448
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-gray-400 mb-4", children: "Select an option from these available tokens" }),
|
|
47449
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3", children: availableTokens.map((token) => /* @__PURE__ */ jsxs(
|
|
47450
|
+
"button",
|
|
47451
|
+
{
|
|
47452
|
+
onClick: () => handleTokenSelect(token),
|
|
47453
|
+
className: `flex items-center gap-3 p-4 rounded-xl border-2 transition-all ${(selectedToken == null ? void 0 : selectedToken.id) === token.id ? "border-[#7042D2] bg-purple-50" : "border-gray-100 hover:border-[#7042D2] hover:bg-purple-50"}`,
|
|
47454
|
+
children: [
|
|
47455
|
+
/* @__PURE__ */ jsx(
|
|
47456
|
+
"img",
|
|
47457
|
+
{
|
|
47458
|
+
src: getTokenLogoUrl(token.symbol),
|
|
47459
|
+
alt: token.symbol,
|
|
47460
|
+
className: "w-10 h-10 rounded-full",
|
|
47461
|
+
onError: (e) => {
|
|
47462
|
+
e.target.src = `https://ui-avatars.com/api/?name=${token.symbol}&background=7042D2&color=fff`;
|
|
47463
|
+
}
|
|
47464
|
+
}
|
|
47465
|
+
),
|
|
47466
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left", children: [
|
|
47467
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
47468
|
+
/* @__PURE__ */ jsx("p", { className: "font-semibold text-gray-900", children: token.name || token.symbol }),
|
|
47469
|
+
token.isStablecoin && /* @__PURE__ */ jsxs("span", { className: "text-xs text-green-600 flex items-center gap-1", children: [
|
|
47470
|
+
/* @__PURE__ */ jsx("span", { className: "w-1.5 h-1.5 bg-green-500 rounded-full" }),
|
|
47471
|
+
"Stable coin"
|
|
47472
|
+
] })
|
|
47473
|
+
] }),
|
|
47474
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-gray-400", children: truncateAddress(token.contractAddress || token.address) })
|
|
47475
|
+
] })
|
|
47476
|
+
]
|
|
47477
|
+
},
|
|
47478
|
+
token.id
|
|
47479
|
+
)) })
|
|
47480
|
+
] }),
|
|
47481
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3 mt-6", children: [
|
|
47482
|
+
/* @__PURE__ */ jsx(
|
|
47483
|
+
"button",
|
|
47484
|
+
{
|
|
47485
|
+
onClick: handleCancel,
|
|
47486
|
+
className: "px-8 py-3 border-2 border-[#7042D2] text-[#7042D2] rounded-xl font-semibold hover:bg-purple-50 transition-colors",
|
|
47487
|
+
children: "Cancel"
|
|
47488
|
+
}
|
|
47489
|
+
),
|
|
47490
|
+
/* @__PURE__ */ jsx(
|
|
47491
|
+
"button",
|
|
47492
|
+
{
|
|
47493
|
+
onClick: handleConnectWallet,
|
|
47494
|
+
disabled: !selectedNetwork || !selectedToken || loading,
|
|
47495
|
+
className: "flex-1 py-3 bg-[#7042D2] text-white rounded-xl font-semibold hover:bg-[#5b34b1] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
|
|
47496
|
+
children: loading ? "Creating Payment..." : "Connect my Wallet"
|
|
47497
|
+
}
|
|
47498
|
+
)
|
|
47499
|
+
] })
|
|
47500
|
+
] }),
|
|
47501
|
+
activeTab === PAYMENT_TABS.WALLET && showWalletConfirm && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47502
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
|
|
47503
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-4", children: "Confirm Payment" }),
|
|
47504
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-50 rounded-xl p-4 mb-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
|
|
47505
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
47506
|
+
/* @__PURE__ */ jsx(
|
|
47507
|
+
"img",
|
|
47508
|
+
{
|
|
47509
|
+
src: getNetworkLogoUrl(selectedNetwork),
|
|
47510
|
+
alt: selectedNetwork == null ? void 0 : selectedNetwork.name,
|
|
47511
|
+
className: "w-8 h-8 rounded-full",
|
|
47512
|
+
onError: (e) => {
|
|
47513
|
+
e.target.src = `https://ui-avatars.com/api/?name=${selectedNetwork == null ? void 0 : selectedNetwork.shortName}&background=7042D2&color=fff`;
|
|
47514
|
+
}
|
|
47515
|
+
}
|
|
47516
|
+
),
|
|
47517
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: selectedNetwork == null ? void 0 : selectedNetwork.name })
|
|
47518
|
+
] }),
|
|
47519
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-400", children: "•" }),
|
|
47520
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
47521
|
+
/* @__PURE__ */ jsx(
|
|
47522
|
+
"img",
|
|
47523
|
+
{
|
|
47524
|
+
src: getTokenLogoUrl(selectedToken == null ? void 0 : selectedToken.symbol),
|
|
47525
|
+
alt: selectedToken == null ? void 0 : selectedToken.symbol,
|
|
47526
|
+
className: "w-8 h-8 rounded-full",
|
|
47527
|
+
onError: (e) => {
|
|
47528
|
+
e.target.src = `https://ui-avatars.com/api/?name=${selectedToken == null ? void 0 : selectedToken.symbol}&background=7042D2&color=fff`;
|
|
47529
|
+
}
|
|
47530
|
+
}
|
|
47531
|
+
),
|
|
47532
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: selectedToken == null ? void 0 : selectedToken.symbol })
|
|
47533
|
+
] })
|
|
47534
|
+
] }) }),
|
|
47535
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-gray-50 rounded-xl p-4 space-y-3", children: [
|
|
47536
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
|
|
47537
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "Product Amount" }),
|
|
47538
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
47539
|
+
"$",
|
|
47540
|
+
formatAmount((paymentData == null ? void 0 : paymentData.productAmount) || (config == null ? void 0 : config.amount) || 0)
|
|
47541
|
+
] })
|
|
47542
|
+
] }),
|
|
47543
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
|
|
47544
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "Processing Fee" }),
|
|
47545
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
47546
|
+
"+$",
|
|
47547
|
+
formatAmount((paymentData == null ? void 0 : paymentData.platformFee) || 0)
|
|
47548
|
+
] })
|
|
47549
|
+
] }),
|
|
47550
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between", children: [
|
|
47551
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "Network Fee" }),
|
|
47552
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
47553
|
+
"+$",
|
|
47554
|
+
formatAmount((paymentData == null ? void 0 : paymentData.networkFee) || 0)
|
|
47555
|
+
] })
|
|
47556
|
+
] }),
|
|
47557
|
+
/* @__PURE__ */ jsxs("div", { className: "border-t border-gray-200 pt-3 flex justify-between", children: [
|
|
47558
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold", children: "Total" }),
|
|
47559
|
+
/* @__PURE__ */ jsxs("span", { className: "font-bold text-lg", children: [
|
|
47560
|
+
formatAmount((paymentData == null ? void 0 : paymentData.totalAmount) || (config == null ? void 0 : config.amount) || 0),
|
|
47561
|
+
" ",
|
|
47562
|
+
selectedToken == null ? void 0 : selectedToken.symbol
|
|
47563
|
+
] })
|
|
47564
|
+
] })
|
|
47565
|
+
] })
|
|
47566
|
+
] }),
|
|
47567
|
+
/* @__PURE__ */ jsx("div", { className: "mb-6", children: /* @__PURE__ */ jsx(
|
|
47568
|
+
WalletSelector,
|
|
47569
|
+
{
|
|
47570
|
+
selectedNetwork,
|
|
47571
|
+
onWalletSelect: handleWalletSelection,
|
|
47572
|
+
onConnect: handleConnect,
|
|
47573
|
+
connectedWallet: isSolana ? solanaWallet.connectedWallet : connectedWallet,
|
|
47574
|
+
loading,
|
|
47575
|
+
paymentData,
|
|
47576
|
+
selectedToken,
|
|
47577
|
+
api: paymentFlow.api,
|
|
47578
|
+
solanaWallet,
|
|
47579
|
+
onSolanaConnect: async ({ walletType, publicKey: publicKey22, wallet }) => {
|
|
47580
|
+
console.log("Solana wallet connected:", walletType, publicKey22);
|
|
47581
|
+
}
|
|
47582
|
+
}
|
|
47583
|
+
) }),
|
|
47584
|
+
(connectedWallet || solanaWallet.connectedWallet) && /* @__PURE__ */ jsx("div", { className: "bg-green-50 border border-green-200 rounded-xl p-4 mb-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
47585
|
+
/* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-green-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) }),
|
|
47586
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
47587
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-green-800", children: "Wallet Connected" }),
|
|
47588
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-green-600", children: truncateAddress(isSolana ? solanaWallet.publicKey : address) })
|
|
47589
|
+
] })
|
|
47590
|
+
] }) }),
|
|
47591
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3 mt-6", children: [
|
|
47592
|
+
/* @__PURE__ */ jsx(
|
|
47593
|
+
"button",
|
|
47594
|
+
{
|
|
47595
|
+
onClick: handleBackFromWalletConfirm,
|
|
47596
|
+
className: "px-8 py-3 border-2 border-[#7042D2] text-[#7042D2] rounded-xl font-semibold hover:bg-purple-50 transition-colors",
|
|
47597
|
+
children: "Back"
|
|
47598
|
+
}
|
|
47599
|
+
),
|
|
47600
|
+
/* @__PURE__ */ jsx(
|
|
47601
|
+
"button",
|
|
47602
|
+
{
|
|
47603
|
+
onClick: executePayment,
|
|
47604
|
+
disabled: !(connectedWallet || solanaWallet.connectedWallet) || loading,
|
|
47605
|
+
className: "flex-1 py-3 bg-[#7042D2] text-white rounded-xl font-semibold hover:bg-[#5b34b1] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
|
|
47606
|
+
children: loading ? "Processing..." : `Pay ${formatAmount((paymentData == null ? void 0 : paymentData.totalAmount) || (config == null ? void 0 : config.amount) || 0)} ${selectedToken == null ? void 0 : selectedToken.symbol}`
|
|
47607
|
+
}
|
|
47608
|
+
)
|
|
47609
|
+
] })
|
|
47610
|
+
] }),
|
|
47611
|
+
activeTab === PAYMENT_TABS.QR && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47612
|
+
(!selectedNetwork || !selectedToken) && /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
|
|
47613
|
+
/* @__PURE__ */ jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsx("svg", { className: "w-16 h-16 mx-auto text-gray-300", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M16 20h4M4 12h4m12 0h.01M5 8h2a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1zm12 0h2a1 1 0 001-1V5a1 1 0 00-1-1h-2a1 1 0 00-1 1v2a1 1 0 001 1zM5 20h2a1 1 0 001-1v-2a1 1 0 00-1-1H5a1 1 0 00-1 1v2a1 1 0 001 1z" }) }) }),
|
|
47614
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-2", children: "Generate QR Code" }),
|
|
47615
|
+
/* @__PURE__ */ jsx("p", { className: "text-gray-500 mb-6", children: "Please select a network and token to generate your payment QR code" }),
|
|
47616
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left max-w-md mx-auto", children: [
|
|
47617
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
|
|
47618
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Network" }),
|
|
47619
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: networks.slice(0, 4).map((network) => /* @__PURE__ */ jsxs(
|
|
47620
|
+
"button",
|
|
47621
|
+
{
|
|
47622
|
+
onClick: () => handleNetworkSelect(network),
|
|
47623
|
+
className: `flex items-center gap-2 p-3 rounded-xl border-2 transition-all ${(selectedNetwork == null ? void 0 : selectedNetwork.id) === network.id ? "border-[#7042D2] bg-purple-50" : "border-gray-100 hover:border-[#7042D2]"}`,
|
|
47624
|
+
children: [
|
|
47625
|
+
/* @__PURE__ */ jsx(
|
|
47626
|
+
"img",
|
|
47627
|
+
{
|
|
47628
|
+
src: getNetworkLogoUrl(network),
|
|
47629
|
+
alt: network.name,
|
|
47630
|
+
className: "w-6 h-6 rounded-full",
|
|
47631
|
+
onError: (e) => {
|
|
47632
|
+
e.target.src = `https://ui-avatars.com/api/?name=${network.shortName}&background=7042D2&color=fff`;
|
|
47633
|
+
}
|
|
47634
|
+
}
|
|
47635
|
+
),
|
|
47636
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: network.name })
|
|
47637
|
+
]
|
|
47638
|
+
},
|
|
47639
|
+
network.id
|
|
47640
|
+
)) })
|
|
47641
|
+
] }),
|
|
47642
|
+
selectedNetwork && availableTokens.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
|
|
47643
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Token" }),
|
|
47644
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: availableTokens.map((token) => /* @__PURE__ */ jsxs(
|
|
47645
|
+
"button",
|
|
47646
|
+
{
|
|
47647
|
+
onClick: async () => {
|
|
47648
|
+
handleTokenSelect(token);
|
|
47649
|
+
if (!paymentData) {
|
|
47650
|
+
await createPayment(config);
|
|
47651
|
+
}
|
|
47652
|
+
},
|
|
47653
|
+
className: `flex items-center gap-2 p-3 rounded-xl border-2 transition-all ${(selectedToken == null ? void 0 : selectedToken.id) === token.id ? "border-[#7042D2] bg-purple-50" : "border-gray-100 hover:border-[#7042D2]"}`,
|
|
47654
|
+
children: [
|
|
47655
|
+
/* @__PURE__ */ jsx(
|
|
47656
|
+
"img",
|
|
47657
|
+
{
|
|
47658
|
+
src: getTokenLogoUrl(token.symbol),
|
|
47659
|
+
alt: token.symbol,
|
|
47660
|
+
className: "w-6 h-6 rounded-full",
|
|
47661
|
+
onError: (e) => {
|
|
47662
|
+
e.target.src = `https://ui-avatars.com/api/?name=${token.symbol}&background=7042D2&color=fff`;
|
|
47663
|
+
}
|
|
47664
|
+
}
|
|
47665
|
+
),
|
|
47666
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: token.symbol })
|
|
47667
|
+
]
|
|
47668
|
+
},
|
|
47669
|
+
token.id
|
|
47670
|
+
)) })
|
|
47671
|
+
] })
|
|
47672
|
+
] })
|
|
47673
|
+
] }),
|
|
47674
|
+
selectedNetwork && selectedToken && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47675
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-6 mb-6", children: [
|
|
47676
|
+
/* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: qrCodeDataUrl ? /* @__PURE__ */ jsx("img", { src: qrCodeDataUrl, alt: "Payment QR Code", className: "w-40 h-40" }) : /* @__PURE__ */ jsx("div", { className: "w-40 h-40 bg-gray-100 rounded-lg flex items-center justify-center animate-pulse", children: /* @__PURE__ */ jsx("span", { className: "text-gray-400 text-sm", children: "Generating..." }) }) }),
|
|
47677
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
47678
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold mb-3", children: "Instructions" }),
|
|
47679
|
+
/* @__PURE__ */ jsxs("ol", { className: "text-sm text-gray-600 space-y-2", children: [
|
|
47680
|
+
/* @__PURE__ */ jsx("li", { children: "1. Open your crypto wallet app (metamask, trust wallet etc)" }),
|
|
47681
|
+
/* @__PURE__ */ jsx("li", { children: "2. Scan the QR code above" }),
|
|
47682
|
+
/* @__PURE__ */ jsxs("li", { children: [
|
|
47683
|
+
"3. Confirm the payment amount (",
|
|
47684
|
+
formatAmount((paymentData == null ? void 0 : paymentData.totalAmount) || (config == null ? void 0 : config.amount)),
|
|
47685
|
+
" ",
|
|
47686
|
+
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
47687
|
+
")"
|
|
47688
|
+
] }),
|
|
47689
|
+
/* @__PURE__ */ jsx("li", { children: `4. Click "I've paid" button below after sending the payment` })
|
|
47690
|
+
] })
|
|
47691
|
+
] })
|
|
47692
|
+
] }),
|
|
47693
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between py-3 border-t border-gray-100", children: [
|
|
47694
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "Currency" }),
|
|
47695
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: selectedToken == null ? void 0 : selectedToken.symbol })
|
|
47696
|
+
] }),
|
|
47697
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between py-3 border-t border-gray-100", children: [
|
|
47698
|
+
/* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "Network" }),
|
|
47699
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: selectedNetwork == null ? void 0 : selectedNetwork.name })
|
|
47700
|
+
] }),
|
|
47701
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-purple-50 border border-purple-200 rounded-xl p-4 mt-4 flex items-start gap-3", children: [
|
|
47702
|
+
/* @__PURE__ */ jsx("svg", { className: "w-6 h-6 text-[#7042D2] flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
|
|
47703
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-[#7042D2]", children: [
|
|
47704
|
+
"Make sure you're sending on the correct network (",
|
|
47705
|
+
selectedNetwork == null ? void 0 : selectedNetwork.name,
|
|
47706
|
+
") and using the exact amount shown above."
|
|
47707
|
+
] })
|
|
47708
|
+
] }),
|
|
47709
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3 mt-6", children: [
|
|
47710
|
+
/* @__PURE__ */ jsxs(
|
|
47711
|
+
"button",
|
|
47712
|
+
{
|
|
47713
|
+
onClick: () => {
|
|
47714
|
+
if (qrCodeDataUrl) {
|
|
47715
|
+
const link = document.createElement("a");
|
|
47716
|
+
link.download = `coinley-payment-${(paymentData == null ? void 0 : paymentData.id) || "qr"}.png`;
|
|
47717
|
+
link.href = qrCodeDataUrl;
|
|
47718
|
+
link.click();
|
|
47719
|
+
}
|
|
47720
|
+
},
|
|
47721
|
+
className: "px-6 py-3 border-2 border-[#7042D2] text-[#7042D2] rounded-xl font-semibold hover:bg-purple-50 transition-colors flex items-center gap-2",
|
|
47722
|
+
children: [
|
|
47723
|
+
/* @__PURE__ */ jsx("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" }) }),
|
|
47724
|
+
"Download QR"
|
|
47725
|
+
]
|
|
47726
|
+
}
|
|
47727
|
+
),
|
|
47728
|
+
/* @__PURE__ */ jsx(
|
|
47729
|
+
"button",
|
|
47730
|
+
{
|
|
47731
|
+
onClick: handlePaymentConfirmation,
|
|
47732
|
+
disabled: !paymentData || verifyingPayment,
|
|
47733
|
+
className: "flex-1 py-3 bg-[#7042D2] text-white rounded-xl font-semibold hover:bg-[#5b34b1] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
|
|
47734
|
+
children: verifyingPayment ? "Verifying..." : "I've made the payment"
|
|
47735
|
+
}
|
|
47736
|
+
)
|
|
47737
|
+
] })
|
|
47738
|
+
] })
|
|
47739
|
+
] }),
|
|
47740
|
+
activeTab === PAYMENT_TABS.TRANSFER && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47741
|
+
(!selectedNetwork || !selectedToken || !(paymentData == null ? void 0 : paymentData.depositAddress)) && /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
|
|
47742
|
+
/* @__PURE__ */ jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsx("svg", { className: "w-16 h-16 mx-auto text-gray-300", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4" }) }) }),
|
|
47743
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-2", children: "Transfer to Address" }),
|
|
47744
|
+
/* @__PURE__ */ jsx("p", { className: "text-gray-500 mb-6", children: "Select a network and token to get the payment address" }),
|
|
47745
|
+
/* @__PURE__ */ jsxs("div", { className: "text-left max-w-md mx-auto", children: [
|
|
47746
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
|
|
47747
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Network" }),
|
|
47748
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: networks.slice(0, 4).map((network) => /* @__PURE__ */ jsxs(
|
|
47749
|
+
"button",
|
|
47750
|
+
{
|
|
47751
|
+
onClick: () => handleNetworkSelect(network),
|
|
47752
|
+
className: `flex items-center gap-2 p-3 rounded-xl border-2 transition-all ${(selectedNetwork == null ? void 0 : selectedNetwork.id) === network.id ? "border-[#7042D2] bg-purple-50" : "border-gray-100 hover:border-[#7042D2]"}`,
|
|
47753
|
+
children: [
|
|
47754
|
+
/* @__PURE__ */ jsx(
|
|
47755
|
+
"img",
|
|
47756
|
+
{
|
|
47757
|
+
src: getNetworkLogoUrl(network),
|
|
47758
|
+
alt: network.name,
|
|
47759
|
+
className: "w-6 h-6 rounded-full",
|
|
47760
|
+
onError: (e) => {
|
|
47761
|
+
e.target.src = `https://ui-avatars.com/api/?name=${network.shortName}&background=7042D2&color=fff`;
|
|
47762
|
+
}
|
|
47763
|
+
}
|
|
47764
|
+
),
|
|
47765
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: network.name })
|
|
47766
|
+
]
|
|
47767
|
+
},
|
|
47768
|
+
network.id
|
|
47769
|
+
)) })
|
|
47770
|
+
] }),
|
|
47771
|
+
selectedNetwork && availableTokens.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
|
|
47772
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: "Token" }),
|
|
47773
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: availableTokens.map((token) => /* @__PURE__ */ jsxs(
|
|
47774
|
+
"button",
|
|
47775
|
+
{
|
|
47776
|
+
onClick: () => handleTokenSelect(token),
|
|
47777
|
+
className: `flex items-center gap-2 p-3 rounded-xl border-2 transition-all ${(selectedToken == null ? void 0 : selectedToken.id) === token.id ? "border-[#7042D2] bg-purple-50" : "border-gray-100 hover:border-[#7042D2]"}`,
|
|
47778
|
+
children: [
|
|
47779
|
+
/* @__PURE__ */ jsx(
|
|
47780
|
+
"img",
|
|
47781
|
+
{
|
|
47782
|
+
src: getTokenLogoUrl(token.symbol),
|
|
47783
|
+
alt: token.symbol,
|
|
47784
|
+
className: "w-6 h-6 rounded-full",
|
|
47785
|
+
onError: (e) => {
|
|
47786
|
+
e.target.src = `https://ui-avatars.com/api/?name=${token.symbol}&background=7042D2&color=fff`;
|
|
47787
|
+
}
|
|
47788
|
+
}
|
|
47789
|
+
),
|
|
47790
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: token.symbol })
|
|
47791
|
+
]
|
|
47792
|
+
},
|
|
47793
|
+
token.id
|
|
47794
|
+
)) })
|
|
47795
|
+
] }),
|
|
47796
|
+
selectedNetwork && selectedToken && !(paymentData == null ? void 0 : paymentData.depositAddress) && /* @__PURE__ */ jsx(
|
|
47797
|
+
"button",
|
|
47798
|
+
{
|
|
47799
|
+
onClick: async () => {
|
|
47800
|
+
try {
|
|
47801
|
+
await createDepositPayment(config);
|
|
47802
|
+
} catch (err) {
|
|
47803
|
+
}
|
|
47804
|
+
},
|
|
47805
|
+
disabled: loading,
|
|
47806
|
+
className: "w-full py-3 bg-[#7042D2] text-white rounded-xl font-semibold hover:bg-[#5b34b1] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
|
|
47807
|
+
children: loading ? "Generating Address..." : "Generate Transfer Address"
|
|
47808
|
+
}
|
|
47809
|
+
)
|
|
47810
|
+
] })
|
|
47811
|
+
] }),
|
|
47812
|
+
selectedNetwork && selectedToken && (paymentData == null ? void 0 : paymentData.depositAddress) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47813
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
|
|
47814
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-700 mb-2", children: "Wallet Address" }),
|
|
47815
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-4 bg-gray-50 rounded-xl border border-gray-200", children: [
|
|
47816
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1 text-sm font-mono text-gray-700 break-all", children: paymentData.depositAddress }),
|
|
47817
|
+
/* @__PURE__ */ jsx(
|
|
47818
|
+
"button",
|
|
47819
|
+
{
|
|
47820
|
+
onClick: () => copyToClipboard(paymentData.depositAddress),
|
|
47821
|
+
className: "p-2 hover:bg-gray-200 rounded-lg transition-colors flex-shrink-0",
|
|
47822
|
+
children: /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-gray-500", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" }) })
|
|
47823
|
+
}
|
|
47824
|
+
)
|
|
47825
|
+
] }),
|
|
47826
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-gray-400 mt-2 flex items-center gap-1", children: [
|
|
47827
|
+
/* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
|
47828
|
+
"Double-check before sending. Transactions cannot be reversed."
|
|
47829
|
+
] })
|
|
47830
|
+
] }),
|
|
47831
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
|
|
47832
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-700 mb-2", children: "Amount" }),
|
|
47833
|
+
/* @__PURE__ */ jsx("div", { className: "p-4 bg-gray-50 rounded-xl border border-gray-200", children: /* @__PURE__ */ jsxs("span", { className: "text-lg font-semibold", children: [
|
|
47834
|
+
formatAmount((paymentData == null ? void 0 : paymentData.totalAmount) || (config == null ? void 0 : config.amount)),
|
|
47835
|
+
" ",
|
|
47836
|
+
selectedToken == null ? void 0 : selectedToken.symbol
|
|
47837
|
+
] }) })
|
|
47838
|
+
] }),
|
|
47839
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
|
|
47840
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-700 mb-2", children: "Network Fee" }),
|
|
47841
|
+
/* @__PURE__ */ jsx("div", { className: "p-4 bg-gray-50 rounded-xl border border-gray-200", children: /* @__PURE__ */ jsxs("span", { className: "text-lg font-semibold", children: [
|
|
47842
|
+
"$",
|
|
47843
|
+
formatAmount((paymentData == null ? void 0 : paymentData.networkFee) || 0.5)
|
|
47844
|
+
] }) })
|
|
47845
|
+
] }),
|
|
47846
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-orange-50 border border-orange-200 rounded-xl p-4 flex items-start gap-3", children: [
|
|
47847
|
+
/* @__PURE__ */ jsx("svg", { className: "w-6 h-6 text-orange-500 flex-shrink-0", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" }) }),
|
|
47848
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
47849
|
+
/* @__PURE__ */ jsxs("p", { className: "font-semibold text-orange-700", children: [
|
|
47850
|
+
"Send ",
|
|
47851
|
+
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
47852
|
+
" on ",
|
|
47853
|
+
selectedNetwork == null ? void 0 : selectedNetwork.name,
|
|
47854
|
+
" network"
|
|
47855
|
+
] }),
|
|
47856
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-orange-600", children: [
|
|
47857
|
+
"Use the ",
|
|
47858
|
+
selectedNetwork == null ? void 0 : selectedNetwork.name,
|
|
47859
|
+
" network to send your ",
|
|
47860
|
+
selectedToken == null ? void 0 : selectedToken.symbol,
|
|
47861
|
+
" quickly and securely with lower transaction fees."
|
|
47862
|
+
] })
|
|
47863
|
+
] })
|
|
47864
|
+
] }),
|
|
47865
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3 mt-6", children: [
|
|
47866
|
+
/* @__PURE__ */ jsx(
|
|
47867
|
+
"button",
|
|
47868
|
+
{
|
|
47869
|
+
onClick: () => {
|
|
47870
|
+
resetAllTransactionState();
|
|
47871
|
+
setActiveTab(PAYMENT_TABS.WALLET);
|
|
47872
|
+
},
|
|
47873
|
+
className: "px-8 py-3 border-2 border-[#7042D2] text-[#7042D2] rounded-xl font-semibold hover:bg-purple-50 transition-colors",
|
|
47874
|
+
children: "Go Back"
|
|
47875
|
+
}
|
|
47876
|
+
),
|
|
47877
|
+
/* @__PURE__ */ jsx(
|
|
47878
|
+
"button",
|
|
47879
|
+
{
|
|
47880
|
+
onClick: handlePaymentConfirmation,
|
|
47881
|
+
disabled: verifyingPayment,
|
|
47882
|
+
className: "flex-1 py-3 bg-[#7042D2] text-white rounded-xl font-semibold hover:bg-[#5b34b1] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
|
|
47883
|
+
children: verifyingPayment ? "Verifying..." : "I've made the payment"
|
|
47884
|
+
}
|
|
47885
|
+
)
|
|
47886
|
+
] })
|
|
47887
|
+
] })
|
|
47888
|
+
] }),
|
|
47889
|
+
(error || transactionError) && /* @__PURE__ */ jsxs("div", { className: "mt-4 p-4 bg-red-50 border border-red-200 rounded-xl", children: [
|
|
47890
|
+
/* @__PURE__ */ jsx("p", { className: "text-red-800 text-sm", children: error || transactionError }),
|
|
47891
|
+
/* @__PURE__ */ jsx(
|
|
47892
|
+
"button",
|
|
47893
|
+
{
|
|
47894
|
+
onClick: () => {
|
|
47895
|
+
var _a2;
|
|
47896
|
+
setError("");
|
|
47897
|
+
(_a2 = transactionHandling.setTransactionError) == null ? void 0 : _a2.call(transactionHandling, "");
|
|
47898
|
+
},
|
|
47899
|
+
className: "mt-2 text-red-600 hover:text-red-800 text-xs underline",
|
|
47900
|
+
children: "Dismiss"
|
|
47901
|
+
}
|
|
47902
|
+
)
|
|
47903
|
+
] })
|
|
47904
|
+
] })
|
|
47905
|
+
] }) })
|
|
47906
|
+
] });
|
|
47907
|
+
};
|
|
47908
|
+
const RedesignedCoinleyPayment = (props) => {
|
|
47909
|
+
return /* @__PURE__ */ jsx(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(RedesignedCoinleyPaymentInternal, { ...props }) }) });
|
|
47910
|
+
};
|
|
46889
47911
|
const NETWORK_CHAINS = {
|
|
46890
47912
|
ethereum: mainnet,
|
|
46891
47913
|
bsc,
|
|
@@ -48366,6 +49388,7 @@ export {
|
|
|
48366
49388
|
PaymentAPI,
|
|
48367
49389
|
PaymentQRGenerator,
|
|
48368
49390
|
QRCodePayment,
|
|
49391
|
+
RedesignedCoinleyPayment,
|
|
48369
49392
|
SimpleCoinleyProvider,
|
|
48370
49393
|
ThemeProvider,
|
|
48371
49394
|
USAGE_EXAMPLES,
|