@flopay/react 0.5.10 → 0.5.11
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/index.cjs +76 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +76 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -789,12 +789,6 @@ function PayPalButtonInner({
|
|
|
789
789
|
const redirectStatus = params.get("redirect_status");
|
|
790
790
|
if (!paymentIntentId || !clientSecret) return;
|
|
791
791
|
paypalResumeAttempted.current = true;
|
|
792
|
-
console.info("[FloPay debug] PayPal resume effect firing", {
|
|
793
|
-
paymentIntentId,
|
|
794
|
-
redirectStatus,
|
|
795
|
-
currentSessionId: sessionId,
|
|
796
|
-
url: window.location.href
|
|
797
|
-
});
|
|
798
792
|
const cleanedUrl = new URL(window.location.href);
|
|
799
793
|
cleanedUrl.searchParams.delete("payment_intent");
|
|
800
794
|
cleanedUrl.searchParams.delete("payment_intent_client_secret");
|
|
@@ -1354,11 +1348,6 @@ function SplitCardFormInner({
|
|
|
1354
1348
|
const effectiveAccount = mergeAccountPatch(resolvedAccount, overrides?.accountPatch);
|
|
1355
1349
|
const resolvedCompletionPaymentMethodId = overrides?.completionPaymentMethodId ?? resolveTokenizedPaymentMethodId(tokenizedBody);
|
|
1356
1350
|
const requestTokenizedBody = tokenizedBody.originalPaymentMethodId ? { ...tokenizedBody, originalPaymentMethodId: void 0 } : tokenizedBody;
|
|
1357
|
-
console.info("[FloPay debug] processPaymentInternal -> POST /process", {
|
|
1358
|
-
sessionId: effectiveSessionId,
|
|
1359
|
-
paymentIntentId: tokenizedBody.threeDSecureActionResultTokenId,
|
|
1360
|
-
isPaypal: tokenizedBody.isPaypal
|
|
1361
|
-
});
|
|
1362
1351
|
try {
|
|
1363
1352
|
const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
|
|
1364
1353
|
method: "POST",
|
|
@@ -3161,6 +3150,30 @@ function FloPayCheckout({
|
|
|
3161
3150
|
);
|
|
3162
3151
|
}
|
|
3163
3152
|
const paymentMethodId = typeof paymentIntent.payment_method === "string" ? paymentIntent.payment_method : paymentIntent.payment_method?.id;
|
|
3153
|
+
if (resumeState.sessionId) {
|
|
3154
|
+
const resumeApi = new import_js2.PaymentAPI(resolvedBillingUrl);
|
|
3155
|
+
const resumeSessionResult = await resumeApi.getUnifiedCheckoutSession(resumeState.sessionId);
|
|
3156
|
+
const resumeSession = resumeSessionResult.data.session;
|
|
3157
|
+
if (resumeSession && resumeSession.status !== "complete") {
|
|
3158
|
+
const processResult = await processSavedPaymentForMode({
|
|
3159
|
+
billingApiUrl: resolvedBillingUrl,
|
|
3160
|
+
sessionId: resumeState.sessionId,
|
|
3161
|
+
session: resumeSession,
|
|
3162
|
+
tokenizedData: {
|
|
3163
|
+
id: paymentMethodId ?? paymentIntent.id,
|
|
3164
|
+
type: "card",
|
|
3165
|
+
threeDSecureActionResultTokenId: paymentIntent.id,
|
|
3166
|
+
isPaypal: true
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
3169
|
+
if (processResult.type !== "success") {
|
|
3170
|
+
throw Object.assign(
|
|
3171
|
+
new import_shared7.FloPayError("Failed to finalize PayPal payment.", "api_error"),
|
|
3172
|
+
{ checkoutMethod: "paypal" }
|
|
3173
|
+
);
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3164
3177
|
if (resumeState.sessionId) markSessionRecentlyCompleted(resumeState.sessionId);
|
|
3165
3178
|
setModeOverlayStatus("success");
|
|
3166
3179
|
await sleep(PROCESSING_OVERLAY_SUCCESS_DELAY_MS);
|
|
@@ -3234,42 +3247,24 @@ function FloPayCheckout({
|
|
|
3234
3247
|
const api = new import_js2.PaymentAPI(resolvedBillingUrl);
|
|
3235
3248
|
let sid = typeof window !== "undefined" ? window.sessionStorage.getItem(cacheKey) : null;
|
|
3236
3249
|
let realResult = null;
|
|
3237
|
-
console.info("[FloPay debug] resolveInlineSession enter", {
|
|
3238
|
-
cacheKey,
|
|
3239
|
-
cachedSid: sid,
|
|
3240
|
-
url: typeof window !== "undefined" ? window.location.href : null
|
|
3241
|
-
});
|
|
3242
3250
|
if (sid) {
|
|
3243
3251
|
try {
|
|
3244
3252
|
realResult = await api.getUnifiedCheckoutSession(sid);
|
|
3245
3253
|
const status = realResult.data.session?.status;
|
|
3246
|
-
console.info("[FloPay debug] resolveInlineSession cache hit", {
|
|
3247
|
-
cacheKey,
|
|
3248
|
-
sid,
|
|
3249
|
-
status,
|
|
3250
|
-
recentlyCompleted: wasSessionRecentlyCompleted(sid)
|
|
3251
|
-
});
|
|
3252
3254
|
if (status === "complete") {
|
|
3253
3255
|
if (wasSessionRecentlyCompleted(sid)) {
|
|
3254
|
-
console.info("[FloPay debug] resolveInlineSession reuse-completed", { sid });
|
|
3255
3256
|
return { sid, result: realResult };
|
|
3256
3257
|
}
|
|
3257
|
-
console.warn("[FloPay debug] resolveInlineSession clearing stale complete cache", { sid });
|
|
3258
3258
|
if (typeof window !== "undefined") window.sessionStorage.removeItem(cacheKey);
|
|
3259
3259
|
sid = null;
|
|
3260
3260
|
realResult = null;
|
|
3261
3261
|
}
|
|
3262
|
-
} catch
|
|
3263
|
-
console.warn("[FloPay debug] resolveInlineSession getUnifiedCheckoutSession threw", { sid, err });
|
|
3262
|
+
} catch {
|
|
3264
3263
|
if (typeof window !== "undefined") window.sessionStorage.removeItem(cacheKey);
|
|
3265
3264
|
sid = null;
|
|
3266
3265
|
}
|
|
3267
3266
|
}
|
|
3268
3267
|
if (!sid) {
|
|
3269
|
-
console.warn("[FloPay debug] resolveInlineSession POSTing /v1/checkouts/sessions", {
|
|
3270
|
-
cacheKey,
|
|
3271
|
-
url: typeof window !== "undefined" ? window.location.href : null
|
|
3272
|
-
});
|
|
3273
3268
|
const paramsWithAnalytics = {
|
|
3274
3269
|
...params,
|
|
3275
3270
|
avsCheck: !!enableAVS,
|
|
@@ -3294,16 +3289,10 @@ function FloPayCheckout({
|
|
|
3294
3289
|
const mergedParams = mergeInlineSessionPatch(baseParams, patch);
|
|
3295
3290
|
const cacheKey = hashCreateParams(mergedParams);
|
|
3296
3291
|
let promise = sessionInflightMap.get(cacheKey);
|
|
3297
|
-
const inflightHit = !!promise;
|
|
3298
3292
|
if (!promise) {
|
|
3299
3293
|
promise = resolveInlineSession(mergedParams, cacheKey);
|
|
3300
3294
|
sessionInflightMap.set(cacheKey, promise);
|
|
3301
3295
|
}
|
|
3302
|
-
console.info("[FloPay debug] bootstrapInlineSession", {
|
|
3303
|
-
cacheKey,
|
|
3304
|
-
inflightHit,
|
|
3305
|
-
url: typeof window !== "undefined" ? window.location.href : null
|
|
3306
|
-
});
|
|
3307
3296
|
let resolved;
|
|
3308
3297
|
try {
|
|
3309
3298
|
resolved = await promise;
|
|
@@ -4930,6 +4919,10 @@ function FloPayAutomaticPaymentButton({
|
|
|
4930
4919
|
floPayErr = normalizeSavedPaymentError(intentRecoveryErr);
|
|
4931
4920
|
}
|
|
4932
4921
|
}
|
|
4922
|
+
const inResumeWindow = typeof window !== "undefined" && new URLSearchParams(window.location.search).has("payment_intent_client_secret") && !!readPayPalResumeState2();
|
|
4923
|
+
if (floPayErr.code === "payment_intent_unexpected_state" && inResumeWindow) {
|
|
4924
|
+
return;
|
|
4925
|
+
}
|
|
4933
4926
|
await showError(floPayErr, {
|
|
4934
4927
|
emitDecline: true,
|
|
4935
4928
|
method: floPayErr.checkoutMethod ?? DEFAULT_SAVED_PAYMENT_DECLINE_METHOD
|
|
@@ -5101,25 +5094,58 @@ function FloPayAutomaticPaymentButton({
|
|
|
5101
5094
|
);
|
|
5102
5095
|
}
|
|
5103
5096
|
const resultStatus = mapPayPalIntentStatusToPaymentResult(paymentIntent?.status);
|
|
5104
|
-
if (paymentIntent
|
|
5105
|
-
const paymentMethodId2 = typeof paymentIntent.payment_method === "string" ? paymentIntent.payment_method : paymentIntent.payment_method?.id;
|
|
5106
|
-
await showSuccess({
|
|
5107
|
-
result: {
|
|
5108
|
-
status: resultStatus,
|
|
5109
|
-
paymentIntentId: paymentIntent.id,
|
|
5110
|
-
paymentMethodId: paymentMethodId2,
|
|
5111
|
-
checkoutMethod: "paypal"
|
|
5112
|
-
},
|
|
5113
|
-
session: null,
|
|
5114
|
-
sessionId: resumeState.sessionId,
|
|
5115
|
-
autoCompleted: false
|
|
5116
|
-
});
|
|
5117
|
-
} else {
|
|
5097
|
+
if (!paymentIntent || resultStatus === "failed") {
|
|
5118
5098
|
throw Object.assign(
|
|
5119
5099
|
new import_shared10.FloPayError("PayPal payment was not completed. Please try again.", "api_error"),
|
|
5120
5100
|
{ checkoutMethod: "paypal" }
|
|
5121
5101
|
);
|
|
5122
5102
|
}
|
|
5103
|
+
const paymentMethodId2 = typeof paymentIntent.payment_method === "string" ? paymentIntent.payment_method : paymentIntent.payment_method?.id;
|
|
5104
|
+
if (!resumeState.sessionId) {
|
|
5105
|
+
throw Object.assign(
|
|
5106
|
+
new import_shared10.FloPayError("Missing session id on PayPal resume.", "api_error"),
|
|
5107
|
+
{ checkoutMethod: "paypal" }
|
|
5108
|
+
);
|
|
5109
|
+
}
|
|
5110
|
+
const api = new import_js3.PaymentAPI(resolvedBillingUrl);
|
|
5111
|
+
const sessionResult = await api.getUnifiedCheckoutSession(resumeState.sessionId);
|
|
5112
|
+
const resumeSession = sessionResult.data.session;
|
|
5113
|
+
if (!resumeSession) {
|
|
5114
|
+
throw Object.assign(
|
|
5115
|
+
new import_shared10.FloPayError("Could not load session to capture PayPal payment.", "api_error"),
|
|
5116
|
+
{ checkoutMethod: "paypal" }
|
|
5117
|
+
);
|
|
5118
|
+
}
|
|
5119
|
+
if (resumeSession.status !== "complete") {
|
|
5120
|
+
const processResult = await processSavedPaymentForMode({
|
|
5121
|
+
billingApiUrl: resolvedBillingUrl,
|
|
5122
|
+
sessionId: resumeState.sessionId,
|
|
5123
|
+
session: resumeSession,
|
|
5124
|
+
tokenizedData: {
|
|
5125
|
+
id: paymentMethodId2 ?? paymentIntent.id,
|
|
5126
|
+
type: "card",
|
|
5127
|
+
threeDSecureActionResultTokenId: paymentIntent.id,
|
|
5128
|
+
isPaypal: true
|
|
5129
|
+
}
|
|
5130
|
+
});
|
|
5131
|
+
if (processResult.type !== "success") {
|
|
5132
|
+
throw Object.assign(
|
|
5133
|
+
new import_shared10.FloPayError("Failed to finalize PayPal payment.", "api_error"),
|
|
5134
|
+
{ checkoutMethod: "paypal" }
|
|
5135
|
+
);
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
await showSuccess({
|
|
5139
|
+
result: {
|
|
5140
|
+
status: resultStatus,
|
|
5141
|
+
paymentIntentId: paymentIntent.id,
|
|
5142
|
+
paymentMethodId: paymentMethodId2,
|
|
5143
|
+
checkoutMethod: "paypal"
|
|
5144
|
+
},
|
|
5145
|
+
session: resumeSession,
|
|
5146
|
+
sessionId: resumeState.sessionId,
|
|
5147
|
+
autoCompleted: false
|
|
5148
|
+
});
|
|
5123
5149
|
} catch (err) {
|
|
5124
5150
|
const floPayErr = normalizeSavedPaymentError(err);
|
|
5125
5151
|
await showError(floPayErr, {
|