continuation of PR #8161 Display error notification when attempting to purchase invalid amount of gems - fixes #8145 (#8688)

* Translation string for error notification

* Use function instead of a link for paypal

* Inject notification service, function to check the amount of gems to purchase, function to handle payments with paypal

* Throw error if amount of gems is zero or negative

* Add condition to raise error if amount is negative

* Added gem errors for gifts 0 or less

* Fixed linting and broken test

* Fixed test syntax

* Added back needed strings

* Fixed group locales
This commit is contained in:
Keith Holliday
2017-07-06 14:43:43 -06:00
committed by Sabe Jones
parent 48bbc22fb4
commit e901850a6f
9 changed files with 101 additions and 4 deletions

View File

@@ -98,6 +98,9 @@ api.checkout = async function checkout (options = {}) {
if (gift) {
if (gift.type === this.constants.GIFT_TYPE_GEMS) {
if (gift.gems.amount <= 0) {
throw new BadRequest(i18n.t('badAmountOfGemsToPurchase'));
}
amount = gift.gems.amount / 4;
} else if (gift.type === this.constants.GIFT_TYPE_SUBSCRIPTION) {
amount = common.content.subscriptionBlocks[gift.subscription.key].price;