mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
chore(promo): end G1G1 deal
This commit is contained in:
@@ -209,7 +209,7 @@ describe('payments/index', () => {
|
|||||||
await api.createSubscription(data);
|
await api.createSubscription(data);
|
||||||
let msg = '\`Hello recipient, sender has sent you 3 months of subscription!\`';
|
let msg = '\`Hello recipient, sender has sent you 3 months of subscription!\`';
|
||||||
|
|
||||||
expect(user.sendMessage).to.be.calledTwice;
|
expect(user.sendMessage).to.be.calledOnce;
|
||||||
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: msg, senderMsg: msg, save: false });
|
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: msg, senderMsg: msg, save: false });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -247,77 +247,6 @@ describe('payments/index', () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('Winter 2018-19 Gift-1-Get-1 Promotion', async () => {
|
|
||||||
it('creates a gift subscription for purchaser and recipient if none exist', async () => {
|
|
||||||
await api.createSubscription(data);
|
|
||||||
|
|
||||||
expect(user.items.pets['Jackalope-RoyalPurple']).to.eql(5);
|
|
||||||
expect(user.purchased.plan.customerId).to.eql('Gift');
|
|
||||||
expect(user.purchased.plan.dateTerminated).to.exist;
|
|
||||||
expect(user.purchased.plan.dateUpdated).to.exist;
|
|
||||||
expect(user.purchased.plan.dateCreated).to.exist;
|
|
||||||
|
|
||||||
expect(recipient.items.pets['Jackalope-RoyalPurple']).to.eql(5);
|
|
||||||
expect(recipient.purchased.plan.customerId).to.eql('Gift');
|
|
||||||
expect(recipient.purchased.plan.dateTerminated).to.exist;
|
|
||||||
expect(recipient.purchased.plan.dateUpdated).to.exist;
|
|
||||||
expect(recipient.purchased.plan.dateCreated).to.exist;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds extraMonths to existing subscription for purchaser and creates a gift subscription for recipient without sub', async () => {
|
|
||||||
user.purchased.plan = plan;
|
|
||||||
|
|
||||||
expect(user.purchased.plan.extraMonths).to.eql(0);
|
|
||||||
|
|
||||||
await api.createSubscription(data);
|
|
||||||
|
|
||||||
expect(user.purchased.plan.extraMonths).to.eql(3);
|
|
||||||
|
|
||||||
expect(recipient.items.pets['Jackalope-RoyalPurple']).to.eql(5);
|
|
||||||
expect(recipient.purchased.plan.customerId).to.eql('Gift');
|
|
||||||
expect(recipient.purchased.plan.dateTerminated).to.exist;
|
|
||||||
expect(recipient.purchased.plan.dateUpdated).to.exist;
|
|
||||||
expect(recipient.purchased.plan.dateCreated).to.exist;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds extraMonths to existing subscription for recipient and creates a gift subscription for purchaser without sub', async () => {
|
|
||||||
recipient.purchased.plan = plan;
|
|
||||||
|
|
||||||
expect(recipient.purchased.plan.extraMonths).to.eql(0);
|
|
||||||
|
|
||||||
await api.createSubscription(data);
|
|
||||||
|
|
||||||
expect(recipient.purchased.plan.extraMonths).to.eql(3);
|
|
||||||
|
|
||||||
expect(user.items.pets['Jackalope-RoyalPurple']).to.eql(5);
|
|
||||||
expect(user.purchased.plan.customerId).to.eql('Gift');
|
|
||||||
expect(user.purchased.plan.dateTerminated).to.exist;
|
|
||||||
expect(user.purchased.plan.dateUpdated).to.exist;
|
|
||||||
expect(user.purchased.plan.dateCreated).to.exist;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds extraMonths to existing subscriptions for purchaser and recipient', async () => {
|
|
||||||
user.purchased.plan = plan;
|
|
||||||
recipient.purchased.plan = plan;
|
|
||||||
|
|
||||||
expect(user.purchased.plan.extraMonths).to.eql(0);
|
|
||||||
expect(recipient.purchased.plan.extraMonths).to.eql(0);
|
|
||||||
|
|
||||||
await api.createSubscription(data);
|
|
||||||
|
|
||||||
expect(user.purchased.plan.extraMonths).to.eql(3);
|
|
||||||
expect(recipient.purchased.plan.extraMonths).to.eql(3);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('sends a private message about the promotion', async () => {
|
|
||||||
await api.createSubscription(data);
|
|
||||||
let msg = '\`Hello sender, you received 3 months of subscription as part of our holiday gift-giving promotion!\`';
|
|
||||||
|
|
||||||
expect(user.sendMessage).to.be.calledTwice;
|
|
||||||
expect(user.sendMessage).to.be.calledWith(user, { senderMsg: msg });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context('Purchasing a subscription for self', () => {
|
context('Purchasing a subscription for self', () => {
|
||||||
|
|||||||
@@ -24,12 +24,6 @@ div
|
|||||||
span.resume(@click="resumeDamage()") {{ $t('resumeDamage') }}
|
span.resume(@click="resumeDamage()") {{ $t('resumeDamage') }}
|
||||||
.closepadding(@click="hideBanner()")
|
.closepadding(@click="hideBanner()")
|
||||||
span.svg-icon.inline.icon-10(aria-hidden="true", v-html="icons.close")
|
span.svg-icon.inline.icon-10(aria-hidden="true", v-html="icons.close")
|
||||||
.g1g1-banner.d-flex.justify-content-center.align-items-center(v-if="!giftingHidden")
|
|
||||||
.svg-icon.svg-gifts.left-gift(v-html="icons.gifts")
|
|
||||||
router-link(:to="{name: 'subscription'}") {{ $t('g1g1Announcement') }}
|
|
||||||
.svg-icon.svg-gifts.right-gift(v-html="icons.gifts")
|
|
||||||
.closepadding(@click="hideGiftingBanner()")
|
|
||||||
span.svg-icon.inline.icon-10(aria-hidden="true", v-html="icons.close")
|
|
||||||
notifications-display
|
notifications-display
|
||||||
app-menu
|
app-menu
|
||||||
.container-fluid
|
.container-fluid
|
||||||
@@ -97,41 +91,6 @@ div
|
|||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.g1g1-banner {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 2.5rem;
|
|
||||||
background-color: #34b5c1;
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: $white;
|
|
||||||
text-decoration: none;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.closepadding {
|
|
||||||
margin: 11px 24px;
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.left-gift {
|
|
||||||
margin: auto 1rem auto auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-gift {
|
|
||||||
margin: auto auto auto 1rem;
|
|
||||||
filter: FlipH;
|
|
||||||
transform: scaleX(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.svg-gifts {
|
|
||||||
width: 4.6rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.notification {
|
.notification {
|
||||||
border-radius: 1000px;
|
border-radius: 1000px;
|
||||||
background-color: $green-10;
|
background-color: $green-10;
|
||||||
@@ -230,9 +189,8 @@ import amazonPaymentsModal from 'client/components/payments/amazonModal';
|
|||||||
import paymentsSuccessModal from 'client/components/payments/successModal';
|
import paymentsSuccessModal from 'client/components/payments/successModal';
|
||||||
|
|
||||||
import spellsMixin from 'client/mixins/spells';
|
import spellsMixin from 'client/mixins/spells';
|
||||||
import { CONSTANTS, getLocalSetting, removeLocalSetting, setLocalSetting } from 'client/libs/userlocalManager';
|
import { CONSTANTS, getLocalSetting, removeLocalSetting } from 'client/libs/userlocalManager';
|
||||||
|
|
||||||
import gifts from 'assets/svg/gifts.svg';
|
|
||||||
import svgClose from 'assets/svg/close.svg';
|
import svgClose from 'assets/svg/close.svg';
|
||||||
import bannedAccountModal from 'client/components/bannedAccountModal';
|
import bannedAccountModal from 'client/components/bannedAccountModal';
|
||||||
|
|
||||||
@@ -257,7 +215,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
icons: Object.freeze({
|
icons: Object.freeze({
|
||||||
close: svgClose,
|
close: svgClose,
|
||||||
gifts,
|
|
||||||
}),
|
}),
|
||||||
selectedItemToBuy: null,
|
selectedItemToBuy: null,
|
||||||
selectedSpellToBuy: null,
|
selectedSpellToBuy: null,
|
||||||
@@ -268,8 +225,6 @@ export default {
|
|||||||
loading: true,
|
loading: true,
|
||||||
currentTipNumber: 0,
|
currentTipNumber: 0,
|
||||||
bannerHidden: false,
|
bannerHidden: false,
|
||||||
bannerHeight: 0,
|
|
||||||
giftingHidden: getLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY) === 'dismissed',
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -660,10 +615,6 @@ export default {
|
|||||||
hideBanner () {
|
hideBanner () {
|
||||||
this.bannerHidden = true;
|
this.bannerHidden = true;
|
||||||
},
|
},
|
||||||
hideGiftingBanner () {
|
|
||||||
setLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY, 'dismissed');
|
|
||||||
this.giftingHidden = true;
|
|
||||||
},
|
|
||||||
resumeDamage () {
|
resumeDamage () {
|
||||||
this.$store.dispatch('user:sleep');
|
this.$store.dispatch('user:sleep');
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ b-modal#send-gems(:title="title", :hide-footer="true", size='lg', @hide='onHide(
|
|||||||
label
|
label
|
||||||
input(type="radio", name="subRadio", :value="block.key", v-model='gift.subscription.key')
|
input(type="radio", name="subRadio", :value="block.key", v-model='gift.subscription.key')
|
||||||
| {{ $t('sendGiftSubscription', {price: block.price, months: block.months}) }}
|
| {{ $t('sendGiftSubscription', {price: block.price, months: block.months}) }}
|
||||||
.col-md-8
|
|
||||||
h4 {{ $t('winterPromoGiftHeader') }}
|
|
||||||
p {{ $t('winterPromoGiftDetails1') }}
|
|
||||||
p {{ $t('winterPromoGiftDetails2') }}
|
|
||||||
|
|
||||||
textarea.form-control(rows='3', v-model='gift.message', :placeholder="$t('sendGiftMessagePlaceholder')")
|
textarea.form-control(rows='3', v-model='gift.message', :placeholder="$t('sendGiftMessagePlaceholder')")
|
||||||
//include ../formatting-help
|
//include ../formatting-help
|
||||||
|
|||||||
@@ -90,10 +90,6 @@
|
|||||||
li(v-once) {{ $t('giftSubscriptionText2') }}
|
li(v-once) {{ $t('giftSubscriptionText2') }}
|
||||||
li(v-once) {{ $t('giftSubscriptionText3') }}
|
li(v-once) {{ $t('giftSubscriptionText3') }}
|
||||||
h4(v-once) {{ $t('giftSubscriptionText4') }}
|
h4(v-once) {{ $t('giftSubscriptionText4') }}
|
||||||
.col-6
|
|
||||||
h2 {{ $t('winterPromoGiftHeader') }}
|
|
||||||
p {{ $t('winterPromoGiftDetails1') }}
|
|
||||||
p {{ $t('winterPromoGiftDetails2') }}
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -12,10 +12,6 @@
|
|||||||
z-index: 1400; // 1400 is above modal backgrounds
|
z-index: 1400; // 1400 is above modal backgrounds
|
||||||
|
|
||||||
&-top-pos {
|
&-top-pos {
|
||||||
&-double {
|
|
||||||
top: 145px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-normal {
|
&-normal {
|
||||||
top: 65px;
|
top: 65px;
|
||||||
}
|
}
|
||||||
@@ -30,7 +26,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapState } from 'client/libs/store';
|
import { mapState } from 'client/libs/store';
|
||||||
import notification from './notification';
|
import notification from './notification';
|
||||||
import { CONSTANTS, getLocalSetting } from 'client/libs/userlocalManager';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -44,9 +39,7 @@ export default {
|
|||||||
notificationsTopPos () {
|
notificationsTopPos () {
|
||||||
const base = 'notifications-top-pos-';
|
const base = 'notifications-top-pos-';
|
||||||
let modifier = '';
|
let modifier = '';
|
||||||
if (this.userSleeping && this.giftingShown) {
|
if (this.userSleeping) {
|
||||||
modifier = 'double';
|
|
||||||
} else if (this.userSleeping || this.giftingShown) {
|
|
||||||
modifier = 'sleeping';
|
modifier = 'sleeping';
|
||||||
} else {
|
} else {
|
||||||
modifier = 'normal';
|
modifier = 'normal';
|
||||||
@@ -54,10 +47,5 @@ export default {
|
|||||||
return `${base}${modifier}`;
|
return `${base}${modifier}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
giftingShown: getLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY) !== 'dismissed',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ const CONSTANTS = {
|
|||||||
EQUIPMENT_DRAWER_STATE: 'equipment-drawer-state',
|
EQUIPMENT_DRAWER_STATE: 'equipment-drawer-state',
|
||||||
CURRENT_EQUIPMENT_DRAWER_TAB: 'current-equipment-drawer-tab',
|
CURRENT_EQUIPMENT_DRAWER_TAB: 'current-equipment-drawer-tab',
|
||||||
STABLE_SORT_STATE: 'stable-sort-state',
|
STABLE_SORT_STATE: 'stable-sort-state',
|
||||||
GIFTING_BANNER_DISPLAY: 'gifting-banner-display',
|
|
||||||
},
|
},
|
||||||
drawerStateValues: {
|
drawerStateValues: {
|
||||||
DRAWER_CLOSED: 'drawer-closed',
|
DRAWER_CLOSED: 'drawer-closed',
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ async function createSubscription (data) {
|
|||||||
txnEmail(data.user, emailType);
|
txnEmail(data.user, emailType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.promo) {
|
|
||||||
analytics.trackPurchase({
|
analytics.trackPurchase({
|
||||||
uuid: data.user._id,
|
uuid: data.user._id,
|
||||||
groupId,
|
groupId,
|
||||||
@@ -161,24 +160,14 @@ async function createSubscription (data) {
|
|||||||
purchaseValue: block.price,
|
purchaseValue: block.price,
|
||||||
headers: data.headers,
|
headers: data.headers,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (!group && !data.promo) data.user.purchased.txnCount++;
|
if (!group) data.user.purchased.txnCount++;
|
||||||
|
|
||||||
if (data.gift) {
|
if (data.gift) {
|
||||||
let byUserName = getUserInfo(data.user, ['name']).name;
|
let byUserName = getUserInfo(data.user, ['name']).name;
|
||||||
|
|
||||||
// generate the message in both languages, so both users can understand it
|
// generate the message in both languages, so both users can understand it
|
||||||
let languages = [data.user.preferences.language, data.gift.member.preferences.language];
|
let languages = [data.user.preferences.language, data.gift.member.preferences.language];
|
||||||
if (data.promo) {
|
|
||||||
let senderMsg = shared.i18n.t(`giftedSubscription${data.promo}Promo`, {
|
|
||||||
username: data.gift.member.profile.name,
|
|
||||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
|
||||||
}, languages[0]);
|
|
||||||
|
|
||||||
senderMsg = `\`${senderMsg}\``;
|
|
||||||
data.user.sendMessage(data.gift.member, { senderMsg });
|
|
||||||
} else {
|
|
||||||
let senderMsg = shared.i18n.t('giftedSubscriptionFull', {
|
let senderMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||||
username: data.gift.member.profile.name,
|
username: data.gift.member.profile.name,
|
||||||
sender: byUserName,
|
sender: byUserName,
|
||||||
@@ -199,37 +188,15 @@ async function createSubscription (data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.user.sendMessage(data.gift.member, { receiverMsg, senderMsg, save: false });
|
data.user.sendMessage(data.gift.member, { receiverMsg, senderMsg, save: false });
|
||||||
}
|
|
||||||
|
|
||||||
if (data.gift.member.preferences.emailNotifications.giftedSubscription !== false) {
|
if (data.gift.member.preferences.emailNotifications.giftedSubscription !== false) {
|
||||||
if (data.promo) {
|
|
||||||
txnEmail(data.gift.member, 'gift-one-get-one', [
|
|
||||||
{name: 'GIFTEE_USERNAME', content: data.promoUsername},
|
|
||||||
{name: 'X_MONTHS_SUBSCRIPTION', content: months},
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
txnEmail(data.gift.member, 'gifted-subscription', [
|
txnEmail(data.gift.member, 'gifted-subscription', [
|
||||||
{name: 'GIFTER', content: byUserName},
|
{name: 'GIFTER', content: byUserName},
|
||||||
{name: 'X_MONTHS_SUBSCRIPTION', content: months},
|
{name: 'X_MONTHS_SUBSCRIPTION', content: months},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (data.gift.member._id !== data.user._id) { // If sending to a user other than yourself, don't push notify, and get bonus sub for self per holiday promo
|
|
||||||
let promoData = {
|
|
||||||
user: data.user,
|
|
||||||
gift: {
|
|
||||||
member: data.user,
|
|
||||||
subscription: {
|
|
||||||
key: data.gift.subscription.key,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
paymentMethod: data.paymentMethod,
|
|
||||||
promo: 'Winter',
|
|
||||||
promoUsername: data.gift.member.auth.local.username,
|
|
||||||
};
|
|
||||||
await this.createSubscription(promoData);
|
|
||||||
|
|
||||||
|
if (data.gift.member._id !== data.user._id) { // Only send push notifications if sending to a user other than yourself
|
||||||
if (data.gift.member.preferences.pushNotifications.giftedSubscription !== false) {
|
if (data.gift.member.preferences.pushNotifications.giftedSubscription !== false) {
|
||||||
sendPushNotification(data.gift.member,
|
sendPushNotification(data.gift.member,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ function sendSubscriptionNotification ({
|
|||||||
let text;
|
let text;
|
||||||
let timestamp = new Date();
|
let timestamp = new Date();
|
||||||
if (recipient.id) {
|
if (recipient.id) {
|
||||||
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a ${months}-month gift subscription for ${recipient.name} ${recipient.id} ${recipient.email} and got a promo using ${paymentMethod} on ${timestamp}`;
|
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a ${months}-month gift subscription for ${recipient.name} ${recipient.id} ${recipient.email} using ${paymentMethod} on ${timestamp}`;
|
||||||
} else if (groupId) {
|
} else if (groupId) {
|
||||||
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a 1-month recurring group-plan for ${groupId} using ${paymentMethod} on ${timestamp}`;
|
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a 1-month recurring group-plan for ${groupId} using ${paymentMethod} on ${timestamp}`;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user