Advice and answers from the BitPay Team

Problem:

  • While using the PHP client library for a custom ecommerce integration, you can create invoices correctly but the $_POST superglobal appears to be empty when reading an IPN or other postback from the BitPay network.

Solution:

  • There is a quirk in the way PHP handles pure JSON responses in a post request and attempting to access elements of the $_POST superglobal will not retrieve any of the post information. To work around this, you must usefile_get_contents("php://input") to read the post data directly. This is the method used in the official BitPay PHP library which you can download here: https://github.com/bitpay/php-bitpay-client.

Affects:

  • All known versions of PHP at this time.
Did this answer your question?