coinley-checkout 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1110,97 +1110,37 @@ 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 = () => {
1115
+ const qrCodeUrl = require$$0.useMemo(() => {
1118
1116
  if (!walletAddress)
1119
1117
  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
- };
1118
+ const data = `${currency}:${walletAddress}?amount=${amount}&currency=${currency}`;
1119
+ return `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(data)}`;
1120
+ }, [walletAddress, amount, currency]);
1182
1121
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center", children: [
1183
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1184
- "div",
1122
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg bg-white mb-3", children: walletAddress ? /* @__PURE__ */ jsxRuntimeExports.jsx(
1123
+ "img",
1185
1124
  {
1186
- className: `p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-white"} mb-3`,
1187
- dangerouslySetInnerHTML: { __html: qrCodeSvg }
1125
+ src: qrCodeUrl,
1126
+ alt: `QR Code for ${currency} payment`,
1127
+ style: { width: "200px", height: "200px" }
1188
1128
  }
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" }),
1129
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "200px", height: "200px", background: "#f0f0f0", display: "flex", alignItems: "center", justifyContent: "center" }, children: "Wallet address missing" }) }),
1130
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center text-sm text-gray-700", children: "Scan with your wallet app to pay" }),
1191
1131
  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: [
1132
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500 mb-1", children: [
1193
1133
  "Send ",
1194
1134
  amount,
1195
1135
  " ",
1196
1136
  currency,
1197
1137
  " to:"
1198
1138
  ] }),
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 })
1139
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs font-mono p-2 rounded overflow-auto break-all bg-gray-100 text-gray-700", children: walletAddress })
1200
1140
  ] }),
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: [
1141
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-3 rounded bg-gray-100", children: [
1142
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "text-sm font-medium mb-2 text-gray-800", children: "Payment Instructions" }),
1143
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: "text-xs space-y-2 text-gray-600", children: [
1204
1144
  /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "1. Open your crypto wallet app" }),
1205
1145
  /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "2. Scan the QR code above" }),
1206
1146
  /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
@@ -1348,6 +1288,7 @@ const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
1348
1288
  )) })
1349
1289
  ] });
1350
1290
  };
1291
+ const Logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAcCAYAAACqAXueAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8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ejj483tGCFfIIKjbjtGv1wEwn94cVNyL77xfa2YdtMjNSdsZgrKj1eJHsWpRX7AvhYuHqvFjDfFaT3FO2Fp0VVUzxhFOzalT159IppeaYF+F8YPns2Zp2kUdU5ATz5FOpKuf2T6DNMtcovDztAnx9z2UGpVq0/vaqKFwdUetS5AC7RMbe6wqXTq8CnWpx4s4TRGVsdU3Wyf0rKke5PpWFG5liiFmpqPL0KjTSsxrr59ngYsG9pfny1WJu951z8HG85PozNRIug1OmUu0iKgqXUfyiw+e/IhFv/dkNhTKEabebFK/0hFvtNYR8wrsym27FpgBmaqjUvc1yznvaNxv3VJmzcrutRvVWqEFfEU5HXIlbwifZat1WtXATaJPv9MlyXxc5Ew2zOyh/d6Xe8SYDf+VBZo/VXh/jATa5jhd/JqVK+0UHm6gJzPea2qL3NB0NXEBwD6JmwtE+yx6cVzfdR/5V4JhBgt/YM/O9GzbkM2fubfk2KlLl94MV+XmRW2Ga77B83RQnKyX7TAcC5WBhzKesyaDXO1HWfIe0MjSDYaGNmkEzGdG1QTGaP7m4S2GDxsYJURVlQcDxAIHUQ+1z48V+Jhzp+OSFEWy8mECwdgXlfbYNsh6tF1Xfoh7GslnN9Z0btZay8MmOFkw5YpR2MKW3BCNLO0O0HZqP78QfVYP/jx2mW5TAmcbZYTHxsYFYVNer2XfRyobjxWh1cT607T7d4qejPsrO0EzAgv0u/HH4OBeGaxPO94Q6plv8FECovJc8uTjKNvgPcUpIo0ZgmzUAAAAASUVORK5CYII=";
1351
1292
  const CoinleyModal = (props) => {
1352
1293
  const {
1353
1294
  isOpen,
@@ -1384,17 +1325,252 @@ const CoinleyModal = (props) => {
1384
1325
  setStep("select-currency");
1385
1326
  }
1386
1327
  }, [paymentStatus, payment]);
