Fixed gem purchasing and error catching

This commit is contained in:
Keith Holliday
2018-01-20 15:09:08 -06:00
parent b0a21e116a
commit 2ba327ef14

View File

@@ -173,6 +173,7 @@ export default {
}).bind('AmazonPayRecurring'); }).bind('AmazonPayRecurring');
}; };
} else { } else {
this.$set(this, 'amazonButtonEnabled', true);
walletParams.amazonOrderReferenceId = this.amazonPayments.orderReferenceId; walletParams.amazonOrderReferenceId = this.amazonPayments.orderReferenceId;
} }
@@ -185,21 +186,21 @@ export default {
// @TODO: A gift should not read the same as buying gems for yourself. // @TODO: A gift should not read the same as buying gems for yourself.
if (this.amazonPayments.type === 'single') { if (this.amazonPayments.type === 'single') {
let url = '/amazon/checkout'; let url = '/amazon/checkout';
let response = await axios.post(url, {
try {
await axios.post(url, {
orderReferenceId: this.amazonPayments.orderReferenceId, orderReferenceId: this.amazonPayments.orderReferenceId,
gift: this.amazonPayments.gift, gift: this.amazonPayments.gift,
}); });
if (response.status < 400) {
this.$set(this, 'amazonButtonEnabled', true); this.$set(this, 'amazonButtonEnabled', true);
this.reset(); this.reset();
// @TODO: What are we syncing? // @TODO: What are we syncing?
window.location.reload(true); window.location.reload(true);
return; } catch (e) {
} this.$set(this, 'amazonButtonEnabled', true);
alert(response.message);
this.amazonPaymentsreset(); this.amazonPaymentsreset();
}
} else if (this.amazonPayments.type === 'subscription') { } else if (this.amazonPayments.type === 'subscription') {
let url = '/amazon/subscribe'; let url = '/amazon/subscribe';
@@ -207,7 +208,8 @@ export default {
url = '/api/v3/groups/create-plan'; url = '/api/v3/groups/create-plan';
} }
let response = await axios.post(url, { try {
const response = await axios.post(url, {
billingAgreementId: this.amazonPayments.billingAgreementId, billingAgreementId: this.amazonPayments.billingAgreementId,
subscription: this.amazonPayments.subscription, subscription: this.amazonPayments.subscription,
coupon: this.amazonPayments.coupon, coupon: this.amazonPayments.coupon,
@@ -216,14 +218,6 @@ export default {
paymentType: 'Amazon', paymentType: 'Amazon',
}); });
let responseStatus = response.status;
if (responseStatus >= 400) {
this.$set(this, 'amazonButtonEnabled', true);
alert(`Error: ${response.message}`);
// @TODO: do we need this? this.amazonPaymentsreset();
return;
}
this.$root.$emit('bv::hide::modal', 'amazon-payment'); this.$root.$emit('bv::hide::modal', 'amazon-payment');
let newGroup = response.data.data; let newGroup = response.data.data;
@@ -241,6 +235,10 @@ export default {
window.location.reload(true); window.location.reload(true);
this.reset(); this.reset();
} catch (e) {
this.$set(this, 'amazonButtonEnabled', true);
// @TODO: do we need this? this.amazonPaymentsreset();
}
} }
}, },
amazonOnPaymentSelect () { amazonOnPaymentSelect () {