Make requested syntax changes

This commit is contained in:
Phillip Thelen
2016-10-11 20:47:01 +02:00
committed by GitHub
parent c84d6ba141
commit c6e2b78982

View File

@@ -54,7 +54,7 @@ api.iapAndroidVerify = {
userId: user._id, userId: user._id,
}); });
let amount = 0; let amount;
switch (receiptObj.productId) { switch (receiptObj.productId) {
case 'com.habitrpg.android.habitica.iap.4gems': case 'com.habitrpg.android.habitica.iap.4gems':
@@ -72,9 +72,14 @@ api.iapAndroidVerify = {
break; break;
} }
if (amount === 0) throw new Error('INVALID_ITEM_PURCHASED'); if (amount) throw new Error('INVALID_ITEM_PURCHASED');
await payments.buyGems({user, paymentMethod: 'IAP GooglePlay', amount, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop await payments.buyGems({
user,
paymentMethod: 'IAP GooglePlay',
amount,
headers: req.headers
});
res.respond(200, googleRes); res.respond(200, googleRes);
}, },
@@ -129,7 +134,7 @@ api.iapiOSVerify = {
throw new Error('RECEIPT_ALREADY_USED'); throw new Error('RECEIPT_ALREADY_USED');
} }
let amount = 0; let amount;
switch (purchaseData.productId) { switch (purchaseData.productId) {
case 'com.habitrpg.ios.Habitica.4gems': case 'com.habitrpg.ios.Habitica.4gems':
amount = 1; amount = 1;
@@ -145,11 +150,16 @@ api.iapiOSVerify = {
amount = 21; amount = 21;
break; break;
} }
if (amount === 0) { if (amount) {
correctReceipt = false; correctReceipt = false;
break; break;
} }
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop await payments.buyGems({
user,
paymentMethod: 'IAP AppleStore',
amount,
headers: req.headers
}); // eslint-disable-line babel/no-await-in-loop
} }
if (!correctReceipt) throw new Error('INVALID_ITEM_PURCHASED'); if (!correctReceipt) throw new Error('INVALID_ITEM_PURCHASED');