1328
+ const handleCurrencySelect = (currency) => {
1329
+ onCurrencySelect(currency);
1330
+ setStep("confirm");
1331
+ };
1332
+ const handlePaymentConfirm = () => {
1333
+ onPayment(paymentMethod === "qrcode");
1334
+ };
1335
+ const handleBack = () => {
1336
+ if (step === "confirm") {
1337
+ setStep("select-currency");
1338
+ }
1339
+ };
1340
+ const togglePaymentMethod = (method) => {
1341
+ setPaymentMethod(method);
1342
+ };
1343
+ const formatAmount = (amount) => {
1344
+ return parseFloat(amount).toFixed(2);
1345
+ };
1346
+ const formatTransactionHash = (hash) => {
1347
+ if (!hash)
1348
+ return "";
1349
+ if (hash.length <= 14)
1350
+ return hash;
1351
+ return `${hash.slice(0, 8)}...${hash.slice(-6)}`;
1352
+ };
1387
1353
  if (!isOpen)
1388
1354
  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
- ) }) }) }) });
1355
+ 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: [
1356
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mb-6", children: [
1357
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1358
+ /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: Logo, alt: "Coinley Logo", className: "h-8 mr-2" }),
1359
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-xl font-bold text-gray-900", children: "Coinley Pay" })
1360
+ ] }),
1361
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1362
+ "button",
1363
+ {
1364
+ onClick: onClose,
1365
+ className: "text-gray-500 hover:text-gray-700 focus:outline-none",
1366
+ 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" }) })
1367
+ }
1368
+ )
1369
+ ] }),
1370
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [
1371
+ payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6 p-4 rounded-lg bg-gray-100", children: [
1372
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: merchantName }),
1373
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mt-2", children: [
1374
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-700", children: "Amount:" }),
1375
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold text-xl", children: [
1376
+ "$",
1377
+ formatAmount(payment.totalAmount || payment.amount)
1378
+ ] })
1379
+ ] }),
1380
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-gray-500", children: [
1381
+ "Payment ID: ",
1382
+ payment.id ? payment.id.slice(0, 8) : "",
1383
+ "..."
1384
+ ] }) })
1385
+ ] }),
1386
+ step === "select-currency" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1387
+ PaymentMethods,
1388
+ {
1389
+ onSelect: handleCurrencySelect,
1390
+ selected: selectedCurrency,
1391
+ theme
1392
+ }
1393
+ ),
1394
+ step === "confirm" && payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1395
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-gray-100", children: [
1396
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium mb-2 text-gray-800", children: "Payment Details" }),
1397
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
1398
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1399
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Currency:" }),
1400
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency })
1401
+ ] }),
1402
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1403
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Network:" }),
1404
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "Solana" : "Ethereum" })
1405
+ ] }),
1406
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1407
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Fee:" }),
1408
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: "1.75%" })
1409
+ ] })
1410
+ ] })
1411
+ ] }),
1412
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex border-b border-gray-200", children: [
1413
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1414
+ "button",
1415
+ {
1416
+ onClick: () => togglePaymentMethod("wallet"),
1417
+ 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"}`,
1418
+ children: "Connect Wallet"
1419
+ }
1420
+ ),
1421
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1422
+ "button",
1423
+ {
1424
+ onClick: () => togglePaymentMethod("qrcode"),
1425
+ 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"}`,
1426
+ children: "QR Code"
1427
+ }
1428
+ )
1429
+ ] }) }),
1430
+ testMode ? (
1431
+ // Test mode payment option
1432
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1433
+ /* @__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" }) }) }),
1434
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1435
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "Test Mode Payment" }),
1436
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: 'Click "Pay Now" to simulate a successful payment' })
1437
+ ] })
1438
+ ] }) })
1439
+ ) : paymentMethod === "qrcode" ? (
1440
+ // QR Code payment option
1441
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1442
+ QRCode,
1443
+ {
1444
+ walletAddress: payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
1445
+ amount: payment.totalAmount || payment.amount,
1446
+ currency: selectedCurrency,
1447
+ theme
1448
+ }
1449
+ ) })
1450
+ ) : isMetaMaskAvailable ? (
1451
+ // MetaMask available option
1452
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: [
1453
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1454
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1455
+ "img",
1456
+ {
1457
+ src: "https://metamask.io/images/metamask-fox.svg",
1458
+ alt: "MetaMask",
1459
+ className: "w-8 h-8 mr-2"
1460
+ }
1461
+ ),
1462
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1463
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "Pay with MetaMask" }),
1464
+ /* @__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." })
1465
+ ] })
1466
+ ] }),
1467
+ !walletConnected && /* @__PURE__ */ jsxRuntimeExports.jsx(
1468
+ "button",
1469
+ {
1470
+ onClick: onConnectWallet,
1471
+ className: "mt-3 w-full py-2 px-4 bg-blue-500 hover:bg-blue-600 text-white font-medium rounded-md",
1472
+ children: "Connect Wallet"
1473
+ }
1474
+ )
1475
+ ] })
1476
+ ) : (
1477
+ // MetaMask not available warning
1478
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-yellow-50", children: [
1479
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1480
+ /* @__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" }) }),
1481
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1482
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "font-medium text-gray-800", children: "MetaMask Not Detected" }),
1483
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: "Please install MetaMask extension to make payments" })
1484
+ ] })
1485
+ ] }),
1486
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1487
+ "a",
1488
+ {
1489
+ href: "https://metamask.io/download/",
1490
+ target: "_blank",
1491
+ rel: "noopener noreferrer",
1492
+ 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",
1493
+ children: "Install MetaMask"
1494
+ }
1495
+ )
1496
+ ] })
1497
+ ),
1498
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
1499
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1500
+ "button",
1501
+ {
1502
+ type: "button",
1503
+ onClick: handleBack,
1504
+ className: "w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
1505
+ children: "Back"
1506
+ }
1507
+ ),
1508
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1509
+ "button",
1510
+ {
1511
+ type: "button",
1512
+ onClick: handlePaymentConfirm,
1513
+ className: "w-full py-2 px-4 bg-blue-500 hover:bg-blue-600 text-white font-medium rounded-md",
1514
+ disabled: !testMode && paymentMethod === "wallet" && isMetaMaskAvailable && !walletConnected,
1515
+ children: "Pay Now"
1516
+ }
1517
+ )
1518
+ ] })
1519
+ ] }),
1520
+ step === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1521
+ PaymentStatus,
1522
+ {
1523
+ status: "processing",
1524
+ theme,
1525
+ message: "Processing your payment..."
1526
+ }
1527
+ ),
1528
+ step === "success" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1529
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1530
+ PaymentStatus,
1531
+ {
1532
+ status: "success",
1533
+ theme,
1534
+ message: "Payment successful!"
1535
+ }
1536
+ ),
1537
+ transactionHash && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-100", children: [
1538
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-600 mb-1", children: "Transaction Hash:" }),
1539
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-mono break-all text-gray-800", children: formatTransactionHash(transactionHash) }),
1540
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1541
+ "a",
1542
+ {
1543
+ href: `https://etherscan.io/tx/${transactionHash}`,
1544
+ target: "_blank",
1545
+ rel: "noopener noreferrer",
1546
+ className: "text-xs text-blue-600 mt-2 inline-block",
1547
+ children: "View on Etherscan →"
1548
+ }
1549
+ )
1550
+ ] })
1551
+ ] }),
1552
+ step === "error" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1553
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1554
+ PaymentStatus,
1555
+ {
1556
+ status: "error",
1557
+ theme,
1558
+ message: error || "An error occurred while processing your payment."
1559
+ }
1560
+ ),
1561
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
1562
+ "button",
1563
+ {
1564
+ type: "button",
1565
+ onClick: handleBack,
1566
+ className: "mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
1567
+ children: "Try Again"
1568
+ }
1569
+ )
1570
+ ] })
1571
+ ] }),
1572
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center text-xs text-gray-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Powered by Coinley - Secure Cryptocurrency Payments" }) })
1573
+ ] }) }) });
1398
1574
  };
1399
1575
  const CoinleyCheckout = forwardRef(({
1400
1576
  apiKey,
@@ -1618,77 +1794,7 @@ const DEFAULT_CONFIG = {
1618
1794
  testMode: false,
1619
1795
  theme: "light"
1620
1796
  };
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" }));
1797
+ const VERSION = "0.2.0";
1692
1798
  export {
1693
1799
  CoinleyCheckout,
1694
1800
  CoinleyModal,