Wizcorp/node-iap

return values

kelchy opened this issue · 9 comments

I am trying out google verification.

if the purchase is not yet consumed, i get an error that it is not yet consumed.
if the purchase is consumed, then i get the proper response.
if the purchase does not exist, i get an error but blank.

Is this the expected behavior? I just find it weird

An error, but blank? Can you paste some logs? I also find this weird.
Not-yet-consumed should also not be an error.

this is my code
var payment = { receipt: fields.token, // or fields.order_id productId: fields.sku, packageName: 'com.blahblah', keyObject: { "private_key_id": "blahblah", "private_key": "-----BEGIN PRIVATE KEY-----\nblahblah\n-----END PRIVATE KEY-----\n", "client_email": "blahblah", "client_id": "blahblah", "type": "service_account" } }; iap.verifyPayment("google", payment, function (err, response) { blahblah }); console.log(JSON.stringify(response)); if (err) console.log(JSON.stringify(err));

this is what i got when notConsumed

undefined {"name":"AssertionError","actual":0,"expected":1,"operator":"==","message":"notConsumed"}

this is what i got when purchase not exists

undefined {}

this is when i have a consumed it

{"receipt":{"kind":"androidpublisher#productPurchase","purchaseTimeMillis":"1432806328663","purchaseState":0,"consumptionState":1,"developerPayload":"blahblah"},"transactionId":"blahblah","productId":"blahblah","platform":"google"}

The {} error object would almost have to come from https://github.com/Wizcorp/node-iap/blob/master/lib/google/index.js#L38

Please don't stringify before running console.log though, you may lose some critical information from the object that way. Could you run it again without the JSON.stringify on the error? Also, please console.log(error.stack);

noted. after a successful top-up, here is the console.log(error.stack)

AssertionError: notConsumed
at /home/nodeuser/node_modules/iap/lib/google/index.js:57:12
at IncomingMessage. (/home/nodeuser/node_modules/iap/lib/https/request.js:32:4)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)

Apologies. I think this issue might've been fixed, just never released to NPM. I'll make a release for you today. In the mean time, you can try out npm install Wizcorp/node-iap to get the latest master version.

thanks! will try it out

I just released 0.3.3. Please give it a shot.

works perfectly :) thanks!

Great! Apologies for not releasing sooner.