coinley-checkout 0.1.9 → 0.2.1

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.
@@ -1110,109 +1110,30 @@ const QRCode = ({
1110
1110
  walletAddress,
1111
1111
  amount,
1112
1112
  currency,
1113
- theme = "light",
1114
- size = 200
1113
+ theme = "light"
1115
1114
  }) => {
1116
- const [qrCodeSvg, setQrCodeSvg] = useState("");
1117
- const getQRCodeData = () => {
1118
- if (!walletAddress)
1119
- return "";
1120
- const schemes = {
1121
- "USDT": "ethereum",
1122
- "USDC": "ethereum",
1123
- "BNB": "binance",
1124
- "SOL": "solana",
1125
- "USDC_SOL": "solana"
1126
- };
1127
- const scheme = schemes[currency] || "ethereum";
1128
- return `${scheme}:${walletAddress}?amount=${amount}&currency=${currency}`;
1129
- };
1130
- useEffect(() => {
1131
- const generateQRCode = async () => {
1132
- try {
1133
- const qrcode = await Promise.resolve().then(() => qrcodeGenerator);
1134
- const data = getQRCodeData();
1135
- if (data) {
1136
- const svg = qrcode.generateQR(data, size, theme === "dark");
1137
- setQrCodeSvg(svg);
1138
- }
1139
- } catch (error) {
1140
- console.error("Failed to generate QR code:", error);
1141
- setQrCodeSvg(generateFallbackQR());
1142
- }
1143
- };
1144
- generateQRCode();
1145
- }, [walletAddress, amount, currency, theme, size]);
1146
- const generateFallbackQR = () => {
1147
- const darkMode = theme === "dark";
1148
- const cellSize = Math.floor(size / 25);
1149
- const svgSize = size;
1150
- let svg = `
1151
- <svg
1152
- xmlns="http://www.w3.org/2000/svg"
1153
- width="${svgSize}"
1154
- height="${svgSize}"
1155
- viewBox="0 0 ${svgSize} ${svgSize}"
1156
- >
1157
- `;
1158
- svg += `<rect width="${svgSize}" height="${svgSize}" fill="${darkMode ? "#1f2937" : "white"}"/>`;
1159
- svg += `<rect x="0" y="0" width="${cellSize * 7}" height="${cellSize * 7}" fill="${darkMode ? "white" : "black"}"/>`;
1160
- svg += `<rect x="${cellSize}" y="${cellSize}" width="${cellSize * 5}" height="${cellSize * 5}" fill="${darkMode ? "#1f2937" : "white"}"/>`;
1161
- svg += `<rect x="${cellSize * 2}" y="${cellSize * 2}" width="${cellSize * 3}" height="${cellSize * 3}" fill="${darkMode ? "white" : "black"}"/>`;
1162
- svg += `<rect x="${svgSize - cellSize * 7}" y="0" width="${cellSize * 7}" height="${cellSize * 7}" fill="${darkMode ? "white" : "black"}"/>`;
1163
- svg += `<rect x="${svgSize - cellSize * 6}" y="${cellSize}" width="${cellSize * 5}" height="${cellSize * 5}" fill="${darkMode ? "#1f2937" : "white"}"/>`;
1164
- svg += `<rect x="${svgSize - cellSize * 5}" y="${cellSize * 2}" width="${cellSize * 3}" height="${cellSize * 3}" fill="${darkMode ? "white" : "black"}"/>`;
1165
- svg += `<rect x="0" y="${svgSize - cellSize * 7}" width="${cellSize * 7}" height="${cellSize * 7}" fill="${darkMode ? "white" : "black"}"/>`;
1166
- svg += `<rect x="${cellSize}" y="${svgSize - cellSize * 6}" width="${cellSize * 5}" height="${cellSize * 5}" fill="${darkMode ? "#1f2937" : "white"}"/>`;
1167
- svg += `<rect x="${cellSize * 2}" y="${svgSize - cellSize * 5}" width="${cellSize * 3}" height="${cellSize * 3}" fill="${darkMode ? "white" : "black"}"/>`;
1168
- for (let i = 0; i < 10; i++) {
1169
- for (let j = 0; j < 10; j++) {
1170
- if (i < 3 && j < 3 || i < 3 && j > 6 || i > 6 && j < 3)
1171
- continue;
1172
- if (Math.random() > 0.5) {
1173
- const x = cellSize * (i * 2 + 3);
1174
- const y = cellSize * (j * 2 + 3);
1175
- svg += `<rect x="${x}" y="${y}" width="${cellSize * 2}" height="${cellSize * 2}" fill="${darkMode ? "white" : "black"}"/>`;
1176
- }
1177
- }
1178
- }
1179
- svg += "</svg>";
1180
- return svg;
1181
- };
1115
+ const qrCodeUrl = `https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=${encodeURIComponent(`${currency}:${walletAddress}?amount=${amount}`)}&choe=UTF-8`;
1182
1116
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center", children: [
1183
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1184
- "div",
1117
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg bg-white mb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1118
+ "img",
1185
1119
  {
1186
- className: `p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-white"} mb-3`,
1187
- dangerouslySetInnerHTML: { __html: qrCodeSvg }
1120
+ src: qrCodeUrl,
1121
+ alt: `QR Code for ${currency} payment`,
1122
+ width: "200",
1123
+ height: "200"
1188
1124
  }
1189
- ),
1190
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-center text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Scan with your wallet app to pay" }),
1191
- walletAddress && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 w-full", children: [
1192
- /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: `text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"} mb-1`, children: [
1125
+ ) }),
1126
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center text-sm text-gray-700", children: "Scan with your wallet app to pay" }),
1127
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 w-full", children: [
1128
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 mb-1", children: [
1193
1129
  "Send ",
