mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-20 12:48:52 +00:00
improve error reporting for iOS IAP
This commit is contained in:
parent
6467dd8fc0
commit
39adff0e2c
2 changed files with 25 additions and 7 deletions
|
|
@ -209,8 +209,15 @@ describe 'In-App Purchases', ->
|
|||
|
||||
it 'does not call res.json', ->
|
||||
inApp.iosVerify(req, res, next)
|
||||
|
||||
expect(res.json).to.not.be.called
|
||||
expectedResObj = {
|
||||
ok: false
|
||||
data: {
|
||||
code: 6778001
|
||||
message: 'Invalid receipt'
|
||||
}
|
||||
}
|
||||
expect(res.json).to.be.calledOnce
|
||||
expect(res.json).to.be.calledWith(expectedResObj)
|
||||
|
||||
it 'does not calls payments.buyGems function', ->
|
||||
inApp.iosVerify(req, res, next)
|
||||
|
|
@ -231,7 +238,7 @@ describe 'In-App Purchases', ->
|
|||
ok: false
|
||||
data: {
|
||||
code: 6778001
|
||||
message: 'Incorrect receipt'
|
||||
message: 'Incorrect receipt content'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +266,7 @@ describe 'In-App Purchases', ->
|
|||
ok: false
|
||||
data: {
|
||||
code: 6778001
|
||||
message: 'Incorrect receipt'
|
||||
message: 'Incorrect receipt content'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ exports.iosVerify = function(req, res, next) {
|
|||
|
||||
}
|
||||
|
||||
// iap is ready
|
||||
//iap is ready
|
||||
iap.validate(iap.APPLE, iapBody.transaction.receipt, function (err, appleRes) {
|
||||
if (err) {
|
||||
var resObj = {
|
||||
|
|
@ -102,6 +102,7 @@ exports.iosVerify = function(req, res, next) {
|
|||
var purchaseDataList = iap.getPurchaseData(appleRes);
|
||||
if (purchaseDataList.length > 0) {
|
||||
if (purchaseDataList[0].productId === "com.habitrpg.ios.Habitica.20gems") {
|
||||
//Correct receipt
|
||||
payments.buyGems({user:user, paymentMethod:'IAP AppleStore'});
|
||||
var resObj = {
|
||||
ok: true,
|
||||
|
|
@ -111,16 +112,26 @@ exports.iosVerify = function(req, res, next) {
|
|||
return res.json(resObj);
|
||||
}
|
||||
}
|
||||
//wrong receipt content
|
||||
var resObj = {
|
||||
ok: false,
|
||||
data: {
|
||||
code: INVALID_PAYLOAD,
|
||||
message: "Incorrect receipt"
|
||||
message: "Incorrect receipt content"
|
||||
}
|
||||
};
|
||||
|
||||
return res.json(resObj);
|
||||
}
|
||||
//invalid receipt
|
||||
var resObj = {
|
||||
ok: false,
|
||||
data: {
|
||||
code: INVALID_PAYLOAD,
|
||||
message: "Invalid receipt"
|
||||
}
|
||||
};
|
||||
|
||||
return res.json(resObj);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue