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:
parent
c17b44613b
commit
6d85ea4425
2 changed files with 9 additions and 8 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -408,7 +408,7 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
|
|||
};
|
||||
|
||||
const body = {
|
||||
identity: identity,
|
||||
identity,
|
||||
metadata: metadataObj,
|
||||
successUrl,
|
||||
cancelUrl,
|
||||
|
|
Loading…
Add table
Reference in a new issue