- extend setup:dev script

- Stripe taxes refactoring
- billing subscription fixes
This commit is contained in:
Peter Papp
2021-03-24 08:19:52 +01:00
parent 09d2032a70
commit 0e3c6e286e
9 changed files with 106 additions and 48 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div id="single-page">
<div id="page-content" class="large-width center-page" v-show="! isLoading">
<MobileHeader :title="$router.currentRoute.meta.title"/>
<MobileHeader :title="$router.currentRoute.meta.title" />
<div class="content-page">
<div class="plan-title">
<credit-card-icon size="42" class="title-icon"></credit-card-icon>
@@ -91,7 +91,7 @@
<ValidationProvider tag="div" mode="passive" class="input-wrapper"
rules="required"
name="billing_name" v-slot="{ errors }">
<input v-model="billing.billing_name"
<input v-model="billing.name"
:placeholder="$t('user_settings.name_plac')"
type="text"
:class="{'is-error': errors[0]}"
@@ -105,7 +105,7 @@
<ValidationProvider tag="div" mode="passive" class="input-wrapper"
rules="required"
name="billing_address" v-slot="{ errors }">
<input v-model="billing.billing_address"
<input v-model="billing.address"
:placeholder="$t('user_settings.address_plac')"
type="text"
:class="{'is-error': errors[0]}"
@@ -120,7 +120,7 @@
<ValidationProvider tag="div" mode="passive" class="input-wrapper"
rules="required" name="billing_city"
v-slot="{ errors }">
<input v-model="billing.billing_city"
<input v-model="billing.city"
:placeholder="$t('user_settings.city_plac')"
type="text"
:class="{'is-error': errors[0]}"
@@ -134,7 +134,7 @@
<ValidationProvider tag="div" mode="passive" class="input-wrapper"
rules="required" name="billing_postal_code"
v-slot="{ errors }">
<input v-model="billing.billing_postal_code"
<input v-model="billing.postal_code"
:placeholder="$t('user_settings.postal_code_plac')"
type="text"
:class="{'is-error': errors[0]}"
@@ -149,8 +149,8 @@
<ValidationProvider tag="div" mode="passive" class="input-wrapper"
rules="required"
name="billing_country" v-slot="{ errors }">
<SelectInput v-model="billing.billing_country"
:default="billing.billing_country"
<SelectInput v-model="billing.country"
:default="billing.country"
:options="countries"
:placeholder="$t('user_settings.country_plac')"
:isError="errors[0]" />
@@ -163,7 +163,7 @@
<ValidationProvider tag="div" mode="passive" class="input-wrapper"
rules="required"
name="billing_state" v-slot="{ errors }">
<input v-model="billing.billing_state"
<input v-model="billing.state"
:placeholder="$t('user_settings.state_plac')"
type="text"
:class="{'is-error': errors[0]}"
@@ -180,7 +180,7 @@
<ValidationProvider tag="div" mode="passive" class="input-wrapper"
rules="required"
name="billing_phone_number" v-slot="{ errors }">
<input v-model="billing.billing_phone_number"
<input v-model="billing.phone_number"
:placeholder="$t('user_settings.phone_number_plac')"
type="text"
:class="{'is-error': errors[0]}"
@@ -206,7 +206,7 @@
</div>
<div class="row" v-if="taxRates">
<div class="cell">
<b>{{ $t('page_upgrade_account.summary.vat') }} - ({{ taxRates.jurisdiction }} {{ taxRates.percentage }}%)</b>
<b>{{ $t('page_upgrade_account.summary.vat') }} - ({{ taxRates.country }} {{ taxRates.percentage }}%)</b>
</div>
<div class="cell">
<b>{{ taxRates.plan_price_formatted }}</b>
@@ -291,11 +291,11 @@
computed: {
...mapGetters(['requestedPlan', 'config', 'countries']),
billing() {
return this.$store.getters.user.relationships.settings.data.attributes
return this.$store.getters.user.data.relationships.settings.data.attributes
},
taxRates() {
return this.requestedPlan.data.attributes.tax_rates.find(taxRate => {
return taxRate.jurisdiction === this.billing.billing_country
return taxRate.country === this.billing.country
})
}
},
@@ -405,8 +405,16 @@
} else {
axios
.post('/api/subscription/upgrade', {
billing: this.billing,
.post('/api/user/subscription/upgrade', {
billing: {
billing_address: this.billing.address,
billing_city: this.billing.city,
billing_country: this.billing.country,
billing_name: this.billing.name,
billing_phone_number: this.billing.phone_number,
billing_postal_code: this.billing.postal_code,
billing_state: this.billing.state,
},
plan: this.requestedPlan,
payment: {
type: 'stripe',
@@ -415,8 +423,12 @@
}
}
})
.then(() => this.successOrder())
.catch((error) => this.errorOrder(error))
.then(() => {
this.successOrder()
})
.catch((error) => {
this.errorOrder(error)
})
.finally(() => {
this.isSubmitted = false
})
@@ -427,15 +439,27 @@
if (this.defaultPaymentMethod && !this.payByNewCard) {
axios
.post('/api/subscription/upgrade', {
billing: this.billing,
.post('/api/user/subscription/upgrade', {
billing: {
billing_address: this.billing.address,
billing_city: this.billing.city,
billing_country: this.billing.country,
billing_name: this.billing.name,
billing_phone_number: this.billing.phone_number,
billing_postal_code: this.billing.postal_code,
billing_state: this.billing.state,
},
plan: this.requestedPlan,
payment: {
type: 'stripe',
}
})
.then(() => this.successOrder())
.catch((error) => this.errorOrder(error))
.then(() => {
this.successOrder()
})
.catch((error) => {
this.errorOrder(error)
})
.finally(() => {
this.isSubmitted = false
})
@@ -452,11 +476,13 @@
created() {
// Get setup intent for stripe
axios.get('/api/subscription/setup-intent')
axios.get('/api/user/subscription/setup-intent')
.then(response => {
this.clientSecret = response.data.client_secret
})
.catch(() => this.$isSomethingWrong())
.catch(() => {
this.$isSomethingWrong()
})
axios.get('/api/user/payments')
.then(response => {
@@ -464,11 +490,12 @@
this.defaultPaymentMethod = response.data.default
this.PaymentMethods = response.data.others
})
.catch(() => this.$isSomethingWrong())
.catch(() => {
this.$isSomethingWrong()
})
.finally(() => {
this.isLoading = false
}
)
this.isLoading = false
})
}
}
</script>