1194
1130
  amount,
1195
1131
  " ",
1196
1132
  currency,
1197
1133
  " to:"
1198
1134
  ] }),
1199
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-xs font-mono p-2 rounded overflow-auto break-all ${theme === "dark" ? "bg-gray-800 text-gray-300" : "bg-gray-100 text-gray-700"}`, children: walletAddress })
1200
- ] }),
1201
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-3 rounded ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
1202
- /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: `text-sm font-medium mb-2 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Payment Instructions" }),
1203
- /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: `text-xs space-y-2 ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: [
1204
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "1. Open your crypto wallet app" }),
1205
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "2. Scan the QR code above" }),
1206
- /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
1207
- "3. Confirm the payment amount (",
1208
- amount,
1209
- " ",
1210
- currency,
1211
- ")"
1212
- ] }),
1213
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: '4. Click "Pay Now" button below after sending the payment' })
1214
- ] })
1215
- ] }) })
1135
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs font-mono p-2 rounded overflow-auto break-all bg-gray-100 text-gray-700", children: walletAddress })
1136
+ ] })
1216
1137
  ] });
1217
1138
  };
1218
1139
  const PaymentStatus = ({ status, message, theme = "light" }) => {
@@ -1348,6 +1269,7 @@ const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
1348
1269
  )) })
1349
1270
  ] });
1350
1271
  };
1272
+ const Logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAcCAYAAACqAXueAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAiaSURBVHgB7VrdddNIFL4zNuDAw2orQDQATgUoUABQAU4FOGcLiF0BpoI4FcQ0QLQVxAHOvqLtwDyQOBBr9rszI2n058jeBEhOvnNkS6M7o7m6c39HRA3Qf/bxLR+l9uDIR/sXHD26trjTJeoMiO6/pEuCEBuH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UetS5AC7RMbe6wqXTq8CnWpx4s4TRGVsdU3Wyf0rKke5PpWFG5liiFmpqPL0KjTSsxrr59ngYsG9pfny1WJu951z8HG85PozNRIug1OmUu0iKgqXUfyiw+e/IhFv/dkNhTKEabebFK/0hFvtNYR8wrsym27FpgBmaqjUvc1yznvaNxv3VJmzcrutRvVWqEFfEU5HXIlbwifZat1WtXATaJPv9MlyXxc5Ew2zOyh/d6Xe8SYDf+VBZo/VXh/jATa5jhd/JqVK+0UHm6gJzPea2qL3NB0NXEBwD6JmwtE+yx6cVzfdR/5V4JhBgt/YM/O9GzbkM2fubfk2KlLl94MV+XmRW2Ga77B83RQnKyX7TAcC5WBhzKesyaDXO1HWfIe0MjSDYaGNmkEzGdG1QTGaP7m4S2GDxsYJURVlQcDxAIHUQ+1z48V+Jhzp+OSFEWy8mECwdgXlfbYNsh6tF1Xfoh7GslnN9Z0btZay8MmOFkw5YpR2MKW3BCNLO0O0HZqP78QfVYP/jx2mW5TAmcbZYTHxsYFYVNer2XfRyobjxWh1cT607T7d4qejPsrO0EzAgv0u/HH4OBeGaxPO94Q6plv8FECovJc8uTjKNvgPcUpIo0ZgmzUAAAAASUVORK5CYII=";
1351
1273
  const CoinleyModal = (props) => {
1352
1274
  const {
1353
1275
  isOpen,
@@ -1384,17 +1306,252 @@ const CoinleyModal = (props) => {
1384
1306
  setStep("select-currency");
1385
1307
  }
1386
1308
  }, [paymentStatus, payment]);
1309
+ const handleCurrencySelect = (currency) => {
1310
+ onCurrencySelect(currency);
1311
+ setStep("confirm");
1312
+ };
1313
+ const handlePaymentConfirm = () => {
1314
+ onPayment(paymentMethod === "qrcode");
1315
+ };
1316
+ const handleBack = () => {
1317
+ if (step === "confirm") {
1318
+ setStep("select-currency");
1319
+ }
1320
+ };
1321
+ const togglePaymentMethod = (method) => {
1322
+ setPaymentMethod(method);
1323
+ };
1324
+ const formatAmount = (amount) => {
1325
+ return parseFloat(amount).toFixed(2);
1326
+ };
1327
+ const formatTransactionHash = (hash) => {
1328
+ if (!hash)
1329
+ return "";
1330
+ if (hash.length <= 14)
1331
+ return hash;
1332
+ return `${hash.slice(0, 8)}...${hash.slice(-6)}`;
1333
+ };
1387
1334
  if (!isOpen)
1388
1335
  return null;
1389
- 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(
1390
- QRCode,
1391
- {
1392
- walletAddress: payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
1393
- amount: payment.totalAmount || payment.amount,
1394
- currency: selectedCurrency,
1395
- theme
1396
- }
1397
- ) }) }) }) });
1336
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "fixed inset-0 z-50 overflow-y-auto bg-black/50", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-h-screen items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800", children: [
1337
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mb-6", children: [
1338
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1339
+ /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: Logo, alt: "Coinley Logo", className: "h-8 mr-2" }),
1340
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-xl font-bold text-gray-900", children: "Coinley Pay" })
1341
+ ] }),
1342
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1343
+ "button",
1344
+ {
1345
+ onClick: onClose,
1346
+ className: "text-gray-500 hover:text-gray-700 focus:outline-none",
1347
+ 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" }) })
1348
+ }
1349
+ )
1350
+ ] }),
1351
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [
1352
+ payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6 p-4 rounded-lg bg-gray-100", children: [
1353
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: merchantName }),
1354
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mt-2", children: [
1355
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700", children: "Amount:" }),
1356
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold text-xl", children: [
1357
+ "$",
1358
+ formatAmount(payment.totalAmount || payment.amount)
1359
+ ] })
1360
+ ] }),
1361
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-500", children: [
1362
+ "Payment ID: ",
1363
+ payment.id ? payment.id.slice(0, 8) : "",
1364
+ "..."
1365
+ ] }) })
1366
+ ] }),
1367
+ step === "select-currency" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1368
+ PaymentMethods,
1369
+ {
1370
+ onSelect: handleCurrencySelect,
1371
+ selected: selectedCurrency,
1372
+ theme
1373
+ }
1374
+ ),
1375
+ step === "confirm" && payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1376
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-gray-100", children: [
1377
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium mb-2 text-gray-800", children: "Payment Details" }),
1378
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
1379
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1380
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Currency:" }),
1381
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency })
1382
+ ] }),
1383
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1384
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Network:" }),
1385
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "Solana" : "Ethereum" })
1386
+ ] }),
1387
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1388
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Fee:" }),
1389
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: "1.75%" })
1390
+ ] })
1391
+ ] })
1392
+ ] }),
1393
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex border-b border-gray-200", children: [
1394
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1395
+ "button",
1396
+ {
1397
+ onClick: () => togglePaymentMethod("wallet"),
1398
+ className: `py-2 px-4 text-sm font-medium ${paymentMethod === "wallet" ? "bg-gray-100 text-gray-800 rounded-t-md" : "text-gray-500 hover:text-gray-700"}`,
1399
+ children: "Connect Wallet"
1400
+ }
1401
+ ),
1402
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1403
+ "button",
1404
+ {
1405
+ onClick: () => togglePaymentMethod("qrcode"),
1406
+ className: `py-2 px-4 text-sm font-medium ${paymentMethod === "qrcode" ? "bg-gray-100 text-gray-800 rounded-t-md" : "text-gray-500 hover:text-gray-700"}`,
1407
+ children: "QR Code"
1408
+ }
1409
+ )
1410
+ ] }) }),
1411
+ testMode ? (
1412
+ // Test mode payment option
1413
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1414
+ /* @__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" }) }) }),
1415
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1416
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "Test Mode Payment" }),
1417
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: 'Click "Pay Now" to simulate a successful payment' })
1418
+ ] })
1419
+ ] }) })
1420
+ ) : paymentMethod === "qrcode" ? (
1421
+ // QR Code payment option
1422
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1423
+ QRCode,
1424
+ {
1425
+ walletAddress: payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
1426
+ amount: payment.totalAmount || payment.amount,
1427
+ currency: selectedCurrency,
1428
+ theme
1429
+ }
1430
+ ) })
1431
+ ) : isMetaMaskAvailable ? (
1432
+ // MetaMask available option
1433
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: [
1434
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1435
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1436
+ "img",
1437
+ {
1438
+ src: "https://metamask.io/images/metamask-fox.svg",
1439
+ alt: "MetaMask",
1440
+ className: "w-8 h-8 mr-2"
1441
+ }
1442
+ ),
1443
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1444
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "Pay with MetaMask" }),
1445
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: walletConnected ? "Your wallet is connected. Click 'Pay Now' to proceed." : "Click 'Connect Wallet' to proceed with payment." })
1446
+ ] })
1447
+ ] }),
1448
+ !walletConnected && /* @__PURE__ */ jsxRuntimeExports.jsx(
1449
+ "button",
1450
+ {
1451
+ onClick: onConnectWallet,
1452
+ className: "mt-3 w-full py-2 px-4 bg-blue-500 hover:bg-blue-600 text-white font-medium rounded-md",
1453
+ children: "Connect Wallet"
1454
+ }
1455
+ )
1456
+ ] })
1457
+ ) : (
1458
+ // MetaMask not available warning
1459
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-yellow-50", children: [
1460
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1461
+ /* @__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" }) }),
1462
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1463
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "MetaMask Not Detected" }),
1464
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: "Please install MetaMask extension to make payments" })
1465
+ ] })
1466
+ ] }),
1467
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1468
+ "a",
1469
+ {
1470
+ href: "https://metamask.io/download/",
1471
+ target: "_blank",
1472
+ rel: "noopener noreferrer",
1473
+ className: "block mt-3 text-center w-full py-2 px-4 bg-blue-500 hover:bg-blue-600 text-white font-medium rounded-md",
1474
+ children: "Install MetaMask"
1475
+ }
1476
+ )
1477
+ ] })
1478
+ ),
1479
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
1480
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1481
+ "button",
1482
+ {
1483
+ type: "button",
1484
+ onClick: handleBack,
1485
+ className: "w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
1486
+ children: "Back"
1487
+ }
1488
+ ),
1489
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1490
+ "button",
1491
+ {
1492
+ type: "button",
1493
+ onClick: handlePaymentConfirm,
1494
+ className: "w-full py-2 px-4 bg-blue-500 hover:bg-blue-600 text-white font-medium rounded-md",
1495
+ disabled: !testMode && paymentMethod === "wallet" && isMetaMaskAvailable && !walletConnected,
1496
+ children: "Pay Now"
1497
+ }
1498
+ )
1499
+ ] })
1500
+ ] }),
1501
+ step === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1502
+ PaymentStatus,
1503
+ {
1504
+ status: "processing",
1505
+ theme,
1506
+ message: "Processing your payment..."
1507
+ }
1508
+ ),
1509
+ step === "success" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1510
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1511
+ PaymentStatus,
1512
+ {
1513
+ status: "success",
1514
+ theme,
1515
+ message: "Payment successful!"
1516
+ }
1517
+ ),
1518
+ transactionHash && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-100", children: [
1519
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 mb-1", children: "Transaction Hash:" }),
1520
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-mono break-all text-gray-800", children: formatTransactionHash(transactionHash) }),
1521
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1522
+ "a",
1523
+ {
1524
+ href: `https://etherscan.io/tx/${transactionHash}`,
1525
+ target: "_blank",
1526
+ rel: "noopener noreferrer",
1527
+ className: "text-xs text-blue-600 mt-2 inline-block",
1528
+ children: "View on Etherscan →"
1529
+ }
1530
+ )
1531
+ ] })
1532
+ ] }),
1533
+ step === "error" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1534
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1535
+ PaymentStatus,
1536
+ {
1537
+ status: "error",
1538
+ theme,
1539
+ message: error || "An error occurred while processing your payment."
1540
+ }
1541
+ ),
1542
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1543
+ "button",
1544
+ {
1545
+ type: "button",
1546
+ onClick: handleBack,
1547
+ className: "mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
1548
+ children: "Try Again"
1549
+ }
1550
+ )
1551
+ ] })
1552
+ ] }),
1553
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center text-xs text-gray-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Powered by Coinley - Secure Cryptocurrency Payments" }) })
1554
+ ] }) }) });
1398
1555
  };
