mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
🐛 Fixed extra email sent for logged in members on upgrade
refs https://github.com/TryGhost/Team/issues/695
refs 212be5fb02
(Patch)
Currently when we have a successful Stripe checkout session, we will always send the member an email confirming their signup when using data-members-* attributes.
This is considered a bug for members who have signed up as a free member first, meaning they have already received this email. This change passes a `checkoutType` metadata same as Portal to not send the email when member is already logged in.
This commit is contained in:
parent
4e14d811bf
commit
fd6fee4c9d
2 changed files with 8 additions and 3 deletions
|
@ -59,7 +59,8 @@ export default class App extends React.Component {
|
|||
const contextState = this.getContextFromState();
|
||||
handleDataAttributes({
|
||||
siteUrl,
|
||||
site: contextState.site
|
||||
site: contextState.site,
|
||||
member: contextState.member
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const {getQueryPrice} = require('./utils/helpers');
|
||||
|
||||
function handleDataAttributes({siteUrl, site}) {
|
||||
function handleDataAttributes({siteUrl, site, member}) {
|
||||
siteUrl = siteUrl.replace(/\/$/, '');
|
||||
Array.prototype.forEach.call(document.querySelectorAll('form[data-members-form]'), function (form) {
|
||||
let errorEl = form.querySelector('[data-members-error]');
|
||||
|
@ -85,6 +85,9 @@ function handleDataAttributes({siteUrl, site}) {
|
|||
errorEl.innerText = '';
|
||||
}
|
||||
el.classList.add('loading');
|
||||
const metadata = member ? {
|
||||
checkoutType: 'upgrade'
|
||||
} : {};
|
||||
fetch(`${siteUrl}/members/api/session`, {
|
||||
credentials: 'same-origin'
|
||||
}).then(function (res) {
|
||||
|
@ -102,7 +105,8 @@ function handleDataAttributes({siteUrl, site}) {
|
|||
priceId: priceId,
|
||||
identity: identity,
|
||||
successUrl: checkoutSuccessUrl,
|
||||
cancelUrl: checkoutCancelUrl
|
||||
cancelUrl: checkoutCancelUrl,
|
||||
metadata
|
||||
})
|
||||
}).then(function (res) {
|
||||
if (!res.ok) {
|
||||
|
|
Loading…
Add table
Reference in a new issue