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