1399
1556
  const CoinleyCheckout = forwardRef(({
1400
1557
  apiKey,
@@ -1618,77 +1775,7 @@ const DEFAULT_CONFIG = {
1618
1775
  testMode: false,
1619
1776
  theme: "light"
1620
1777
  };
1621
- const VERSION = "1.0.9";
1622
- const hashString = (str) => {
1623
- let hash = 0;
1624
- for (let i = 0; i < str.length; i++) {
1625
- const char = str.charCodeAt(i);
1626
- hash = (hash << 5) - hash + char;
1627
- hash = hash & hash;
1628
- }
1629
- return Math.abs(hash);
1630
- };
1631
- const generateQR = (data, size = 200, darkMode = false) => {
1632
- const dataHash = hashString(data);
1633
- const moduleCount = 25;
1634
- const moduleSize = Math.floor(size / moduleCount);
1635
- const quietZone = moduleSize * 2;
1636
- const svgSize = size + quietZone * 2;
1637
- const darkColor = darkMode ? "#FFFFFF" : "#000000";
1638
- const lightColor = darkMode ? "#1F2937" : "#FFFFFF";
1639
- let svg = `
1640
- <svg
1641
- xmlns="http://www.w3.org/2000/svg"
1642
- width="${svgSize}"
1643
- height="${svgSize}"
1644
- viewBox="0 0 ${svgSize} ${svgSize}"
1645
- >
1646
- `;
1647
- svg += `<rect width="${svgSize}" height="${svgSize}" fill="${lightColor}"/>`;
1648
- svg += createPositionPattern(quietZone, quietZone, moduleSize, darkColor, lightColor);
1649
- svg += createPositionPattern(svgSize - quietZone - moduleSize * 7, quietZone, moduleSize, darkColor, lightColor);
1650
- svg += createPositionPattern(quietZone, svgSize - quietZone - moduleSize * 7, moduleSize, darkColor, lightColor);
1651
- for (let row = 0; row < moduleCount; row++) {
1652
- for (let col = 0; col < moduleCount; col++) {
1653
- if (row < 7 && col < 7 || // Top left
1654
- row < 7 && col >= moduleCount - 7 || // Top right
1655
- row >= moduleCount - 7 && col < 7) {
1656
- continue;
1657
- }
1658
- const shouldFill = (dataHash + row * 37 + col * 17) % 3 === 0;
1659
- if (shouldFill) {
1660
- const x = quietZone + col * moduleSize;
1661
- const y = quietZone + row * moduleSize;
1662
- svg += `<rect x="${x}" y="${y}" width="${moduleSize}" height="${moduleSize}" fill="${darkColor}"/>`;
1663
- }
1664
- }
1665
- }
1666
- for (let i = 8; i < moduleCount - 8; i++) {
1667
- if (i % 2 === 0) {
1668
- svg += `<rect x="${quietZone + i * moduleSize}" y="${quietZone + 6 * moduleSize}" width="${moduleSize}" height="${moduleSize}" fill="${darkColor}"/>`;
1669
- }
1670
- }
1671
- for (let i = 8; i < moduleCount - 8; i++) {
1672
- if (i % 2 === 0) {
1673
- svg += `<rect x="${quietZone + 6 * moduleSize}" y="${quietZone + i * moduleSize}" width="${moduleSize}" height="${moduleSize}" fill="${darkColor}"/>`;
1674
- }
1675
- }
1676
- svg += `<rect x="${quietZone + moduleSize * 12}" y="${quietZone + moduleSize * 12}" width="${moduleSize * 3}" height="${moduleSize * 3}" fill="${darkColor}"/>`;
1677
- svg += `<rect x="${quietZone + moduleSize * 13}" y="${quietZone + moduleSize * 13}" width="${moduleSize}" height="${moduleSize}" fill="${lightColor}"/>`;
1678
- svg += "</svg>";
1679
- return svg;
1680
- };
1681
- const createPositionPattern = (x, y, size, darkColor, lightColor) => {
1682
- let pattern = "";
1683
- pattern += `<rect x="${x}" y="${y}" width="${size * 7}" height="${size * 7}" fill="${darkColor}"/>`;
1684
- pattern += `<rect x="${x + size}" y="${y + size}" width="${size * 5}" height="${size * 5}" fill="${lightColor}"/>`;
1685
- pattern += `<rect x="${x + size * 2}" y="${y + size * 2}" width="${size * 3}" height="${size * 3}" fill="${darkColor}"/>`;
1686
- return pattern;
1687
- };
1688
- const qrcodeGenerator = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1689
- __proto__: null,
1690
- generateQR
1691
- }, Symbol.toStringTag, { value: "Module" }));
1778
+ const VERSION = "0.2.0";
1692
1779
  export {
1693
1780
  CoinleyCheckout,
1694
1781
  CoinleyModal,