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);
|
||||
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 });
|
||||
});
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -24,12 +24,6 @@ div
|
||||
span.resume(@click="resumeDamage()") {{ $t('resumeDamage') }}
|
||||
.closepadding(@click="hideBanner()")
|
||||
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
|
||||
app-menu
|
||||
.container-fluid
|
||||
@@ -97,41 +91,6 @@ div
|
||||
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 {
|
||||
border-radius: 1000px;
|
||||
background-color: $green-10;
|
||||
@@ -230,9 +189,8 @@ import amazonPaymentsModal from 'client/components/payments/amazonModal';
|
||||
import paymentsSuccessModal from 'client/components/payments/successModal';
|
||||
|
||||
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 bannedAccountModal from 'client/components/bannedAccountModal';
|
||||
|
||||
@@ -257,7 +215,6 @@ export default {
|
||||
return {
|
||||
icons: Object.freeze({
|
||||
close: svgClose,
|
||||
gifts,
|
||||
}),
|
||||
selectedItemToBuy: null,
|
||||
selectedSpellToBuy: null,
|
||||
@@ -268,8 +225,6 @@ export default {
|
||||
loading: true,
|
||||
currentTipNumber: 0,
|
||||
bannerHidden: false,
|
||||
bannerHeight: 0,
|
||||
giftingHidden: getLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY) === 'dismissed',
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -660,10 +615,6 @@ export default {
|
||||
hideBanner () {
|
||||
this.bannerHidden = true;
|
||||
},
|
||||
hideGiftingBanner () {
|
||||
setLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY, 'dismissed');
|
||||
this.giftingHidden = true;
|
||||
},
|
||||
resumeDamage () {
|
||||
this.$store.dispatch('user:sleep');
|
||||
},
|
||||
|
||||
@@ -38,10 +38,6 @@ b-modal#send-gems(:title="title", :hide-footer="true", size='lg', @hide='onHide(
|
||||
label
|
||||
input(type="radio", name="subRadio", :value="block.key", v-model='gift.subscription.key')
|
||||
| {{ $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')")
|
||||
//include ../formatting-help
|
||||
|
||||
@@ -90,10 +90,6 @@
|
||||
li(v-once) {{ $t('giftSubscriptionText2') }}
|
||||
li(v-once) {{ $t('giftSubscriptionText3') }}
|
||||
h4(v-once) {{ $t('giftSubscriptionText4') }}
|
||||
.col-6
|
||||
h2 {{ $t('winterPromoGiftHeader') }}
|
||||
p {{ $t('winterPromoGiftDetails1') }}
|
||||
p {{ $t('winterPromoGiftDetails2') }}
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
z-index: 1400; // 1400 is above modal backgrounds
|
||||
|
||||
&-top-pos {
|
||||
&-double {
|
||||
top: 145px;
|
||||
}
|
||||
|
||||
&-normal {
|
||||
top: 65px;
|
||||
}
|
||||
@@ -30,7 +26,6 @@
|
||||
<script>
|
||||
import { mapState } from 'client/libs/store';
|
||||
import notification from './notification';
|
||||
import { CONSTANTS, getLocalSetting } from 'client/libs/userlocalManager';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -44,9 +39,7 @@ export default {
|
||||
notificationsTopPos () {
|
||||
const base = 'notifications-top-pos-';
|
||||
let modifier = '';
|
||||
if (this.userSleeping && this.giftingShown) {
|
||||
modifier = 'double';
|
||||
} else if (this.userSleeping || this.giftingShown) {
|
||||
if (this.userSleeping) {
|
||||
modifier = 'sleeping';
|
||||
} else {
|
||||
modifier = 'normal';
|
||||
@@ -54,10 +47,5 @@ export default {
|
||||
return `${base}${modifier}`;
|
||||
},
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
giftingShown: getLocalSetting(CONSTANTS.keyConstants.GIFTING_BANNER_DISPLAY) !== 'dismissed',
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -5,7 +5,6 @@ const CONSTANTS = {
|
||||
EQUIPMENT_DRAWER_STATE: 'equipment-drawer-state',
|
||||
CURRENT_EQUIPMENT_DRAWER_TAB: 'current-equipment-drawer-tab',
|
||||
STABLE_SORT_STATE: 'stable-sort-state',
|
||||
GIFTING_BANNER_DISPLAY: 'gifting-banner-display',
|
||||
},
|
||||
drawerStateValues: {
|
||||
DRAWER_CLOSED: 'drawer-closed',
|
||||
|
||||
@@ -148,88 +148,55 @@ async function createSubscription (data) {
|
||||
txnEmail(data.user, emailType);
|
||||
}
|
||||
|
||||
if (!data.promo) {
|
||||
analytics.trackPurchase({
|
||||
uuid: data.user._id,
|
||||
groupId,
|
||||
itemPurchased,
|
||||
sku: `${data.paymentMethod.toLowerCase()}-subscription`,
|
||||
purchaseType,
|
||||
paymentMethod: data.paymentMethod,
|
||||
quantity: 1,
|
||||
gift: Boolean(data.gift),
|
||||
purchaseValue: block.price,
|
||||
headers: data.headers,
|
||||
});
|
||||
}
|
||||
analytics.trackPurchase({
|
||||
uuid: data.user._id,
|
||||
groupId,
|
||||
itemPurchased,
|
||||
sku: `${data.paymentMethod.toLowerCase()}-subscription`,
|
||||
purchaseType,
|
||||
paymentMethod: data.paymentMethod,
|
||||
quantity: 1,
|
||||
gift: Boolean(data.gift),
|
||||
purchaseValue: block.price,
|
||||
headers: data.headers,
|
||||
});
|
||||
|
||||
if (!group && !data.promo) data.user.purchased.txnCount++;
|
||||
if (!group) data.user.purchased.txnCount++;
|
||||
|
||||
if (data.gift) {
|
||||
let byUserName = getUserInfo(data.user, ['name']).name;
|
||||
|
||||
// generate the message in both languages, so both users can understand it
|
||||
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]);
|
||||
let senderMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[0]);
|
||||
senderMsg = `\`${senderMsg}\``;
|
||||
|
||||
senderMsg = `\`${senderMsg}\``;
|
||||
data.user.sendMessage(data.gift.member, { senderMsg });
|
||||
} else {
|
||||
let senderMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[0]);
|
||||
senderMsg = `\`${senderMsg}\``;
|
||||
let receiverMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[1]);
|
||||
receiverMsg = `\`${receiverMsg}\``;
|
||||
|
||||
let receiverMsg = shared.i18n.t('giftedSubscriptionFull', {
|
||||
username: data.gift.member.profile.name,
|
||||
sender: byUserName,
|
||||
monthCount: shared.content.subscriptionBlocks[data.gift.subscription.key].months,
|
||||
}, languages[1]);
|
||||
receiverMsg = `\`${receiverMsg}\``;
|
||||
|
||||
if (data.gift.message) {
|
||||
receiverMsg += ` ${data.gift.message}`;
|
||||
senderMsg += ` ${data.gift.message}`;
|
||||
}
|
||||
|
||||
data.user.sendMessage(data.gift.member, { receiverMsg, senderMsg, save: false });
|
||||
if (data.gift.message) {
|
||||
receiverMsg += ` ${data.gift.message}`;
|
||||
senderMsg += ` ${data.gift.message}`;
|
||||
}
|
||||
|
||||
data.user.sendMessage(data.gift.member, { receiverMsg, senderMsg, save: 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', [
|
||||
{name: 'GIFTER', content: byUserName},
|
||||
{name: 'X_MONTHS_SUBSCRIPTION', content: months},
|
||||
]);
|
||||
}
|
||||
txnEmail(data.gift.member, 'gifted-subscription', [
|
||||
{name: 'GIFTER', content: byUserName},
|
||||
{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) {
|
||||
sendPushNotification(data.gift.member,
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ function sendSubscriptionNotification ({
|
||||
let text;
|
||||
let timestamp = new Date();
|
||||
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) {
|
||||
text = `${buyer.name} ${buyer.id} ${buyer.email} bought a 1-month recurring group-plan for ${groupId} using ${paymentMethod} on ${timestamp}`;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user