aporat / store-receipt-validator

PHP receipt validator for Apple iTunes, Google Play and Amazon App Store
Apache License 2.0
633 stars 153 forks source link

Google Play Response Error ( Cannot Encode to JSON ) #68

Closed omkarjadhav closed 5 years ago

omkarjadhav commented 6 years ago

Hey, We are trying to use this wrapper. It works great for iTunes but for Google Play Store we are getting an issue in response. After var_dump($response) we get this ->

ReceiptValidator\GooglePlay\PurchaseResponse Object ( [response:protected] => Google_Service_AndroidPublisher_ProductPurchase Object ( [consumptionState] => 1 [developerPayload] => com.myCompany.myAppName [kind] => androidpublisher#productPurchase [orderId] => GPA.XXXX-XXXX-XXXX-XXXX [purchaseState] => 0 [purchaseTimeMillis] => 1234567890123 [purchaseType] => 0 [internal_gapi_mappings:protected] => Array ( ) [modelData:protected] => Array ( ) [processed:protected] => Array ( ) ) [developerPayload:protected] => ) we are not able to encode it to JSON format .

( Masked my app ID and order ID on purpose )

gsingh1 commented 6 years ago

@omkarjadhav - You can get the raw response using getRawResponse() method PurchaseResponse on and then encode to json!

roshimon commented 6 years ago

@gsingh1 getRawResponse() does the trick. Thanks :+1: