I've just upgraded to the latest ActionScript SDK, and I've had to rework all our code (we were using a year old version).
I'm currently unable to work out how to retrieve errors on BuyVirtualGoodResponse.
Here is the code:
public function handleInAppPurchaseResponse(response:BuyVirtualGoodResponse ):void
{
if (response.HasErrors)
{
var errors:Object = response.getScriptData();
}
}
In this case, errors = null. I've looked at the contents of response, and it does contain the error information I need, but I'm not sure how to get it.
Thanks,
Graeme.
Best Answer
G
Graeme Laws
said
almost 7 years ago
Thanks, I have it working with getAttribute method.
I was using the latest SDK from the page which does not have the getErrors method. I downloaded the SWC from Bitbucket, however it does not appear to be in a working state, as I received lots of what looked like socket errors. I have gone back to the older SWC and it's working fine now.
The errors in the response are in JSON format. You need to parse the error from the response as a string. In C# for instance I would do the following: Debug.Log("error buying virtual good"+ response.Errors.JSON.ToString());
This gets the error JSON from the response and parses it as a string into my console in Unity.
Does this help point you in the right direction? Do you think you can apply this in terms of ActionScript?
If not I'm happy to help you further.
Regards Patrick.
Tech Support
said
almost 7 years ago
Hi Graeme
In the ActionScript sdk, you should use the getErrors() method instead of the getScriptData() method
public function handleInAppPurchaseResponse(response:BuyVirtualGoodResponse ):void
{
if (response.HasErrors)
{
var errors:Object = response.getErrors();
}
}
Hope that help !
Gabriel
M
Marcel Piestansky
said
almost 7 years ago
Hi,
Beware that 'HasErrors' is NOT defined as a getter (as is the practice in ActionScript for 'get' methods), thus you need to use the parentheses to get the return value. If you do not type the parentheses then the if statement will always be evaluated as true. I know that for example IntelliJ IDEA does not add the parentheses when I use a code hint and confirm my selection with ENTER or TAB key so you need to be extra cautious here.
To access the error in the response, I use the following code:
if( response.HasErrors() ) {
var error:Object = response.getAttribute( "error" );
// further query the error object
}
The error object is already parsed JSON - its properties match the properties you see in TestHarness.
Marcel
M
Marcel Piestansky
said
almost 7 years ago
Hi Gabriel,
The response does not have getErrors() method, really the only way I found to get the error data is using the approach I mentioned above.
Marcel
M
Marcel Piestansky
said
almost 7 years ago
Oh, I see there is the getErrors() method now (I was using a slightly outdated SDK) - just a note that the precompiled SWC linked on this page is not necessarily the latest one - it has to be taken from the Bitbucket repository.
Marcel
G
Graeme Laws
said
almost 7 years ago
Answer
Thanks, I have it working with getAttribute method.
I was using the latest SDK from the page which does not have the getErrors method. I downloaded the SWC from Bitbucket, however it does not appear to be in a working state, as I received lots of what looked like socket errors. I have gone back to the older SWC and it's working fine now.
Graeme Laws
Hi,
I've just upgraded to the latest ActionScript SDK, and I've had to rework all our code (we were using a year old version).
I'm currently unable to work out how to retrieve errors on BuyVirtualGoodResponse.
Here is the code:
public function handleInAppPurchaseResponse(response:BuyVirtualGoodResponse ):void
{
if (response.HasErrors)
{
var errors:Object = response.getScriptData();
}
}
In this case, errors = null. I've looked at the contents of response, and it does contain the error information I need, but I'm not sure how to get it.
Thanks,
Graeme.
Thanks, I have it working with getAttribute method.
I was using the latest SDK from the page which does not have the getErrors method. I downloaded the SWC from Bitbucket, however it does not appear to be in a working state, as I received lots of what looked like socket errors. I have gone back to the older SWC and it's working fine now.
Thanks,
Graeme.
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Graeme,
The errors in the response are in JSON format. You need to parse the error from the response as a string. In C# for instance I would do the following: Debug.Log("error buying virtual good"+ response.Errors.JSON.ToString());
This gets the error JSON from the response and parses it as a string into my console in Unity.
Does this help point you in the right direction? Do you think you can apply this in terms of ActionScript?
If not I'm happy to help you further.
Regards Patrick.
Tech Support
Hi Graeme
In the ActionScript sdk, you should use the getErrors() method instead of the getScriptData() method
public function handleInAppPurchaseResponse(response:BuyVirtualGoodResponse ):void
{
if (response.HasErrors)
{
var errors:Object = response.getErrors();
}
}
Hope that help !
Gabriel
Marcel Piestansky
Hi,
Beware that 'HasErrors' is NOT defined as a getter (as is the practice in ActionScript for 'get' methods), thus you need to use the parentheses to get the return value. If you do not type the parentheses then the if statement will always be evaluated as true. I know that for example IntelliJ IDEA does not add the parentheses when I use a code hint and confirm my selection with ENTER or TAB key so you need to be extra cautious here.
To access the error in the response, I use the following code:
The error object is already parsed JSON - its properties match the properties you see in TestHarness.
Marcel
Marcel Piestansky
Hi Gabriel,
The response does not have getErrors() method, really the only way I found to get the error data is using the approach I mentioned above.
Marcel
Marcel Piestansky
Oh, I see there is the getErrors() method now (I was using a slightly outdated SDK) - just a note that the precompiled SWC linked on this page is not necessarily the latest one - it has to be taken from the Bitbucket repository.
Marcel
Graeme Laws
Thanks, I have it working with getAttribute method.
I was using the latest SDK from the page which does not have the getErrors method. I downloaded the SWC from Bitbucket, however it does not appear to be in a working state, as I received lots of what looked like socket errors. I have gone back to the older SWC and it's working fine now.
Thanks,
Graeme.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics