From 2a367ab3a7c7227741833b10c65ae398b9efeea2 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Thu, 7 Mar 2019 16:58:49 +0100 Subject: [PATCH] Revert "New payments buttons and new Amazon checkout flow (#10940)" This reverts commit 77f3bb53dea34625a965eb2d6bd418ce76878c7b. --- .../group-plans/createGroupModalPages.vue | 13 +- .../client/components/groups/groupPlan.vue | 16 +-- .../components/payments/amazonButton.vue | 110 ----------------- .../components/payments/amazonModal.vue | 114 ++++++++++++++---- .../components/payments/buyGemsModal.vue | 14 +-- .../components/payments/sendGemsModal.vue | 7 +- .../components/settings/subscription.vue | 15 +-- website/client/mixins/payments.js | 24 +--- 8 files changed, 118 insertions(+), 195 deletions(-) delete mode 100644 website/client/components/payments/amazonButton.vue diff --git a/website/client/components/group-plans/createGroupModalPages.vue b/website/client/components/group-plans/createGroupModalPages.vue index 38630835ad..e0971792a8 100644 --- a/website/client/components/group-plans/createGroupModalPages.vue +++ b/website/client/components/group-plans/createGroupModalPages.vue @@ -25,8 +25,7 @@ .payment-providers .box.payment-button(@click='pay(PAYMENTS.STRIPE)') .svg-icon.credit-card-icon(v-html="icons.creditCard") - amazon-button(:amazon-data="pay(PAYMENTS.AMAZON)") - //.box.payment-button.amazon(@click='pay(PAYMENTS.AMAZON)') + .box.payment-button.amazon(@click='pay(PAYMENTS.AMAZON)') .svg-icon.amazon-pay-icon(v-html="icons.amazonpay") @@ -88,21 +87,17 @@ import * as Analytics from 'client/libs/analytics'; import { mapState } from 'client/libs/store'; import paymentsMixin from '../../mixins/payments'; -import amazonButton from 'client/components/payments/amazonButton'; -// import amazonpay from 'assets/svg/amazonpay.svg'; +import amazonpay from 'assets/svg/amazonpay.svg'; import creditCard from 'assets/svg/credit-card.svg'; export default { mixins: [paymentsMixin], - components: { - amazonButton, - }, data () { return { amazonPayments: {}, icons: Object.freeze({ - // amazonpay, + amazonpay, creditCard, }), PAGES: { @@ -164,7 +159,7 @@ export default { this.showStripe(paymentData); } else if (this.paymentMethod === this.PAYMENTS.AMAZON) { paymentData.type = 'subscription'; - return paymentData; + this.amazonPaymentsInit(paymentData); } }, }, diff --git a/website/client/components/groups/groupPlan.vue b/website/client/components/groups/groupPlan.vue index 968b442703..9e92d0aa58 100644 --- a/website/client/components/groups/groupPlan.vue +++ b/website/client/components/groups/groupPlan.vue @@ -53,8 +53,7 @@ div .svg-icon.credit-card-icon(v-html="icons.group") p.credit-card Credit Card p Powered by Stripe - amazon-button(:amazon-data="pay(PAYMENTS.AMAZON)") - //.box.payment-button(@click='pay(PAYMENTS.AMAZON)') + .box.payment-button(@click='pay(PAYMENTS.AMAZON)') .svg-icon.amazon-pay-icon(v-html="icons.amazonpay") .container.col-6.offset-3.create-option(v-if='!upgradingGroup._id') @@ -105,8 +104,7 @@ div .box.payment-button(@click='pay(PAYMENTS.STRIPE)') p Credit Card p Powered by Stripe - amazon-button(:amazon-data="pay(PAYMENTS.AMAZON)") - //.box.payment-button(@click='pay(PAYMENTS.AMAZON)') + .box.payment-button(@click='pay(PAYMENTS.AMAZON)') | Amazon Pay @@ -336,21 +334,17 @@ div import paymentsMixin from '../../mixins/payments'; import { mapState } from 'client/libs/store'; import group from 'assets/svg/group.svg'; -// import amazonpay from 'assets/svg/amazonpay.svg'; +import amazonpay from 'assets/svg/amazonpay.svg'; import positiveIcon from 'assets/svg/positive.svg'; -import amazonButton from 'client/components/payments/amazonButton'; export default { mixins: [paymentsMixin], - components: { - amazonButton, - }, data () { return { amazonPayments: {}, icons: Object.freeze({ group, - // amazonpay, + amazonpay, positiveIcon, }), PAGES: { @@ -419,7 +413,7 @@ export default { this.showStripe(paymentData); } else if (this.paymentMethod === this.PAYMENTS.AMAZON) { paymentData.type = 'subscription'; - return paymentData; + this.amazonPaymentsInit(paymentData); } }, }, diff --git a/website/client/components/payments/amazonButton.vue b/website/client/components/payments/amazonButton.vue deleted file mode 100644 index 35e33c2af7..0000000000 --- a/website/client/components/payments/amazonButton.vue +++ /dev/null @@ -1,110 +0,0 @@ - - - - - diff --git a/website/client/components/payments/amazonModal.vue b/website/client/components/payments/amazonModal.vue index 823aae5e85..13380db0b5 100644 --- a/website/client/components/payments/amazonModal.vue +++ b/website/client/components/payments/amazonModal.vue @@ -1,6 +1,7 @@ @@ -87,16 +86,12 @@ import { mapState } from 'client/libs/store'; import planGemLimits from '../../../common/script/libs/planGemLimits'; import paymentsMixin from 'client/mixins/payments'; import notificationsMixin from 'client/mixins/notifications'; -import amazonButton from 'client/components/payments/amazonButton'; // @TODO: EMAILS.TECH_ASSISTANCE_EMAIL, load from config const TECH_ASSISTANCE_EMAIL = 'admin@habitica.com'; export default { mixins: [paymentsMixin, notificationsMixin], - components: { - amazonButton, - }, data () { return { planGemLimits, diff --git a/website/client/components/settings/subscription.vue b/website/client/components/settings/subscription.vue index 14c7223c6c..b76747c523 100644 --- a/website/client/components/settings/subscription.vue +++ b/website/client/components/settings/subscription.vue @@ -80,8 +80,7 @@ a.purchase(@click="openPaypal(paypalPurchaseLink, 'subscription')", :disabled='!subscription.key') img(src='https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-small.png', :alt="$t('paypal')") .col-md-4 - amazon-button(:amazon-data="{type: 'subscription', subscription: this.subscription.key, coupon: this.subscription.coupon}") - // a.btn.btn-secondary.purchase(@click="payWithAmazon()") + a.btn.btn-secondary.purchase(@click="payWithAmazon()") img(src='https://payments.amazon.com/gp/cba/button', :alt="$t('amazonPayments')") .row .col-6 @@ -116,13 +115,8 @@ import planGemLimits from '../../../common/script/libs/planGemLimits'; import paymentsMixin from '../../mixins/payments'; import notificationsMixin from '../../mixins/notifications'; -import amazonButton from 'client/components/payments/amazonButton'; - export default { mixins: [paymentsMixin, notificationsMixin], - components: { - amazonButton, - }, data () { return { loading: false, @@ -246,6 +240,13 @@ export default { }, }, methods: { + payWithAmazon () { + this.amazonPaymentsInit({ + type: 'subscription', + subscription: this.subscription.key, + coupon: this.subscription.coupon, + }); + }, async applyCoupon (coupon) { const response = await axios.post(`/api/v4/coupons/validate/${coupon}`); diff --git a/website/client/mixins/payments.js b/website/client/mixins/payments.js index 9fc28dda27..84c653a45f 100644 --- a/website/client/mixins/payments.js +++ b/website/client/mixins/payments.js @@ -251,30 +251,8 @@ export default { this.amazonPayments.gift = data.gift; this.amazonPayments.type = data.type; - }, - amazonOnError (error) { - alert(error.getErrorMessage()); - this.reset(); - }, - reset () { - // @TODO: Ensure we are using all of these - // some vars are set in the payments mixin. We should try to edit in one place - this.amazonPayments.modal = null; - this.amazonPayments.type = null; - this.amazonPayments.loggedIn = false; - // Gift - this.amazonPayments.gift = null; - this.amazonPayments.giftReceiver = null; - - this.amazonPayments.billingAgreementId = null; - this.amazonPayments.orderReferenceId = null; - this.amazonPayments.paymentSelected = false; - this.amazonPayments.recurringConsent = false; - this.amazonPayments.subscription = null; - this.amazonPayments.coupon = null; - this.amazonPayments.groupToCreate = null; - this.amazonPayments.group = null; + this.$root.$emit('habitica::pay-with-amazon', this.amazonPayments); }, async cancelSubscription (config) { if (config && config.group && !confirm(this.$t('confirmCancelGroupPlan'))) return;