@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.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -593,6 +593,7 @@ var DEFAULT_PROCESSING_RETRY_AFTER_MS = 1e3;
|
|
|
593
593
|
var MIN_PROCESSING_RETRY_AFTER_MS = 500;
|
|
594
594
|
var DEFAULT_PROCESSING_TIMEOUT_MS = 15e3;
|
|
595
595
|
var MAX_PROCESSING_RETRY_AFTER_MS = 3e3;
|
|
596
|
+
var DEFAULT_ACCOUNT_SNAPSHOT_TIMEOUT_MS = 1e4;
|
|
596
597
|
function isRecord(value) {
|
|
597
598
|
return typeof value === "object" && value !== null;
|
|
598
599
|
}
|
|
@@ -815,18 +816,33 @@ var PaymentAPI = class {
|
|
|
815
816
|
* pre-pay PATCH would silently leave AVS unsent and cause an
|
|
816
817
|
* AVS-protected charge to decline downstream.
|
|
817
818
|
*/
|
|
818
|
-
async patchAccountSnapshot(sessionId, nonce, body) {
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
819
|
+
async patchAccountSnapshot(sessionId, nonce, body, options) {
|
|
820
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_ACCOUNT_SNAPSHOT_TIMEOUT_MS;
|
|
821
|
+
const controller = new AbortController();
|
|
822
|
+
const onCallerAbort = () => controller.abort();
|
|
823
|
+
if (options?.signal) {
|
|
824
|
+
if (options.signal.aborted) controller.abort();
|
|
825
|
+
else options.signal.addEventListener("abort", onCallerAbort, { once: true });
|
|
826
|
+
}
|
|
827
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
828
|
+
let response;
|
|
829
|
+
try {
|
|
830
|
+
response = await fetchWithNetworkRetry(
|
|
831
|
+
`${this.baseUrl}/v1/checkouts/sessions/${encodeURIComponent(sessionId)}/account`,
|
|
832
|
+
{
|
|
833
|
+
method: "PATCH",
|
|
834
|
+
headers: {
|
|
835
|
+
"Content-Type": "application/json",
|
|
836
|
+
"x-checkout-session-token": nonce
|
|
837
|
+
},
|
|
838
|
+
body: JSON.stringify(body),
|
|
839
|
+
signal: controller.signal
|
|
840
|
+
}
|
|
841
|
+
);
|
|
842
|
+
} finally {
|
|
843
|
+
clearTimeout(timer);
|
|
844
|
+
options?.signal?.removeEventListener("abort", onCallerAbort);
|
|
845
|
+
}
|
|
830
846
|
if (!response.ok) {
|
|
831
847
|
throw await buildApiErrorFromResponse(response, "Failed to persist account snapshot");
|
|
832
848
|
}
|