iOS inApp purchase : ERROR: Runtime error json.prettify takes a string or a table (got userdata)

Hi,

I am using the latest build (Build 2017.3068) and was testing in app purchase with TestFlight and everything was ok (transaction done, but then when the API was called, I receive this error) :

Apr  8 07:55:06 iPad Secret Quotes Deluxe[2637] <Warning>: {

 “name”:“storeTransaction”,

 “transaction”:"<type ‘userdata’ is not supported by JSON.>"

}

Apr  8 07:55:06 iPad Secret Quotes Deluxe[2637] <Warning>: ERROR: Runtime error

json.prettify takes a string or a table (got userdata)

stack traceback:

[C]: in function ‘error’

?: in function ‘prettify’

?: in function <?:187>

Apr  8 07:55:06 iPad Secret Quotes Deluxe[2637] <Warning>: Runtime Error: Runtime error: json.prettify takes a string or a table (got userdata)

How is this possible ? how come the store callback is not receiving at least a proper JSON object ?

thanks for your help.

Nick

userdata is basically a C structure. It behaves like a table with regards to accessing it’s members like transaction.state. It’s not a string of JSON to be decoded. You will have to do something like:

 print( "productIdentifier", transaction.productIdentifier ) print( "receipt", transaction.receipt ) print( "signature:", transaction.signature ) print( "transactionIdentifier", transaction.identifier ) print( "date", transaction.date )

to get the values.

Rob

Thanks Rob. 

I was not careful and I kept this code from the example in the Corona documentation. Would be worth it to update it so no one else is facing the same problem.

Nick

userdata is basically a C structure. It behaves like a table with regards to accessing it’s members like transaction.state. It’s not a string of JSON to be decoded. You will have to do something like:

 print( "productIdentifier", transaction.productIdentifier ) print( "receipt", transaction.receipt ) print( "signature:", transaction.signature ) print( "transactionIdentifier", transaction.identifier ) print( "date", transaction.date )

to get the values.

Rob

Thanks Rob. 

I was not careful and I kept this code from the example in the Corona documentation. Would be worth it to update it so no one else is facing the same problem.

Nick