@base44-preview/sdk 0.8.58-beta.0-pr.366.ad93094 → 0.8.58-beta.0-pr.366.dccfb00
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.
|
@@ -146,6 +146,8 @@ checkout, options, deps) {
|
|
|
146
146
|
}
|
|
147
147
|
let destroyed = false;
|
|
148
148
|
let completing = false;
|
|
149
|
+
// Set once a payment goes through: another click would create and charge a second order.
|
|
150
|
+
let paid = false;
|
|
149
151
|
let starting = false;
|
|
150
152
|
let checkoutId = typeof checkout === "string" ? checkout : undefined;
|
|
151
153
|
// App callbacks run only while mounted, and their own errors never reach PayPal or onError.
|
|
@@ -180,6 +182,7 @@ checkout, options, deps) {
|
|
|
180
182
|
return;
|
|
181
183
|
}
|
|
182
184
|
completing = false;
|
|
185
|
+
paid = true;
|
|
183
186
|
notify(() => { var _a; return (_a = options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options, result); });
|
|
184
187
|
},
|
|
185
188
|
onCancel() {
|
|
@@ -191,7 +194,7 @@ checkout, options, deps) {
|
|
|
191
194
|
});
|
|
192
195
|
button.setAttribute("type", subscription ? "subscribe" : "pay");
|
|
193
196
|
const onClick = () => {
|
|
194
|
-
if (completing || starting || button.disabled)
|
|
197
|
+
if (paid || completing || starting || button.disabled)
|
|
195
198
|
return;
|
|
196
199
|
starting = true;
|
|
197
200
|
// Not awaited before start(), which must run inside the click to open PayPal's popup.
|
|
@@ -227,8 +230,8 @@ checkout, options, deps) {
|
|
|
227
230
|
(_a = session.destroy) === null || _a === void 0 ? void 0 : _a.call(session);
|
|
228
231
|
},
|
|
229
232
|
setDisabled(disabled) {
|
|
230
|
-
// A payment being completed keeps the button off whatever the app asks.
|
|
231
|
-
if (!completing)
|
|
233
|
+
// A payment being completed, or already made, keeps the button off whatever the app asks.
|
|
234
|
+
if (!completing && !paid)
|
|
232
235
|
button.disabled = disabled;
|
|
233
236
|
},
|
|
234
237
|
};
|
|
@@ -371,7 +371,7 @@ export interface PayPalCheckoutOnClick {
|
|
|
371
371
|
export interface CheckoutMount {
|
|
372
372
|
/** Removes the checkout from the page. Call it when the component that holds it unmounts. For Stripe, mounting another checkout destroys this one for you. */
|
|
373
373
|
destroy: () => void;
|
|
374
|
-
/** PayPal: greys out the button and ignores clicks, for example until a required form is filled in. Stripe ignores it. */
|
|
374
|
+
/** PayPal: greys out the button and ignores clicks, for example until a required form is filled in. After a payment completes the button stays off, so `setDisabled(false)` can't start a second payment. Stripe ignores it. */
|
|
375
375
|
setDisabled: (disabled: boolean) => void;
|
|
376
376
|
}
|
|
377
377
|
/**
|