diff --git a/website/client/src/libs/payments.js b/website/client/src/libs/payments.js index 2c568e218cc..d41efbc4a35 100644 --- a/website/client/src/libs/payments.js +++ b/website/client/src/libs/payments.js @@ -3,26 +3,11 @@ import getStore from '@/store'; export function setup () { // eslint-disable-line import/prefer-default-export const store = getStore(); - // // Set Amazon Payments as ready in the store, - // // Added here to make sure the listener is registered before the script can be executed - window.onAmazonLoginReady = () => { - store.state.isAmazonReady = true; - window.amazon.Login.setClientId(process.env.AMAZON_PAYMENTS_CLIENT_ID); - }; - - // Load the scripts - - // Amazon Payments - const amazonScript = document.createElement('script'); - let firstScript = document.getElementsByTagName('script')[0]; - amazonScript.type = 'text/javascript'; - amazonScript.async = true; - amazonScript.src = `https://static-na.payments-amazon.com/OffAmazonPayments/us/${(process.env.AMAZON_PAYMENTS_MODE === 'sandbox' ? 'sandbox/' : '')}js/Widgets.js`; - firstScript.parentNode.insertBefore(amazonScript, firstScript); + // Load the payment scripts // Stripe const stripeScript = document.createElement('script'); - [firstScript] = document.getElementsByTagName('script'); + let firstScript = document.getElementsByTagName('script')[0]; stripeScript.async = true; stripeScript.src = 'https://js.stripe.com/v3/'; firstScript.parentNode.insertBefore(stripeScript, firstScript); diff --git a/website/client/src/mixins/payments.js b/website/client/src/mixins/payments.js index 47763dccaff..b8d724f313e 100644 --- a/website/client/src/mixins/payments.js +++ b/website/client/src/mixins/payments.js @@ -263,76 +263,7 @@ export default { } return true; }, - amazonPaymentsInit (data) { - if (data.type !== 'single' && data.type !== 'subscription') return; - if (data.type === 'single') { - this.amazonPayments.gemsBlock = data.gemsBlock; - this.amazonPayments.sku = data.sku; - } - - if (data.gift) { - if (data.gift.gems && data.gift.gems.amount && data.gift.gems.amount <= 0) return; - data.gift.uuid = data.giftedTo; - this.amazonPayments.giftReceiver = data.receiverName; - } - - if (data.subscription) { - this.amazonPayments.subscription = data.subscription; - this.amazonPayments.coupon = data.coupon; - } - - if (data.groupId) { - this.amazonPayments.groupId = data.groupId; - } - - if (data.group) { // upgrading a group - this.amazonPayments.group = data.group; - } - - if (data.groupToCreate) { // creating a group - this.amazonPayments.groupToCreate = data.groupToCreate; - } - - if (data.demographics) { // sending demographics - this.amazonPayments.demographics = data.demographics; - } - - this.amazonPayments.gift = data.gift; - this.amazonPayments.type = data.type; - }, - amazonOnError (error) { - window.alert(error.getErrorMessage()); // eslint-disable-line no-alert - this.reset(); - }, - // Make sure the amazon session is reset between different sessions and after each purchase - amazonLogout () { - if (window.amazon && window.amazon.Login && typeof window.amazon.Login.logout === 'function') { - window.amazon.Login.logout(); - } - }, - 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.amazonLogout(); - - 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; - }, cancelSubscriptionConfirm (config) { if (config.canCancel === false) return; this.$root.$emit('habitica:cancel-subscription-confirm', config); @@ -348,7 +279,7 @@ export default { let paymentMethod = group ? group.purchased.plan.paymentMethod : this.user.purchased.plan.paymentMethod; - paymentMethod = paymentMethod === 'Amazon Payments' ? 'amazon' : paymentMethod.toLowerCase(); + paymentMethod = paymentMethod.toLowerCase(); const queryParams = { noRedirect: true,