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

Where to add the sharedSecret #50

Closed ef33zy closed 7 years ago

ef33zy commented 7 years ago

Hi,

Pardon my ignorance/limited knowledge, where do I add/include the sharedSecret value obtained from iTunesConnect? I do not want to include it in the app (which I assume is bad practice anyway)

Would I need to change in the Validator.php:

protected $_sharedSecret = null; to: protected $_sharedSecret = 'myOwnSharedSecret';?

Thanks for your help.

albertleao commented 7 years ago

Hello! Just ran into this issue as well. Reading through the code I found the following method

public function setSharedSecret($secret)

You can run this function on your instantiated validator and it will work.

ef33zy commented 7 years ago

Hi @albertleao, when you say '...run this function on your instantiated validator...' how do you mean?

albertleao commented 7 years ago

$validator->setSharedSecret($secret);

ef33zy commented 7 years ago

Hi @albertleao Thanks for that, it works as below, with the receipt data 'hard-coded' in there ($receiptBase64Data), just need to figure how to without hard-coding it in. Thanks once again.

image

albertleao commented 7 years ago

Environment variables, config files... there are several ways to do that but it's outside the scope of this library.