@flopay/js 1.3.1 → 1.3.2
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 +28 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +28 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -632,6 +632,7 @@ var DEFAULT_PROCESSING_RETRY_AFTER_MS = 1e3;
|
|
|
632
632
|
var MIN_PROCESSING_RETRY_AFTER_MS = 500;
|
|
633
633
|
var DEFAULT_PROCESSING_TIMEOUT_MS = 15e3;
|
|
634
634
|
var MAX_PROCESSING_RETRY_AFTER_MS = 3e3;
|
|
635
|
+
var DEFAULT_ACCOUNT_SNAPSHOT_TIMEOUT_MS = 1e4;
|
|
635
636
|
function isRecord(value) {
|
|
636
637
|
return typeof value === "object" && value !== null;
|
|
637
638
|
}
|
|
@@ -854,18 +855,33 @@ var PaymentAPI = class {
|
|
|
854
855
|
* pre-pay PATCH would silently leave AVS unsent and cause an
|
|
855
856
|
* AVS-protected charge to decline downstream.
|
|
856
857
|
*/
|
|
857
|
-
async patchAccountSnapshot(sessionId, nonce, body) {
|
|
858
|
-
const
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
858
|
+
async patchAccountSnapshot(sessionId, nonce, body, options) {
|
|
859
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_ACCOUNT_SNAPSHOT_TIMEOUT_MS;
|
|
860
|
+
const controller = new AbortController();
|
|
861
|
+
const onCallerAbort = () => controller.abort();
|
|
862
|
+
if (options?.signal) {
|
|
863
|
+
if (options.signal.aborted) controller.abort();
|
|
864
|
+
else options.signal.addEventListener("abort", onCallerAbort, { once: true });
|
|
865
|
+
}
|
|
866
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
867
|
+
let response;
|
|
868
|
+
try {
|
|
869
|
+
response = await fetchWithNetworkRetry(
|
|
870
|
+
`${this.baseUrl}/v1/checkouts/sessions/${encodeURIComponent(sessionId)}/account`,
|
|
871
|
+
{
|
|
872
|
+
method: "PATCH",
|
|
873
|
+
headers: {
|
|
874
|
+
"Content-Type": "application/json",
|
|
875
|
+
"x-checkout-session-token": nonce
|
|
876
|
+
},
|
|
877
|
+
body: JSON.stringify(body),
|
|
878
|
+
signal: controller.signal
|
|
879
|
+
}
|
|
880
|
+
);
|
|
881
|
+
} finally {
|
|
882
|
+
clearTimeout(timer);
|
|
883
|
+
options?.signal?.removeEventListener("abort", onCallerAbort);
|
|
884
|
+
}
|
|
869
885
|
if (!response.ok) {
|
|
870
886
|
throw await buildApiErrorFromResponse(response, "Failed to persist account snapshot");
|
|
871
887
|
}
|