coinley-checkout 0.1.5 → 0.1.7
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/coinley-checkout.es.js +199 -616
- package/dist/coinley-checkout.es.js.map +1 -1
- package/dist/style.css +0 -3
- package/package.json +1 -1
- package/dist/coinley-checkout.umd.js +0 -1993
- package/dist/coinley-checkout.umd.js.map +0 -1
@@ -1,4 +1,117 @@
|
|
1
|
-
import require$$0, { createContext, useContext, useState, useEffect,
|
1
|
+
import require$$0, { createContext, useContext, useState, useEffect, forwardRef, useImperativeHandle } from "react";
|
2
|
+
const styles = "";
|
3
|
+
let apiConfig = {
|
4
|
+
apiKey: null,
|
5
|
+
apiSecret: null,
|
6
|
+
apiUrl: "https://coinleyserver-production.up.railway.app"
|
7
|
+
};
|
8
|
+
const initializeApi = (config) => {
|
9
|
+
apiConfig = { ...apiConfig, ...config };
|
10
|
+
console.log("API initialized with:", apiConfig);
|
11
|
+
};
|
12
|
+
const getHeaders = () => {
|
13
|
+
return {
|
14
|
+
"Content-Type": "application/json",
|
15
|
+
"x-api-key": apiConfig.apiKey,
|
16
|
+
"x-api-secret": apiConfig.apiSecret
|
17
|
+
};
|
18
|
+
};
|
19
|
+
const createPayment = async (paymentData) => {
|
20
|
+
try {
|
21
|
+
console.log("Creating payment with data:", paymentData);
|
22
|
+
console.log("API URL:", `${apiConfig.apiUrl}/api/payments/create`);
|
23
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/create`, {
|
24
|
+
method: "POST",
|
25
|
+
headers: getHeaders(),
|
26
|
+
body: JSON.stringify(paymentData)
|
27
|
+
});
|
28
|
+
console.log("Create payment response status:", response.status);
|
29
|
+
if (!response.ok) {
|
30
|
+
const errorData = await response.json();
|
31
|
+
console.error("Error creating payment:", errorData);
|
32
|
+
throw new Error(errorData.error || `Failed to create payment: ${response.status}`);
|
33
|
+
}
|
34
|
+
const data = await response.json();
|
35
|
+
console.log("Create payment response data:", data);
|
36
|
+
return data;
|
37
|
+
} catch (error) {
|
38
|
+
console.error("Create payment error:", error);
|
39
|
+
throw error;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
const getPayment = async (paymentId) => {
|
43
|
+
try {
|
44
|
+
console.log("Getting payment:", paymentId);
|
45
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/${paymentId}`, {
|
46
|
+
method: "GET",
|
47
|
+
headers: getHeaders()
|
48
|
+
});
|
49
|
+
if (!response.ok) {
|
50
|
+
const errorData = await response.json();
|
51
|
+
console.error("Error getting payment:", errorData);
|
52
|
+
throw new Error(errorData.error || `Failed to get payment: ${response.status}`);
|
53
|
+
}
|
54
|
+
const data = await response.json();
|
55
|
+
console.log("Get payment response:", data);
|
56
|
+
return data;
|
57
|
+
} catch (error) {
|
58
|
+
console.error("Get payment error:", error);
|
59
|
+
throw error;
|
60
|
+
}
|
61
|
+
};
|
62
|
+
const processPayment = async (processData) => {
|
63
|
+
try {
|
64
|
+
console.log("Processing payment with data:", processData);
|
65
|
+
console.log("API URL:", `${apiConfig.apiUrl}/api/payments/process`);
|
66
|
+
const response = await fetch(`${apiConfig.apiUrl}/api/payments/process`, {
|
67
|
+
method: "POST",
|
68
|
+
headers: getHeaders(),
|
69
|
+
body: JSON.stringify(processData)
|
70
|
+
});
|
71
|
+
console.log("Process payment response status:", response.status);
|
72
|
+
if (!response.ok) {
|
73
|
+
const errorData = await response.json();
|
74
|
+
console.error("Error processing payment:", errorData);
|
75
|
+
throw new Error(errorData.error || `Failed to process payment: ${response.status}`);
|
76
|
+
}
|
77
|
+
const data = await response.json();
|
78
|
+
console.log("Process payment response data:", data);
|
79
|
+
return data;
|
80
|
+
} catch (error) {
|
81
|
+
console.error("Process payment error:", error);
|
82
|
+
throw error;
|
83
|
+
}
|
84
|
+
};
|
85
|
+
const isMetaMaskInstalled = () => {
|
86
|
+
return typeof window !== "undefined" && typeof window.ethereum !== "undefined";
|
87
|
+
};
|
88
|
+
const connectWallet = async () => {
|
89
|
+
if (!isMetaMaskInstalled()) {
|
90
|
+
throw new Error("MetaMask is not installed");
|
91
|
+
}
|
92
|
+
try {
|
93
|
+
const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
|
94
|
+
return accounts;
|
95
|
+
} catch (error) {
|
96
|
+
console.error("Error connecting to wallet:", error);
|
97
|
+
throw error;
|
98
|
+
}
|
99
|
+
};
|
100
|
+
const sendTransaction = async (txParams) => {
|
101
|
+
if (!isMetaMaskInstalled()) {
|
102
|
+
throw new Error("MetaMask is not installed");
|
103
|
+
}
|
104
|
+
try {
|
105
|
+
const txHash = await window.ethereum.request({
|
106
|
+
method: "eth_sendTransaction",
|
107
|
+
params: [txParams]
|
108
|
+
});
|
109
|
+
return txHash;
|
110
|
+
} catch (error) {
|
111
|
+
console.error("Error sending transaction:", error);
|
112
|
+
throw error;
|
113
|
+
}
|
114
|
+
};
|
2
115
|
var jsxRuntime = { exports: {} };
|
3
116
|
var reactJsxRuntime_production_min = {};
|
4
117
|
/**
|
@@ -954,159 +1067,6 @@ const ThemeProvider = ({ initialTheme = "light", children }) => {
|
|
954
1067
|
}, [theme]);
|
955
1068
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeContext.Provider, { value: { theme, setTheme, toggleTheme }, children });
|
956
1069
|
};
|
957
|
-
let apiConfig = {
|
958
|
-
apiKey: null,
|
959
|
-
apiSecret: null,
|
960
|
-
apiUrl: "https://coinleyserver-production.up.railway.app"
|
961
|
-
};
|
962
|
-
const initializeApi = (config) => {
|
963
|
-
apiConfig = { ...apiConfig, ...config };
|
964
|
-
console.log("API initialized with:", apiConfig);
|
965
|
-
};
|
966
|
-
const getHeaders = () => {
|
967
|
-
return {
|
968
|
-
"Content-Type": "application/json",
|
969
|
-
"x-api-key": apiConfig.apiKey,
|
970
|
-
"x-api-secret": apiConfig.apiSecret
|
971
|
-
};
|
972
|
-
};
|
973
|
-
const createPayment = async (paymentData) => {
|
974
|
-
try {
|
975
|
-
console.log("Creating payment with data:", paymentData);
|
976
|
-
console.log("API URL:", `${apiConfig.apiUrl}/api/payments/create`);
|
977
|
-
const response = await fetch(`${apiConfig.apiUrl}/api/payments/create`, {
|
978
|
-
method: "POST",
|
979
|
-
headers: getHeaders(),
|
980
|
-
body: JSON.stringify(paymentData)
|
981
|
-
});
|
982
|
-
console.log("Create payment response status:", response.status);
|
983
|
-
if (!response.ok) {
|
984
|
-
const errorData = await response.json();
|
985
|
-
console.error("Error creating payment:", errorData);
|
986
|
-
throw new Error(errorData.error || `Failed to create payment: ${response.status}`);
|
987
|
-
}
|
988
|
-
const data = await response.json();
|
989
|
-
console.log("Create payment response data:", data);
|
990
|
-
return data;
|
991
|
-
} catch (error) {
|
992
|
-
console.error("Create payment error:", error);
|
993
|
-
throw error;
|
994
|
-
}
|
995
|
-
};
|
996
|
-
const getPayment = async (paymentId) => {
|
997
|
-
try {
|
998
|
-
console.log("Getting payment:", paymentId);
|
999
|
-
const response = await fetch(`${apiConfig.apiUrl}/api/payments/${paymentId}`, {
|
1000
|
-
method: "GET",
|
1001
|
-
headers: getHeaders()
|
1002
|
-
});
|
1003
|
-
if (!response.ok) {
|
1004
|
-
const errorData = await response.json();
|
1005
|
-
console.error("Error getting payment:", errorData);
|
1006
|
-
throw new Error(errorData.error || `Failed to get payment: ${response.status}`);
|
1007
|
-
}
|
1008
|
-
const data = await response.json();
|
1009
|
-
console.log("Get payment response:", data);
|
1010
|
-
return data;
|
1011
|
-
} catch (error) {
|
1012
|
-
console.error("Get payment error:", error);
|
1013
|
-
throw error;
|
1014
|
-
}
|
1015
|
-
};
|
1016
|
-
const processPayment = async (processData) => {
|
1017
|
-
try {
|
1018
|
-
console.log("Processing payment with data:", processData);
|
1019
|
-
console.log("API URL:", `${apiConfig.apiUrl}/api/payments/process`);
|
1020
|
-
const response = await fetch(`${apiConfig.apiUrl}/api/payments/process`, {
|
1021
|
-
method: "POST",
|
1022
|
-
headers: getHeaders(),
|
1023
|
-
body: JSON.stringify(processData)
|
1024
|
-
});
|
1025
|
-
console.log("Process payment response status:", response.status);
|
1026
|
-
if (!response.ok) {
|
1027
|
-
const errorData = await response.json();
|
1028
|
-
console.error("Error processing payment:", errorData);
|
1029
|
-
throw new Error(errorData.error || `Failed to process payment: ${response.status}`);
|
1030
|
-
}
|
1031
|
-
const data = await response.json();
|
1032
|
-
console.log("Process payment response data:", data);
|
1033
|
-
return data;
|
1034
|
-
} catch (error) {
|
1035
|
-
console.error("Process payment error:", error);
|
1036
|
-
throw error;
|
1037
|
-
}
|
1038
|
-
};
|
1039
|
-
const getMerchantPayments = async (options = {}) => {
|
1040
|
-
try {
|
1041
|
-
const { page = 1, limit = 10, status, currency, startDate, endDate, search } = options;
|
1042
|
-
const queryParams = new URLSearchParams();
|
1043
|
-
queryParams.append("page", page);
|
1044
|
-
queryParams.append("limit", limit);
|
1045
|
-
if (status)
|
1046
|
-
queryParams.append("status", status);
|
1047
|
-
if (currency)
|
1048
|
-
queryParams.append("currency", currency);
|
1049
|
-
if (startDate)
|
1050
|
-
queryParams.append("startDate", startDate);
|
1051
|
-
if (endDate)
|
1052
|
-
queryParams.append("endDate", endDate);
|
1053
|
-
if (search)
|
1054
|
-
queryParams.append("search", search);
|
1055
|
-
const url = `${apiConfig.apiUrl}/api/payments/merchant/list?${queryParams.toString()}`;
|
1056
|
-
const response = await fetch(url, {
|
1057
|
-
method: "GET",
|
1058
|
-
headers: getHeaders()
|
1059
|
-
});
|
1060
|
-
if (!response.ok) {
|
1061
|
-
const errorData = await response.json();
|
1062
|
-
throw new Error(errorData.error || `Failed to get payments: ${response.status}`);
|
1063
|
-
}
|
1064
|
-
return await response.json();
|
1065
|
-
} catch (error) {
|
1066
|
-
console.error("Get merchant payments error:", error);
|
1067
|
-
throw error;
|
1068
|
-
}
|
1069
|
-
};
|
1070
|
-
const getMerchantPaymentStats = async () => {
|
1071
|
-
try {
|
1072
|
-
const response = await fetch(`${apiConfig.apiUrl}/api/payments/merchant/stats`, {
|
1073
|
-
method: "GET",
|
1074
|
-
headers: getHeaders()
|
1075
|
-
});
|
1076
|
-
if (!response.ok) {
|
1077
|
-
const errorData = await response.json();
|
1078
|
-
throw new Error(errorData.error || `Failed to get payment stats: ${response.status}`);
|
1079
|
-
}
|
1080
|
-
return await response.json();
|
1081
|
-
} catch (error) {
|
1082
|
-
console.error("Get merchant payment stats error:", error);
|
1083
|
-
throw error;
|
1084
|
-
}
|
1085
|
-
};
|
1086
|
-
const getSupportedCurrencies = async () => {
|
1087
|
-
try {
|
1088
|
-
const response = await fetch(`${apiConfig.apiUrl}/api/payments/currencies`, {
|
1089
|
-
method: "GET",
|
1090
|
-
headers: getHeaders()
|
1091
|
-
});
|
1092
|
-
if (!response.ok) {
|
1093
|
-
const errorData = await response.json();
|
1094
|
-
throw new Error(errorData.error || `Failed to get currencies: ${response.status}`);
|
1095
|
-
}
|
1096
|
-
return await response.json();
|
1097
|
-
} catch (error) {
|
1098
|
-
console.error("Get supported currencies error:", error);
|
1099
|
-
return {
|
1100
|
-
currencies: [
|
1101
|
-
{ id: "USDT", name: "Tether USD", network: "ethereum" },
|
1102
|
-
{ id: "USDC", name: "USD Coin", network: "ethereum" },
|
1103
|
-
{ id: "BNB", name: "Binance Coin", network: "binance" },
|
1104
|
-
{ id: "SOL", name: "Solana", network: "solana" },
|
1105
|
-
{ id: "USDC_SOL", name: "USD Coin (Solana)", network: "solana" }
|
1106
|
-
]
|
1107
|
-
};
|
1108
|
-
}
|
1109
|
-
};
|
1110
1070
|
const CoinleyContext = createContext();
|
1111
1071
|
const useCoinley = () => useContext(CoinleyContext);
|
1112
1072
|
const CoinleyProvider = ({
|
@@ -1146,163 +1106,51 @@ const CoinleyProvider = ({
|
|
1146
1106
|
};
|
1147
1107
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(CoinleyContext.Provider, { value, children });
|
1148
1108
|
};
|
1149
|
-
const
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
try {
|
1169
|
-
const accounts = await window.ethereum.request({ method: "eth_accounts" });
|
1170
|
-
return accounts;
|
1171
|
-
} catch (error) {
|
1172
|
-
console.error("Error getting accounts:", error);
|
1173
|
-
throw error;
|
1174
|
-
}
|
1175
|
-
};
|
1176
|
-
const getChainId = async () => {
|
1177
|
-
if (!isMetaMaskInstalled()) {
|
1178
|
-
throw new Error("MetaMask is not installed");
|
1179
|
-
}
|
1180
|
-
try {
|
1181
|
-
const chainId = await window.ethereum.request({ method: "eth_chainId" });
|
1182
|
-
return chainId;
|
1183
|
-
} catch (error) {
|
1184
|
-
console.error("Error getting chain ID:", error);
|
1185
|
-
throw error;
|
1186
|
-
}
|
1187
|
-
};
|
1188
|
-
const sendTransaction = async (txParams) => {
|
1189
|
-
if (!isMetaMaskInstalled()) {
|
1190
|
-
throw new Error("MetaMask is not installed");
|
1191
|
-
}
|
1192
|
-
try {
|
1193
|
-
const txHash = await window.ethereum.request({
|
1194
|
-
method: "eth_sendTransaction",
|
1195
|
-
params: [txParams]
|
1196
|
-
});
|
1197
|
-
return txHash;
|
1198
|
-
} catch (error) {
|
1199
|
-
console.error("Error sending transaction:", error);
|
1200
|
-
throw error;
|
1201
|
-
}
|
1202
|
-
};
|
1203
|
-
const sendToken = async (tokenAddress, toAddress, amount) => {
|
1204
|
-
if (!isMetaMaskInstalled()) {
|
1205
|
-
throw new Error("MetaMask is not installed");
|
1206
|
-
}
|
1207
|
-
try {
|
1208
|
-
const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
|
1209
|
-
const fromAddress = accounts[0];
|
1210
|
-
const transferFunctionSignature = "0xa9059cbb";
|
1211
|
-
const paddedToAddress = toAddress.slice(2).padStart(64, "0");
|
1212
|
-
const paddedAmount = amount.toString(16).padStart(64, "0");
|
1213
|
-
const data = `${transferFunctionSignature}${paddedToAddress}${paddedAmount}`;
|
1214
|
-
const txParams = {
|
1215
|
-
from: fromAddress,
|
1216
|
-
to: tokenAddress,
|
1217
|
-
data
|
1218
|
-
};
|
1219
|
-
const txHash = await window.ethereum.request({
|
1220
|
-
method: "eth_sendTransaction",
|
1221
|
-
params: [txParams]
|
1222
|
-
});
|
1223
|
-
return txHash;
|
1224
|
-
} catch (error) {
|
1225
|
-
console.error("Error sending token:", error);
|
1226
|
-
throw error;
|
1227
|
-
}
|
1228
|
-
};
|
1229
|
-
const isWalletConnected = async () => {
|
1230
|
-
try {
|
1231
|
-
const accounts = await getAccounts();
|
1232
|
-
return accounts.length > 0;
|
1233
|
-
} catch (error) {
|
1234
|
-
return false;
|
1235
|
-
}
|
1236
|
-
};
|
1237
|
-
const getNetworkName = (chainId) => {
|
1238
|
-
const networks = {
|
1239
|
-
"0x1": "Ethereum Mainnet",
|
1240
|
-
"0x3": "Ropsten Testnet",
|
1241
|
-
"0x4": "Rinkeby Testnet",
|
1242
|
-
"0x5": "Goerli Testnet",
|
1243
|
-
"0x2a": "Kovan Testnet",
|
1244
|
-
"0x38": "Binance Smart Chain",
|
1245
|
-
"0x89": "Polygon",
|
1246
|
-
"0xa86a": "Avalanche"
|
1247
|
-
};
|
1248
|
-
return networks[chainId] || `Unknown Network (${chainId})`;
|
1249
|
-
};
|
1250
|
-
const getTokenBalance = async (tokenAddress, userAddress) => {
|
1251
|
-
if (!isMetaMaskInstalled()) {
|
1252
|
-
throw new Error("MetaMask is not installed");
|
1253
|
-
}
|
1254
|
-
try {
|
1255
|
-
const balanceOfSignature = "0x70a08231";
|
1256
|
-
const paddedAddress = userAddress.slice(2).padStart(64, "0");
|
1257
|
-
const data = `${balanceOfSignature}${paddedAddress}`;
|
1258
|
-
const balance = await window.ethereum.request({
|
1259
|
-
method: "eth_call",
|
1260
|
-
params: [
|
1261
|
-
{
|
1262
|
-
to: tokenAddress,
|
1263
|
-
data
|
1264
|
-
},
|
1265
|
-
"latest"
|
1109
|
+
const QRCode = ({ walletAddress, amount, currency, theme = "light" }) => {
|
1110
|
+
const qrDisplay = /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
1111
|
+
"div",
|
1112
|
+
{
|
1113
|
+
style: {
|
1114
|
+
width: "200px",
|
1115
|
+
height: "200px",
|
1116
|
+
backgroundColor: theme === "dark" ? "#374151" : "#f3f4f6",
|
1117
|
+
display: "flex",
|
1118
|
+
alignItems: "center",
|
1119
|
+
justifyContent: "center",
|
1120
|
+
color: theme === "dark" ? "white" : "black",
|
1121
|
+
fontWeight: "bold",
|
1122
|
+
border: `1px solid ${theme === "dark" ? "#4b5563" : "#e5e7eb"}`,
|
1123
|
+
margin: "0 auto"
|
1124
|
+
},
|
1125
|
+
children: [
|
1126
|
+
currency,
|
1127
|
+
" Payment QR"
|
1266
1128
|
]
|
1267
|
-
}
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
}
|
1274
|
-
const TOKEN_ADDRESSES = {
|
1275
|
-
USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
1276
|
-
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
1277
|
-
DAI: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
|
1278
|
-
WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
1279
|
-
WBTC: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
|
1280
|
-
};
|
1281
|
-
const QRCode$1 = ({ walletAddress, amount, currency, theme = "light" }) => {
|
1282
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center", children: [
|
1283
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-white"} mb-3`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { width: "200px", height: "200px", backgroundColor: "#f0f0f0", display: "flex", alignItems: "center", justifyContent: "center" }, children: [
|
1284
|
-
"QR Code: ",
|
1285
|
-
currency
|
1286
|
-
] }) }),
|
1287
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center text-sm", children: "Scan with your wallet app to pay" }),
|
1288
|
-
walletAddress && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 w-full", children: [
|
1289
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs mb-1", children: [
|
1129
|
+
}
|
1130
|
+
);
|
1131
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1132
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: theme === "dark" ? "bg-gray-700" : "bg-white", children: qrDisplay }),
|
1133
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { textAlign: "center", marginTop: "12px", fontSize: "14px" }, children: "Scan with your wallet app to pay" }),
|
1134
|
+
walletAddress && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { marginTop: "12px" }, children: [
|
1135
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { fontSize: "12px", marginBottom: "4px" }, children: [
|
1290
1136
|
"Send ",
|
1291
1137
|
amount,
|
1292
1138
|
" ",
|
1293
1139
|
currency,
|
1294
1140
|
" to:"
|
1295
1141
|
] }),
|
1296
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", {
|
1142
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: {
|
1143
|
+
fontSize: "12px",
|
1144
|
+
fontFamily: "monospace",
|
1145
|
+
padding: "8px",
|
1146
|
+
backgroundColor: theme === "dark" ? "#1f2937" : "#f3f4f6",
|
1147
|
+
borderRadius: "4px",
|
1148
|
+
overflowWrap: "break-word"
|
1149
|
+
}, children: walletAddress })
|
1297
1150
|
] })
|
1298
1151
|
] });
|
1299
1152
|
};
|
1300
|
-
const
|
1301
|
-
__proto__: null,
|
1302
|
-
default: QRCode$1
|
1303
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
1304
|
-
const PaymentStatus = ({ status, theme = "light", message }) => {
|
1305
|
-
console.log("PaymentStatus render:", { status, message });
|
1153
|
+
const PaymentStatus = ({ status, message, theme = "light" }) => {
|
1306
1154
|
const renderIcon = () => {
|
1307
1155
|
switch (status) {
|
1308
1156
|
case "processing":
|
@@ -1370,7 +1218,6 @@ const PaymentStatus = ({ status, theme = "light", message }) => {
|
|
1370
1218
|
] });
|
1371
1219
|
};
|
1372
1220
|
const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
|
1373
|
-
console.log("PaymentMethods render:", { selected });
|
1374
1221
|
const paymentMethods = [
|
1375
1222
|
{
|
1376
1223
|
id: "USDT",
|
@@ -1395,16 +1242,9 @@ const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
|
|
1395
1242
|
name: "SOL",
|
1396
1243
|
description: "Solana",
|
1397
1244
|
logo: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiI+PGcgZmlsbD0ibm9uZSI+PGNpcmNsZSBjeD0iMTYiIGN5PSIxNiIgcj0iMTYiIGZpbGw9IiM0MDNCODIiLz48cGF0aCBkPSJNMTIuNDQgMTAuMmE1NDUuNzYgNTQ1Ljc2IDAgMDE4LjMyLTQuNjZjLjE0LS4wOC4zIDAgLjMuMTlWOC42cy0uMDEuMTQtLjExLjJDMTkuNDQgOS42NyAxOCAyMC4wOCAxOCAyMC4wOGwtLjA0LjEzYy0uMS4zNC0uMzYuNjEtLjcuNzVsLS40Mi4xN2MtLjEzLjA1LS41OS4xNS0uNTkuMTUtLjE5LjA1LS4zNy0uMTMtLjI2LS4zbDYuNDUtMTJhLjM0LjM0IDAgMDAtLjAzLS4zNy4zMi4zMiAwIDAwLS4zMi0uMDlsLTkuOS41LjAxLjI5elptOS4wNiA0LjA0Yy4wOC0uMDkuMjMtLjA2LjMuMDUuMzYuNDQuMzYgMS4wNiAwIDEuNS0uMzcuNDQtMTAuMzcgMTIuMDQtMTAuMzcgMTIuMDRsLS4xMy4xNmMtLjEzLjE1LS4zMi4yNS0uNTIuMjlsLS4yOC4wNGMtLjI0LjAzLS41My0uMDUtLjY4LS4yM0w2LjU2IDI0Yy0uMTQtLjE1LS4wNS0uNC4xNS0uNDNsMTMuODMtOC4yMWMuMzgtLjIzLjY1LS42LjcyLTEuMDRsLjA4LS4zYy4wMy0uMTEuMS0uMi4xNi0uMjh6TTYuNTYgMTIuNTV2LTEuMnMuMDQtLjE3LjEzLS4yM2MuMDktLjA2LjIzLTEuMDQuMjMtMS4wNC4wMy0uMjIuMTYtLjQyLjM2LS41M2wuNC0uMjJjLjA4LS4wNC41My0uNDUuNTMtLjQ1LjEzLS4xLjMtLjAzLjM0LjEzIDAgMCAxLjg5IDkuMDEgMS44OSA5LjAxLjA1LjMtLjE3LjU2LS40NC42OWwtLjQ4LjI0Yy0uMy4xNS0xMS40NSA1LjgtMTEuNDUgNS44LS4yMi4xMi0uNTctLjA0LS41Ny0uMzJWMTJjLS4wMi0uMzUuMjQtLjY2LjU3LS43aDguNDRhLjY3LjY3IDAgMDAuNjEtLjM4di0uMDJjLjA3LS4xNi4yNC0uMjQuNC0uMmwuMjUuMDRjLjE0LjAyLjMuMTguMy4xOHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+"
|
1398
|
-
},
|
1399
|
-
{
|
1400
|
-
id: "USDC_SOL",
|
1401
|
-
name: "USDC (Solana)",
|
1402
|
-
description: "USD Coin on Solana",
|
1403
|
-
logo: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGN4PSIxNiIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzJCNzVFRCIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0yMS4yMDkgOS43MzlsLTIuOTQxIDIuOTQxYTMuMTMyIDMuMTMyIDAgMDAtNC41MzYgMGwtMi45NDItMi45NDFhNy42MjMgNy42MjMgMCAwMTEwLjQxOSAwek0xMC43OTEgMjIuMjYxbDIuOTQxLTIuOTQxYTMuMTMyIDMuMTMyIDAgMDA0LjUzNiAwbDIuOTQyIDIuOTQxYTcuNjIzIDcuNjIzIDAgMDEtMTAuNDE5IDB6bTExLjU3NS00LjI2MWgtNC4xNTNhMy4xMzMgMy4xMzMgMCAwMDAtNC41MzdoNC4xNTNhNy42MjEgNy42MjEgMCAwMTAgNC41Mzd6bS0xMy43OTMtNC41MzdoNC4xNTNhMy4xMzMgMy4xMzMgMCAwMDAgNC41MzdIOS42ODZhNy42MjEgNy42MjEgMCAwMTAtNC41Mzd6Ii8+PC9nPjwvc3ZnPg=="
|
1404
1245
|
}
|
1405
1246
|
];
|
1406
1247
|
const handleSelectPaymentMethod = (id) => {
|
1407
|
-
console.log("Method selected:", id);
|
1408
1248
|
onSelect(id);
|
1409
1249
|
};
|
1410
1250
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
@@ -1443,24 +1283,23 @@ const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
|
|
1443
1283
|
)) })
|
1444
1284
|
] });
|
1445
1285
|
};
|
1446
|
-
const
|
1447
|
-
const
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
}) => {
|
1286
|
+
const CoinleyModal = (props) => {
|
1287
|
+
const {
|
1288
|
+
isOpen,
|
1289
|
+
onClose,
|
1290
|
+
payment,
|
1291
|
+
paymentStatus,
|
1292
|
+
selectedCurrency,
|
1293
|
+
onCurrencySelect,
|
1294
|
+
onPayment,
|
1295
|
+
error,
|
1296
|
+
theme = "light",
|
1297
|
+
merchantName,
|
1298
|
+
transactionHash,
|
1299
|
+
walletConnected,
|
1300
|
+
onConnectWallet,
|
1301
|
+
testMode = false
|
1302
|
+
} = props;
|
1464
1303
|
const [step, setStep] = useState("select-currency");
|
1465
1304
|
const [isMetaMaskAvailable, setIsMetaMaskAvailable] = useState(false);
|
1466
1305
|
const [paymentMethod, setPaymentMethod] = useState("wallet");
|
@@ -1480,263 +1319,17 @@ const CoinleyModal = ({
|
|
1480
1319
|
setStep("select-currency");
|
1481
1320
|
}
|
1482
1321
|
}, [paymentStatus, payment]);
|
1483
|
-
const handleCurrencySelect = (currency) => {
|
1484
|
-
onCurrencySelect(currency);
|
1485
|
-
setStep("confirm");
|
1486
|
-
};
|
1487
|
-
const handlePaymentConfirm = () => {
|
1488
|
-
onPayment(paymentMethod === "qrcode");
|
1489
|
-
};
|
1490
|
-
const handleBack = () => {
|
1491
|
-
if (step === "confirm") {
|
1492
|
-
setStep("select-currency");
|
1493
|
-
}
|
1494
|
-
};
|
1495
|
-
const handleClose = () => {
|
1496
|
-
onClose();
|
1497
|
-
};
|
1498
|
-
const formatAmount = (amount) => {
|
1499
|
-
return parseFloat(amount).toFixed(2);
|
1500
|
-
};
|
1501
|
-
const formatTransactionHash = (hash) => {
|
1502
|
-
if (!hash)
|
1503
|
-
return "";
|
1504
|
-
if (hash.length <= 14)
|
1505
|
-
return hash;
|
1506
|
-
return `${hash.slice(0, 8)}...${hash.slice(-6)}`;
|
1507
|
-
};
|
1508
|
-
const togglePaymentMethod = (method) => {
|
1509
|
-
setPaymentMethod(method);
|
1510
|
-
};
|
1511
|
-
const modalBaseClasses = `fixed inset-0 z-50 overflow-y-auto ${theme === "dark" ? "bg-gray-900/75" : "bg-black/50"}`;
|
1512
|
-
const modalContentClasses = `relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl ${theme === "dark" ? "bg-gray-800 text-white" : "bg-white text-gray-800"}`;
|
1513
|
-
const headerClasses = `text-xl font-bold mb-4 ${theme === "dark" ? "text-white" : "text-gray-900"}`;
|
1514
|
-
const buttonPrimaryClasses = `w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${theme === "dark" ? "bg-blue-600 hover:bg-blue-700 text-white focus:ring-blue-500" : "bg-blue-500 hover:bg-blue-600 text-white focus:ring-blue-500"}`;
|
1515
|
-
const buttonSecondaryClasses = `w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${theme === "dark" ? "bg-gray-700 hover:bg-gray-600 text-white focus:ring-gray-500" : "bg-gray-200 hover:bg-gray-300 text-gray-800 focus:ring-gray-500"}`;
|
1516
|
-
const tabButtonClasses = `py-2 px-4 text-sm font-medium focus:outline-none transition-colors`;
|
1517
|
-
const activeTabClasses = `${theme === "dark" ? "bg-gray-700 text-white" : "bg-gray-100 text-gray-800"} rounded-t-md`;
|
1518
|
-
const inactiveTabClasses = `${theme === "dark" ? "text-gray-400 hover:text-gray-300" : "text-gray-500 hover:text-gray-700"}`;
|
1519
1322
|
if (!isOpen)
|
1520
1323
|
return null;
|
1521
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className:
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
onClick: handleClose,
|
1531
|
-
className: `text-gray-500 hover:text-gray-700 focus:outline-none ${theme === "dark" ? "text-gray-400 hover:text-gray-300" : ""}`,
|
1532
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
1533
|
-
}
|
1534
|
-
)
|
1535
|
-
] }),
|
1536
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [
|
1537
|
-
payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `mb-6 p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
|
1538
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: merchantName }),
|
1539
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mt-2", children: [
|
1540
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `font-medium ${theme === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Amount:" }),
|
1541
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold text-xl", children: [
|
1542
|
-
"$",
|
1543
|
-
formatAmount(payment.totalAmount || payment.amount)
|
1544
|
-
] })
|
1545
|
-
] }),
|
1546
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: [
|
1547
|
-
"Payment ID: ",
|
1548
|
-
payment.id.slice(0, 8),
|
1549
|
-
"..."
|
1550
|
-
] }) })
|
1551
|
-
] }),
|
1552
|
-
step === "select-currency" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1553
|
-
PaymentMethods,
|
1554
|
-
{
|
1555
|
-
onSelect: handleCurrencySelect,
|
1556
|
-
selected: selectedCurrency,
|
1557
|
-
theme
|
1558
|
-
}
|
1559
|
-
),
|
1560
|
-
step === "confirm" && payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1561
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
|
1562
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-lg font-medium mb-2 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Payment Details" }),
|
1563
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
|
1564
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
|
1565
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Currency:" }),
|
1566
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency })
|
1567
|
-
] }),
|
1568
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
|
1569
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Network:" }),
|
1570
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "Solana" : "Ethereum" })
|
1571
|
-
] }),
|
1572
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
|
1573
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Fee:" }),
|
1574
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: "1.75%" })
|
1575
|
-
] })
|
1576
|
-
] })
|
1577
|
-
] }),
|
1578
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex border-b border-gray-200", children: [
|
1579
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1580
|
-
"button",
|
1581
|
-
{
|
1582
|
-
onClick: () => togglePaymentMethod("wallet"),
|
1583
|
-
className: `${tabButtonClasses} ${paymentMethod === "wallet" ? activeTabClasses : inactiveTabClasses}`,
|
1584
|
-
children: "Connect Wallet"
|
1585
|
-
}
|
1586
|
-
),
|
1587
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1588
|
-
"button",
|
1589
|
-
{
|
1590
|
-
onClick: () => togglePaymentMethod("qrcode"),
|
1591
|
-
className: `${tabButtonClasses} ${paymentMethod === "qrcode" ? activeTabClasses : inactiveTabClasses}`,
|
1592
|
-
children: "QR Code"
|
1593
|
-
}
|
1594
|
-
)
|
1595
|
-
] }) }),
|
1596
|
-
testMode ? (
|
1597
|
-
// Test mode payment option
|
1598
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
1599
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-blue-500 rounded-full p-2 mr-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-white", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) }),
|
1600
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1601
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Test Mode Payment" }),
|
1602
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: 'Click "Pay Now" to simulate a successful payment' })
|
1603
|
-
] })
|
1604
|
-
] }) })
|
1605
|
-
) : paymentMethod === "qrcode" ? (
|
1606
|
-
// QR Code payment option
|
1607
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1608
|
-
QRCode,
|
1609
|
-
{
|
1610
|
-
walletAddress: payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
1611
|
-
amount: payment.totalAmount || payment.amount,
|
1612
|
-
currency: selectedCurrency,
|
1613
|
-
theme
|
1614
|
-
}
|
1615
|
-
) })
|
1616
|
-
) : isMetaMaskAvailable ? (
|
1617
|
-
// MetaMask available option
|
1618
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: [
|
1619
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
1620
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1621
|
-
"img",
|
1622
|
-
{
|
1623
|
-
src: "https://metamask.io/images/metamask-fox.svg",
|
1624
|
-
alt: "MetaMask",
|
1625
|
-
className: "w-8 h-8 mr-2"
|
1626
|
-
}
|
1627
|
-
),
|
1628
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1629
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Pay with MetaMask" }),
|
1630
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: walletConnected ? "Your wallet is connected. Click 'Pay Now' to proceed." : "Click 'Connect Wallet' to proceed with payment." })
|
1631
|
-
] })
|
1632
|
-
] }),
|
1633
|
-
!walletConnected && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1634
|
-
"button",
|
1635
|
-
{
|
1636
|
-
onClick: onConnectWallet,
|
1637
|
-
className: `mt-3 ${buttonPrimaryClasses}`,
|
1638
|
-
children: "Connect Wallet"
|
1639
|
-
}
|
1640
|
-
)
|
1641
|
-
] })
|
1642
|
-
) : (
|
1643
|
-
// MetaMask not available warning
|
1644
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-yellow-900/20" : "bg-yellow-50"}`, children: [
|
1645
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
1646
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-yellow-500 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.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" }) }),
|
1647
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1648
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "MetaMask Not Detected" }),
|
1649
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Please install MetaMask extension to make payments" })
|
1650
|
-
] })
|
1651
|
-
] }),
|
1652
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1653
|
-
"a",
|
1654
|
-
{
|
1655
|
-
href: "https://metamask.io/download/",
|
1656
|
-
target: "_blank",
|
1657
|
-
rel: "noopener noreferrer",
|
1658
|
-
className: `block mt-3 text-center ${buttonPrimaryClasses}`,
|
1659
|
-
children: "Install MetaMask"
|
1660
|
-
}
|
1661
|
-
)
|
1662
|
-
] })
|
1663
|
-
),
|
1664
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
|
1665
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1666
|
-
"button",
|
1667
|
-
{
|
1668
|
-
type: "button",
|
1669
|
-
onClick: handleBack,
|
1670
|
-
className: buttonSecondaryClasses,
|
1671
|
-
children: "Back"
|
1672
|
-
}
|
1673
|
-
),
|
1674
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1675
|
-
"button",
|
1676
|
-
{
|
1677
|
-
type: "button",
|
1678
|
-
onClick: handlePaymentConfirm,
|
1679
|
-
className: buttonPrimaryClasses,
|
1680
|
-
disabled: !testMode && paymentMethod === "wallet" && isMetaMaskAvailable && !walletConnected,
|
1681
|
-
children: "Pay Now"
|
1682
|
-
}
|
1683
|
-
)
|
1684
|
-
] })
|
1685
|
-
] }),
|
1686
|
-
step === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1687
|
-
PaymentStatus,
|
1688
|
-
{
|
1689
|
-
status: "processing",
|
1690
|
-
theme,
|
1691
|
-
message: "Processing your payment..."
|
1692
|
-
}
|
1693
|
-
),
|
1694
|
-
step === "success" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1695
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1696
|
-
PaymentStatus,
|
1697
|
-
{
|
1698
|
-
status: "success",
|
1699
|
-
theme,
|
1700
|
-
message: "Payment successful!"
|
1701
|
-
}
|
1702
|
-
),
|
1703
|
-
transactionHash && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `mt-4 p-3 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
|
1704
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme === "dark" ? "text-gray-300" : "text-gray-600"} mb-1`, children: "Transaction Hash:" }),
|
1705
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm font-mono break-all ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: formatTransactionHash(transactionHash) }),
|
1706
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1707
|
-
"a",
|
1708
|
-
{
|
1709
|
-
href: `https://etherscan.io/tx/${transactionHash}`,
|
1710
|
-
target: "_blank",
|
1711
|
-
rel: "noopener noreferrer",
|
1712
|
-
className: `text-xs ${theme === "dark" ? "text-blue-400" : "text-blue-600"} mt-2 inline-block`,
|
1713
|
-
children: "View on Etherscan →"
|
1714
|
-
}
|
1715
|
-
)
|
1716
|
-
] })
|
1717
|
-
] }),
|
1718
|
-
step === "error" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
1719
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1720
|
-
PaymentStatus,
|
1721
|
-
{
|
1722
|
-
status: "error",
|
1723
|
-
theme,
|
1724
|
-
message: error || "An error occurred while processing your payment."
|
1725
|
-
}
|
1726
|
-
),
|
1727
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
1728
|
-
"button",
|
1729
|
-
{
|
1730
|
-
type: "button",
|
1731
|
-
onClick: handleBack,
|
1732
|
-
className: `mt-4 ${buttonSecondaryClasses}`,
|
1733
|
-
children: "Try Again"
|
1734
|
-
}
|
1735
|
-
)
|
1736
|
-
] })
|
1737
|
-
] }),
|
1738
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-center text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Powered by Coinley - Secure Cryptocurrency Payments" }) })
|
1739
|
-
] }) }) });
|
1324
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: theme === "dark" ? "bg-gray-900/75" : "bg-black/50", style: { position: "fixed", inset: 0, zIndex: 50 }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { minHeight: "100vh", display: "flex", alignItems: "center", justifyContent: "center", padding: "16px" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: theme === "dark" ? "bg-gray-800 text-white" : "bg-white text-gray-800", style: { position: "relative", padding: "24px", width: "100%", maxWidth: "28rem", borderRadius: "8px", boxShadow: "0 20px 25px -5px rgb(0 0 0 / 0.1)" }, children: step === "confirm" && payment && paymentMethod === "qrcode" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
1325
|
+
QRCode,
|
1326
|
+
{
|
1327
|
+
walletAddress: payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
|
1328
|
+
amount: payment.totalAmount || payment.amount,
|
1329
|
+
currency: selectedCurrency,
|
1330
|
+
theme
|
1331
|
+
}
|
1332
|
+
) }) }) }) });
|
1740
1333
|
};
|
1741
1334
|
const CoinleyCheckout = forwardRef(({
|
1742
1335
|
apiKey,
|
@@ -1781,32 +1374,34 @@ const CoinleyCheckout = forwardRef(({
|
|
1781
1374
|
}
|
1782
1375
|
};
|
1783
1376
|
useEffect(() => {
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1377
|
+
if (typeof window !== "undefined") {
|
1378
|
+
const checkWalletConnection = async () => {
|
1379
|
+
if (isMetaMaskInstalled()) {
|
1380
|
+
try {
|
1381
|
+
const accounts = await window.ethereum.request({ method: "eth_accounts" });
|
1382
|
+
setWalletConnected(accounts && accounts.length > 0);
|
1383
|
+
} catch (err) {
|
1384
|
+
log("Error checking wallet connection:", err);
|
1385
|
+
setWalletConnected(false);
|
1386
|
+
}
|
1387
|
+
} else {
|
1791
1388
|
setWalletConnected(false);
|
1792
1389
|
}
|
1793
|
-
}
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
checkWalletConnection();
|
1798
|
-
}, []);
|
1390
|
+
};
|
1391
|
+
checkWalletConnection();
|
1392
|
+
}
|
1393
|
+
}, [effectiveDebug]);
|
1799
1394
|
useEffect(() => {
|
1800
|
-
const handleAccountsChanged = (accounts) => {
|
1801
|
-
setWalletConnected(accounts.length > 0);
|
1802
|
-
};
|
1803
1395
|
if (typeof window !== "undefined" && window.ethereum) {
|
1396
|
+
const handleAccountsChanged = (accounts) => {
|
1397
|
+
setWalletConnected(accounts.length > 0);
|
1398
|
+
};
|
1804
1399
|
window.ethereum.on("accountsChanged", handleAccountsChanged);
|
1400
|
+
return () => {
|
1401
|
+
window.ethereum.removeListener("accountsChanged", handleAccountsChanged);
|
1402
|
+
};
|
1805
1403
|
}
|
1806
1404
|
return () => {
|
1807
|
-
if (typeof window !== "undefined" && window.ethereum) {
|
1808
|
-
window.ethereum.removeListener("accountsChanged", handleAccountsChanged);
|
1809
|
-
}
|
1810
1405
|
};
|
1811
1406
|
}, []);
|
1812
1407
|
const handleOpen = async (paymentDetails) => {
|
@@ -1952,14 +1547,13 @@ const CoinleyCheckout = forwardRef(({
|
|
1952
1547
|
) });
|
1953
1548
|
});
|
1954
1549
|
CoinleyCheckout.displayName = "CoinleyCheckout";
|
1955
|
-
const styles = "";
|
1956
1550
|
const DEFAULT_CONFIG = {
|
1957
1551
|
apiUrl: "https://coinleyserver-production.up.railway.app",
|
1958
1552
|
debug: false,
|
1959
1553
|
testMode: false,
|
1960
1554
|
theme: "light"
|
1961
1555
|
};
|
1962
|
-
const VERSION = "1.0.
|
1556
|
+
const VERSION = "1.0.7";
|
1963
1557
|
export {
|
1964
1558
|
CoinleyCheckout,
|
1965
1559
|
CoinleyModal,
|
@@ -1967,24 +1561,13 @@ export {
|
|
1967
1561
|
DEFAULT_CONFIG,
|
1968
1562
|
PaymentMethods,
|
1969
1563
|
PaymentStatus,
|
1970
|
-
QRCode
|
1971
|
-
TOKEN_ADDRESSES,
|
1564
|
+
QRCode,
|
1972
1565
|
ThemeProvider,
|
1973
1566
|
VERSION,
|
1974
1567
|
connectWallet,
|
1975
1568
|
createPayment,
|
1976
|
-
getAccounts,
|
1977
|
-
getChainId,
|
1978
|
-
getMerchantPaymentStats,
|
1979
|
-
getMerchantPayments,
|
1980
|
-
getNetworkName,
|
1981
1569
|
getPayment,
|
1982
|
-
getSupportedCurrencies,
|
1983
|
-
getTokenBalance,
|
1984
1570
|
isMetaMaskInstalled,
|
1985
|
-
|
1986
|
-
processPayment,
|
1987
|
-
sendToken,
|
1988
|
-
sendTransaction
|
1571
|
+
processPayment
|
1989
1572
|
};
|
1990
1573
|
//# sourceMappingURL=coinley-checkout.es.js.map
|