2d091fc667
* upgrade stripe module * switch stripe api to latest version * fix api version in tests * start upgrading client and server * client: switch to redirect * implement checkout session creation for gems, start implementing webhooks * stripe: start refactoring one time payments * working gems and gift payments * start adding support for subscriptions * stripe: migrate subscriptions and fix cancelling sub * allow upgrading group plans * remove console.log statements * group plans: upgrade from static page / create new one * fix #11885, correct group plan modal title * silence more stripe webhooks * fix group plans redirects * implement editing payment method * start cleaning up code * fix(stripe): update in-code docs, fix eslint issues * subscriptions tests * remove and skip old tests * skip integration tests * fix client build * stripe webhooks: throw error if request fails * subscriptions: correctly pass groupId * remove console.log * stripe: add unit tests for one time payments * wip: stripe checkout tests * stripe createCheckoutSession unit tests * stripe createCheckoutSession unit tests * stripe createCheckoutSession unit tests (editing card) * fix existing webhooks tests * add new webhooks tests * add more webhooks tests * fix lint * stripe integration tests * better error handling when retrieving customer from stripe * client: remove unused strings and improve error handling * payments: limit gift message length (server) * payments: limit gift message length (client) * fix redirects when payment is cancelled * add back "subUpdateCard" string * fix redirects when editing a sub card, use proper names for products, check subs when gifting
138 lines
3.8 KiB
Vue
138 lines
3.8 KiB
Vue
<template>
|
|
<div id="subscription-form">
|
|
<b-form-group class="mb-4 w-100 h-100">
|
|
<!-- eslint-disable vue/no-use-v-if-with-v-for -->
|
|
<b-form-radio
|
|
v-for="block in subscriptionBlocksOrdered"
|
|
v-if="block.target !== 'group' && block.canSubscribe === true"
|
|
:key="block.key"
|
|
v-model="subscription.key"
|
|
:value="block.key"
|
|
class="subscribe-option pt-2 pl-5 pb-3 mb-0"
|
|
:class="{selected: subscription.key === block.key}"
|
|
@click.native="subscription.key = block.key"
|
|
>
|
|
<!-- eslint-enable vue/no-use-v-if-with-v-for -->
|
|
<div
|
|
class="subscription-text ml-2 mb-1"
|
|
v-html="$t('subscriptionRateText', {price: block.price, months: block.months})"
|
|
>
|
|
</div>
|
|
<div
|
|
class="ml-2"
|
|
v-html="subscriptionBubbles(block.key)"
|
|
>
|
|
</div>
|
|
</b-form-radio>
|
|
</b-form-group>
|
|
<payments-buttons
|
|
:disabled="!subscription.key"
|
|
:stripe-fn="() => redirectToStripe({
|
|
subscription: subscription.key,
|
|
coupon: subscription.coupon,
|
|
})"
|
|
:paypal-fn="() => openPaypal({url: paypalPurchaseLink, type: 'subscription'})"
|
|
:amazon-data="{
|
|
type: 'subscription',
|
|
subscription: subscription.key,
|
|
coupon: subscription.coupon
|
|
}"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
|
|
<style lang="scss">
|
|
@import '~@/assets/scss/colors.scss';
|
|
#subscription-form {
|
|
.custom-control .custom-control-label::before,
|
|
.custom-radio .custom-control-input:checked ~ .custom-control-label::after {
|
|
margin-top: 0.75rem;
|
|
}
|
|
|
|
.selected {
|
|
background-color: rgba(213, 200, 255, 0.32);
|
|
|
|
.subscription-bubble {
|
|
background-color: $purple-300;
|
|
color: $white;
|
|
}
|
|
.subscription-text {
|
|
color: $purple-200;
|
|
}
|
|
}
|
|
|
|
.subscription-bubble, .discount-bubble {
|
|
border-radius: 100px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.subscription-bubble {
|
|
background-color: $gray-600;
|
|
color: $gray-200;
|
|
}
|
|
|
|
.discount-bubble {
|
|
background-color: $green-10;
|
|
color: $white;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<style lang="scss" scoped>
|
|
@import '~@/assets/scss/colors.scss';
|
|
|
|
.subscribe-option {
|
|
border-bottom: 1px solid $gray-600;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
import filter from 'lodash/filter';
|
|
import sortBy from 'lodash/sortBy';
|
|
|
|
import paymentsButtons from '@/components/payments/buttons/list';
|
|
import paymentsMixin from '../../mixins/payments';
|
|
import subscriptionBlocks from '@/../../common/script/content/subscriptionBlocks';
|
|
|
|
export default {
|
|
components: {
|
|
paymentsButtons,
|
|
},
|
|
mixins: [
|
|
paymentsMixin,
|
|
],
|
|
data () {
|
|
return {
|
|
subscription: {
|
|
key: null,
|
|
},
|
|
};
|
|
},
|
|
computed: {
|
|
subscriptionBlocks () {
|
|
return subscriptionBlocks;
|
|
},
|
|
subscriptionBlocksOrdered () {
|
|
const subscriptions = filter(subscriptionBlocks, o => o.discount !== true);
|
|
|
|
return sortBy(subscriptions, [o => o.months]);
|
|
},
|
|
},
|
|
methods: {
|
|
subscriptionBubbles (subscription) {
|
|
switch (subscription) {
|
|
case 'basic_3mo':
|
|
return '<span class="subscription-bubble px-2 py-1 mr-1">Gem cap raised to 30</span><span class="subscription-bubble px-2 py-1">+1 Mystic Hourglass</span>';
|
|
case 'basic_6mo':
|
|
return '<span class="subscription-bubble px-2 py-1 mr-1">Gem cap raised to 35</span><span class="subscription-bubble px-2 py-1">+2 Mystic Hourglass</span>';
|
|
case 'basic_12mo':
|
|
return '<span class="discount-bubble px-2 py-1 mr-1">Save 20%</span><span class="subscription-bubble px-2 py-1 mr-1">Gem cap raised to 45</span><span class="subscription-bubble px-2 py-1">+4 Mystic Hourglass</span>';
|
|
default:
|
|
return '<span class="subscription-bubble px-2 py-1">Gem cap at 25</span>';
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|