0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Added redirect after a successful donation (#17551)

refs https://github.com/TryGhost/Product/issues/3650
This commit is contained in:
Sag 2023-08-01 14:39:59 +02:00 committed by GitHub
parent c17b44613b
commit 6d85ea4425
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View file

@ -14,18 +14,19 @@ const SupportPage = () => {
async function checkoutDonation() {
const siteUrl = window.location.origin;
const currentUrl = siteUrl + window.location.pathname;
const api = setupGhostApi({siteUrl});
const successUrl = `${currentUrl}#/portal/support/success`;
const cancelUrl = `${currentUrl}#/portal/support/error`;
const api = setupGhostApi({siteUrl});
try {
await api.member.checkoutDonation({successUrl, cancelUrl});
} catch (err) {
if (err.message) {
setError(err.message);
} else {
setError('There was an error processing your payment. Please try again.');
const response = await api.member.checkoutDonation({successUrl, cancelUrl});
if (response.url) {
await window.location.assign(response.url);
}
} catch (err) {
const errorMessage = err.message || 'There was an error processing your payment. Please try again.';
setError(errorMessage);
} finally {
setLoading(false);
}

View file

@ -408,7 +408,7 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
};
const body = {
identity: identity,
identity,
metadata: metadataObj,
successUrl,
cancelUrl,