paypal: restore url after purchase

This commit is contained in:
Matteo Pagliazzi 2018-11-10 16:03:25 +01:00
parent 680c2162a7
commit 433c73c9d3
4 changed files with 21 additions and 4 deletions

View file

@ -75,7 +75,7 @@
.card-body
.mx-auto(v-html='icons.creditCard', style='"height: 56px; width: 159px; margin-top: 1em;"')
.card.text-center.payment-method
a.card-body.paypal(:href='paypalCheckoutLink', target='_blank')
a.card-body.paypal(@click="openPaypal(paypalCheckoutLink)")
img(src='~assets/images/paypal.png')
.card.text-center.payment-method(@click="amazonPaymentsInit({type: 'single'})")
.card-body.amazon
@ -158,7 +158,7 @@
.card-body(@click='showStripe({subscription: subscriptionPlan})')
.mx-auto(v-html='icons.creditCard', style='"height: 56px; width: 159px; margin-top: 1em;"')
.card.text-center.payment-method
a.card-body.paypal(:href='paypalSubscriptionLink', target='_blank')
a.card-body.paypal(@click="openPaypal(paypalSubscriptionLink)")
img(src='~assets/images/paypal.png')
.card.text-center.payment-method
.card-body.amazon(@click="amazonPaymentsInit({type: 'subscription', subscription: subscriptionPlan})")

View file

@ -77,7 +77,7 @@
.col-md-4
button.purchase.btn.btn-primary(@click='showStripe({subscription:subscription.key, coupon:subscription.coupon})', :disabled='!subscription.key') {{ $t('card') }}
.col-md-4
a.purchase(:href='paypalPurchaseLink', :disabled='!subscription.key', target='_blank')
a.purchase(@click="openPaypal(paypalPurchaseLink)", :disabled='!subscription.key')
img(src='https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-small.png', :alt="$t('paypal')")
.col-md-4
a.btn.btn-secondary.purchase(@click="payWithAmazon()")

View file

@ -14,6 +14,9 @@ const CONSTANTS = {
COSTUME_TAB: 'costume-tab',
EQUIPMENT_TAB: 'equipment-tab',
},
savedAppStateValues: {
SAVED_APP_STATE: 'saved-app-state',
},
};
function setLocalSetting (key, value) {
@ -24,8 +27,14 @@ function getLocalSetting (key) {
return localStorage.getItem(key);
}
function removeLocalSetting (key) {
return localStorage.removeItem(key);
}
export {
CONSTANTS,
getLocalSetting,
setLocalSetting,
removeLocalSetting,
};

View file

@ -6,12 +6,12 @@ import { mapState } from 'client/libs/store';
import encodeParams from 'client/libs/encodeParams';
import notificationsMixin from 'client/mixins/notifications';
import * as Analytics from 'client/libs/analytics';
import { CONSTANTS, setLocalSetting } from 'client/libs/userlocalManager';
export default {
mixins: [notificationsMixin],
computed: {
...mapState(['credentials']),
// @TODO refactor into one single computed property
paypalCheckoutLink () {
return '/paypal/checkout';
},
@ -41,6 +41,14 @@ export default {
let gift = this.encodeGift(data.giftedTo, data.gift);
const url = `/paypal/checkout?gift=${gift}`;
this.openPaypal(url);
},
openPaypal (url) {
const appState = {
path: this.$route.fullPath,
paymentMethod: 'paypal',
};
setLocalSetting(CONSTANTS.savedAppStateValues.SAVED_APP_STATE, JSON.stringify(appState));
window.open(url, '_blank');
},
showStripe (data) {