mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
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:
committed by
Sabe Jones
parent
48bbc22fb4
commit
e901850a6f
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user