mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 04:29:40 +00:00
Merge branch 'iap' of https://github.com/vIiRuS/habitrpg into vIiRuS-iap
This commit is contained in:
commit
94da808279
1 changed files with 39 additions and 10 deletions
|
|
@ -54,11 +54,31 @@ api.iapAndroidVerify = {
|
|||
userId: user._id,
|
||||
});
|
||||
|
||||
let amount;
|
||||
|
||||
switch (receiptObj.productId) {
|
||||
case 'com.habitrpg.android.habitica.iap.4gems':
|
||||
amount = 1;
|
||||
break;
|
||||
case 'com.habitrpg.android.habitica.iap.20gems':
|
||||
case 'com.habitrpg.android.habitica.iap.21gems':
|
||||
amount = 5.25;
|
||||
break;
|
||||
case 'com.habitrpg.android.habitica.iap.42gems':
|
||||
amount = 10.5;
|
||||
break;
|
||||
case 'com.habitrpg.android.habitica.iap.84gems':
|
||||
amount = 21;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!amount) throw new Error('INVALID_ITEM_PURCHASED');
|
||||
|
||||
await payments.buyGems({
|
||||
user,
|
||||
paymentMethod: 'IAP GooglePlay',
|
||||
amount: 5.25,
|
||||
headers: req.headers,
|
||||
amount,
|
||||
headers: req.headers
|
||||
});
|
||||
|
||||
res.respond(200, googleRes);
|
||||
|
|
@ -114,23 +134,32 @@ api.iapiOSVerify = {
|
|||
throw new Error('RECEIPT_ALREADY_USED');
|
||||
}
|
||||
|
||||
let amount;
|
||||
switch (purchaseData.productId) {
|
||||
case 'com.habitrpg.ios.Habitica.4gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 1, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
break;
|
||||
case 'com.habitrpg.ios.Habitica.8gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 2, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
amount = 1;
|
||||
break;
|
||||
case 'com.habitrpg.ios.Habitica.20gems':
|
||||
case 'com.habitrpg.ios.Habitica.21gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 5.25, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
amount = 5.25;
|
||||
break;
|
||||
case 'com.habitrpg.ios.Habitica.42gems':
|
||||
await payments.buyGems({user, paymentMethod: 'IAP AppleStore', amount: 10.5, headers: req.headers}); // eslint-disable-line babel/no-await-in-loop
|
||||
amount = 10.5;
|
||||
break;
|
||||
case 'com.habitrpg.ios.Habitica.84gems':
|
||||
amount = 21;
|
||||
break;
|
||||
default:
|
||||
correctReceipt = false;
|
||||
}
|
||||
if (!amount) {
|
||||
correctReceipt = false;
|
||||
break;
|
||||
}
|
||||
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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue