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

Unable to validate receipt on ubuntu 20 or 22 #176

Closed ZhangWei-bi closed 9 months ago

ZhangWei-bi commented 11 months ago

test_itunes_receipt.php works fine in mac, but not on Ubuntu.

PHP 8.1.2 (cli) curl 8.1.2 Composer version 2.6.6 Ubuntu 22.04.3 LTS (I also tried Ubuntu 20 with slightly different version of php and curl, same issue)

got error = Client error: POST https://sandbox.itunes.apple.com/verifyReceipt resulted in a 400 Bad Request response

0 /home/ubuntu/test/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create()

1 /home/ubuntu/test/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Middleware::GuzzleHttp{closure}()

2 /home/ubuntu/test/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler()

3 /home/ubuntu/test/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()

4 /home/ubuntu/test/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\TaskQueue->run()

5 /home/ubuntu/test/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()

6 /home/ubuntu/test/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()

7 /home/ubuntu/test/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()

8 /home/ubuntu/test/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()

9 /home/ubuntu/test/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait()

10 /home/ubuntu/test/vendor/aporat/store-receipt-validator/src/iTunes/Validator.php(275): GuzzleHttp\Client->request()

11 /home/ubuntu/test/vendor/aporat/store-receipt-validator/src/iTunes/Validator.php(260): ReceiptValidator\iTunes\Validator->sendRequestUsingClient()

12 /home/ubuntu/test/asdf/test_itunes_receipt.php(27): ReceiptValidator\iTunes\Validator->validate()

13 {main}

ubuntu@ubuntu:~$

The only solution I found online was to downgrade guzzle to 5 (not sure if it will work this this package), but I am struggling to use my fork of this project. I keep getting errors like

Could not find a matching version of package zhangwei-bi/store-receipt-validator. Check the p
ackage spelling, your version constraint and that the package is available
in a stability which matches your minimum-stability (stable).

If someone could help with how to use a fork of this branch, let me know. Thanks

Stafox commented 11 months ago

HTTP 400 error means that you sent the data incorrectly to the Apple. Check the error returned in response body.

Stafox commented 9 months ago

Feel free to reopen the issue in case you want to provide more details