create new subscription if stripe was previously cancelled

This commit is contained in:
Čarodej
2022-03-05 09:35:42 +01:00
parent ae138bb4d4
commit 0a30ca0b98
8 changed files with 34 additions and 12 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -95,6 +95,9 @@ export default {
}, },
subscriptionDriver() { subscriptionDriver() {
return this.user.data.relationships.subscription.data.attributes.driver return this.user.data.relationships.subscription.data.attributes.driver
},
subscription() {
return this.user.data.relationships.subscription
} }
}, },
data() { data() {
@@ -129,11 +132,30 @@ export default {
}) })
}, },
payByStripe() { payByStripe() {
axios // Subscribe to the new plan
.post(`/api/subscriptions/swap/${this.selectedPlan.data.id}`) if (['inactive', 'cancelled', 'completed'].includes(this.subscription.data.attributes.status)) {
.then((response) => { axios
console.log(response); .post('/api/stripe/checkout', {
}) planCode: this.selectedPlan.data.meta.driver_plan_id.stripe,
})
.then((response) => {
window.location = response.data.url
})
}
// Change active subscription
if (this.subscription.data.attributes.status === 'active') {
axios
.post(`/api/subscriptions/swap/${this.selectedPlan.data.id}`)
.then(() => {
this.$closePopup()
events.$emit('toaster', {
type: 'success',
message: this.$t('Your subscription was successfully changed.'),
})
})
}
}, },
payByPaystack() { payByPaystack() {
axios axios
+1 -1
View File
@@ -24,7 +24,7 @@
</div> </div>
<span <span
class="block h-full w-full rounded-lg" class="block h-full w-full rounded-lg"
:class="{'bg-theme': bar.percentage > 0, 'bg-gray-200': bar.percentage === 0}" :class="{'bg-theme': bar.percentage > 0, 'dark:bg-gray-700 bg-gray-200': bar.percentage === 0}"
></span> ></span>
</div> </div>
</template> </template>