coinley-checkout 1.3.3 → 1.3.5
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.
|
@@ -22921,8 +22921,8 @@ let apiConfig = {
|
|
|
22921
22921
|
apiKey: null,
|
|
22922
22922
|
apiSecret: null,
|
|
22923
22923
|
// apiUrl: 'https://coinleyserver-production.up.railway.app',
|
|
22924
|
-
|
|
22925
|
-
apiUrl:
|
|
22924
|
+
apiUrl: "https://hub.coinley.io",
|
|
22925
|
+
// apiUrl: 'http://localhost:9000',
|
|
22926
22926
|
merchantWalletAddresses: {},
|
|
22927
22927
|
authToken: null,
|
|
22928
22928
|
merchantFeePercentage: null,
|
|
@@ -25235,9 +25235,14 @@ const PaymentMethods = ({ onSelect, selected, theme: theme2 = "light", supported
|
|
|
25235
25235
|
};
|
|
25236
25236
|
const handleSelectPaymentMethod = (token) => {
|
|
25237
25237
|
const tokenIconData = getTokenIcon(token);
|
|
25238
|
+
console.log("=== PAYMENT METHOD SELECTION DEBUG ===");
|
|
25239
|
+
console.log("Selected token:", token);
|
|
25240
|
+
console.log("Selected network:", selectedNetwork);
|
|
25241
|
+
console.log("Token network:", token.Network?.shortName);
|
|
25238
25242
|
const paymentMethodData = {
|
|
25239
25243
|
currency: token.symbol,
|
|
25240
25244
|
network: selectedNetwork,
|
|
25245
|
+
// ✅ Use the selectedNetwork state, not token.Network.shortName
|
|
25241
25246
|
tokenConfig: {
|
|
25242
25247
|
contractAddress: token.contractAddress,
|
|
25243
25248
|
decimals: token.decimals,
|
|
@@ -25251,9 +25256,13 @@ const PaymentMethods = ({ onSelect, selected, theme: theme2 = "light", supported
|
|
|
25251
25256
|
logo: tokenIconData,
|
|
25252
25257
|
// Store the icon data object
|
|
25253
25258
|
network: selectedNetwork,
|
|
25259
|
+
// ✅ Use selectedNetwork here too
|
|
25254
25260
|
isStablecoin: token.isStablecoin
|
|
25255
25261
|
}
|
|
25256
25262
|
};
|
|
25263
|
+
console.log("🎯 FINAL PAYMENT METHOD DATA:", paymentMethodData);
|
|
25264
|
+
console.log("🎯 Network being set:", paymentMethodData.network);
|
|
25265
|
+
console.log("=== END PAYMENT METHOD SELECTION DEBUG ===");
|
|
25257
25266
|
setSelectedPaymentMethod(paymentMethodData);
|
|
25258
25267
|
};
|
|
25259
25268
|
const handleProceed = () => {
|
|
@@ -25999,6 +26008,7 @@ const CoinleyCheckout = forwardRef(({
|
|
|
25999
26008
|
const [step, setStep] = useState("select-currency");
|
|
26000
26009
|
const [actualMerchantWallets, setActualMerchantWallets] = useState({});
|
|
26001
26010
|
const [merchantFeePercentage, setMerchantFeePercentage] = useState(0.0175);
|
|
26011
|
+
const [storedPaymentDetails, setStoredPaymentDetails] = useState(null);
|
|
26002
26012
|
const [merchantSupportedNetworks, setMerchantSupportedNetworks] = useState([]);
|
|
26003
26013
|
const [merchantSupportedTokens, setMerchantSupportedTokens] = useState([]);
|
|
26004
26014
|
const [processingStartTime, setProcessingStartTime] = useState(null);
|
|
@@ -26155,32 +26165,68 @@ const CoinleyCheckout = forwardRef(({
|
|
|
26155
26165
|
getMerchantSupportedTokens: () => merchantSupportedTokens
|
|
26156
26166
|
}));
|
|
26157
26167
|
const handleOpen = async (paymentDetails) => {
|
|
26168
|
+
console.log("🚨 HANDLE OPEN DEBUG - START");
|
|
26169
|
+
console.log("paymentDetails received:", paymentDetails);
|
|
26158
26170
|
if (!paymentDetails || !paymentDetails.amount) {
|
|
26159
26171
|
setError("Payment amount is required");
|
|
26160
26172
|
if (onError)
|
|
26161
26173
|
onError(new Error("Payment amount is required"));
|
|
26162
26174
|
return;
|
|
26163
26175
|
}
|
|
26164
|
-
|
|
26176
|
+
setStoredPaymentDetails(paymentDetails);
|
|
26177
|
+
setPaymentStatus("idle");
|
|
26165
26178
|
setIsOpen(true);
|
|
26166
26179
|
setStep("select-currency");
|
|
26180
|
+
setError(null);
|
|
26181
|
+
console.log("✅ Modal opened, waiting for user to select payment method");
|
|
26182
|
+
};
|
|
26183
|
+
const handleClose = () => {
|
|
26184
|
+
if (checkingInterval) {
|
|
26185
|
+
clearInterval(checkingInterval);
|
|
26186
|
+
setCheckingInterval(null);
|
|
26187
|
+
}
|
|
26188
|
+
if (processingTimerRef.current) {
|
|
26189
|
+
clearTimeout(processingTimerRef.current);
|
|
26190
|
+
processingTimerRef.current = null;
|
|
26191
|
+
}
|
|
26192
|
+
setIsOpen(false);
|
|
26193
|
+
setTransactionHash(null);
|
|
26194
|
+
setWalletConnection(null);
|
|
26195
|
+
setSelectedPaymentMethod(null);
|
|
26196
|
+
setStoredPaymentDetails(null);
|
|
26197
|
+
setPayment(null);
|
|
26198
|
+
setStep("select-currency");
|
|
26199
|
+
setProcessingStartTime(null);
|
|
26200
|
+
setPendingBackendConfirmation(false);
|
|
26201
|
+
if (onClose)
|
|
26202
|
+
onClose();
|
|
26203
|
+
};
|
|
26204
|
+
const handlePaymentMethodSelect = async (paymentMethod) => {
|
|
26205
|
+
console.log("=== PAYMENT METHOD SELECTION DEBUG ===");
|
|
26206
|
+
console.log("1. Payment method selected:", paymentMethod);
|
|
26207
|
+
console.log("2. Stored payment details:", storedPaymentDetails);
|
|
26208
|
+
if (!storedPaymentDetails) {
|
|
26209
|
+
setError("Payment details are missing");
|
|
26210
|
+
return;
|
|
26211
|
+
}
|
|
26212
|
+
log("Payment method selected:", paymentMethod);
|
|
26213
|
+
setSelectedPaymentMethod(paymentMethod);
|
|
26167
26214
|
try {
|
|
26168
|
-
|
|
26169
|
-
|
|
26170
|
-
|
|
26171
|
-
|
|
26172
|
-
|
|
26173
|
-
|
|
26174
|
-
|
|
26175
|
-
|
|
26215
|
+
setPaymentStatus("loading");
|
|
26216
|
+
console.log("🚀 Creating payment with selected method:");
|
|
26217
|
+
console.log("Network:", paymentMethod.network);
|
|
26218
|
+
console.log("Currency:", paymentMethod.currency);
|
|
26219
|
+
const isNetworkSupported = merchantSupportedNetworks.some(
|
|
26220
|
+
(network) => network.shortName === paymentMethod.network
|
|
26221
|
+
);
|
|
26222
|
+
if (!isNetworkSupported) {
|
|
26223
|
+
throw new Error(`Network ${paymentMethod.network} is not configured for this merchant`);
|
|
26176
26224
|
}
|
|
26177
|
-
|
|
26178
|
-
|
|
26179
|
-
|
|
26180
|
-
|
|
26181
|
-
|
|
26182
|
-
throw new Error(`Token ${paymentDetails.currency} is not supported on ${paymentDetails.network} network for this merchant`);
|
|
26183
|
-
}
|
|
26225
|
+
const isTokenSupported = merchantSupportedTokens.some(
|
|
26226
|
+
(token) => token.symbol === paymentMethod.currency && token.Network && token.Network.shortName === paymentMethod.network
|
|
26227
|
+
);
|
|
26228
|
+
if (!isTokenSupported) {
|
|
26229
|
+
throw new Error(`Token ${paymentMethod.currency} is not supported on ${paymentMethod.network} network for this merchant`);
|
|
26184
26230
|
}
|
|
26185
26231
|
let walletAddresses = actualMerchantWallets;
|
|
26186
26232
|
if (Object.keys(walletAddresses).length === 0) {
|
|
@@ -26190,18 +26236,20 @@ const CoinleyCheckout = forwardRef(({
|
|
|
26190
26236
|
}
|
|
26191
26237
|
log("Using wallet addresses:", walletAddresses);
|
|
26192
26238
|
const paymentResponse = await createPayment({
|
|
26193
|
-
amount:
|
|
26194
|
-
currency:
|
|
26195
|
-
|
|
26196
|
-
|
|
26197
|
-
|
|
26239
|
+
amount: storedPaymentDetails.amount,
|
|
26240
|
+
currency: paymentMethod.currency,
|
|
26241
|
+
// ✅ Use selected currency
|
|
26242
|
+
network: paymentMethod.network,
|
|
26243
|
+
// ✅ Use selected network
|
|
26244
|
+
customerEmail: storedPaymentDetails.customerEmail || customerEmail,
|
|
26245
|
+
callbackUrl: storedPaymentDetails.callbackUrl,
|
|
26198
26246
|
metadata: {
|
|
26199
|
-
...
|
|
26247
|
+
...storedPaymentDetails.metadata,
|
|
26200
26248
|
merchantWalletAddresses: walletAddresses
|
|
26201
26249
|
},
|
|
26202
26250
|
merchantWalletAddresses: walletAddresses
|
|
26203
26251
|
});
|
|
26204
|
-
log("Payment created:", paymentResponse);
|
|
26252
|
+
console.log("✅ Payment created with correct network:", paymentResponse.payment);
|
|
26205
26253
|
if (paymentResponse.payment.customFeePercentage) {
|
|
26206
26254
|
const feeFromPayment = parseFloat(paymentResponse.payment.customFeePercentage);
|
|
26207
26255
|
setMerchantFeePercentage(feeFromPayment);
|
|
@@ -26210,7 +26258,8 @@ const CoinleyCheckout = forwardRef(({
|
|
|
26210
26258
|
setPayment(paymentResponse.payment);
|
|
26211
26259
|
setPaymentStatus("idle");
|
|
26212
26260
|
setError(null);
|
|
26213
|
-
|
|
26261
|
+
setStep("confirm");
|
|
26262
|
+
log("Payment created and proceeding to confirmation");
|
|
26214
26263
|
} catch (err) {
|
|
26215
26264
|
log("Error creating payment:", err);
|
|
26216
26265
|
setError(err.message || "Failed to create payment");
|
|
@@ -26218,40 +26267,14 @@ const CoinleyCheckout = forwardRef(({
|
|
|
26218
26267
|
if (onError)
|
|
26219
26268
|
onError(err);
|
|
26220
26269
|
}
|
|
26221
|
-
};
|
|
26222
|
-
const handleClose = () => {
|
|
26223
|
-
if (checkingInterval) {
|
|
26224
|
-
clearInterval(checkingInterval);
|
|
26225
|
-
setCheckingInterval(null);
|
|
26226
|
-
}
|
|
26227
|
-
if (processingTimerRef.current) {
|
|
26228
|
-
clearTimeout(processingTimerRef.current);
|
|
26229
|
-
processingTimerRef.current = null;
|
|
26230
|
-
}
|
|
26231
|
-
setIsOpen(false);
|
|
26232
|
-
setTransactionHash(null);
|
|
26233
|
-
setWalletConnection(null);
|
|
26234
|
-
setSelectedPaymentMethod(null);
|
|
26235
|
-
setStep("select-currency");
|
|
26236
|
-
setProcessingStartTime(null);
|
|
26237
|
-
setPendingBackendConfirmation(false);
|
|
26238
|
-
if (onClose)
|
|
26239
|
-
onClose();
|
|
26240
|
-
};
|
|
26241
|
-
const handlePaymentMethodSelect = (paymentMethod) => {
|
|
26242
|
-
console.log("=== PAYMENT METHOD SELECTION DEBUG ===");
|
|
26243
|
-
console.log("1. Payment method selected:", paymentMethod);
|
|
26244
|
-
console.log("2. Current step before:", step);
|
|
26245
|
-
log("Payment method selected:", paymentMethod);
|
|
26246
|
-
setSelectedPaymentMethod(paymentMethod);
|
|
26247
|
-
setStep("confirm");
|
|
26248
|
-
console.log("3. Step should now be: confirm");
|
|
26249
26270
|
console.log("=== END PAYMENT METHOD SELECTION DEBUG ===");
|
|
26250
26271
|
};
|
|
26251
26272
|
const handleBack = () => {
|
|
26252
26273
|
if (step === "confirm") {
|
|
26253
26274
|
setStep("select-currency");
|
|
26254
26275
|
setWalletConnection(null);
|
|
26276
|
+
setPayment(null);
|
|
26277
|
+
setSelectedPaymentMethod(null);
|
|
26255
26278
|
} else if (step === "error") {
|
|
26256
26279
|
setStep("confirm");
|
|
26257
26280
|
}
|