(Reposting this from general Android Forum as no-one seems to be able to answer there…)
Hello –
Has anyone out there figured-out how to validate Google Play in-app purchases from Corona in PHP? I can’t find any definitive resources, other than that you’re supposed to use openssl_verify… I’ve been trying code like below but it isn’t working (always returns false)
\<?php $receipt = $\_REQUEST['receipt']; // receipt data from Corona (event.transaction.receipt) $signature = $\_REQUEST['signature']; // signature from Corona (event.transaction.signature) $googlePlayKey = "MIIBIjANB... Public key text from Google Play Developer Console ..."; $publicKey = "-----BEGIN PUBLIC KEY-----\n" . chunk\_split($googlePlayKey, 64, "\n") . '-----END PUBLIC KEY-----'; function isReceiptValid( $store, $receiptdata, $signature ) { global $publicKey; if ( $store == "google" ) { $key = openssl\_get\_publickey( $publicKey ); return ( 1 == openssl\_verify( $receiptdata, base64\_decode( $signature ), $key, OPENSSL\_ALGO\_SHA1 ) ); } return false; } ?\>
Any help would be *greatly* appreciated!