btcpayserver / btcpayserver-php-client

PHP implementation for the BTCPayServer cryptographically secure RESTful API
MIT License
29 stars 33 forks source link

buyer field not populated when getting invoice from client #25

Open petzsch opened 4 years ago

petzsch commented 4 years ago

When processing an IPN and getting an Invoice via the API, I am not able to query the buyerEmail via:

$buyerEmail = $invoice->getBuyerEmail();

All I get is an empty string.

The code is mainly taken from the tutorial code of this repo: IPNlogger.php

After some discussion on MM I think I narrowed the problem down to this function:

https://github.com/btcpayserver/btcpayserver-php-client/blob/master/src/BTCPayServer/Client/Client.php#L106

It is lacking the population of the Buyer Data fields.

My first attempt at fixing the issue with:

->setBuyer(array_key_exists('buyer', $data) ? $data['buyer'] : '')

failed with the following error: PHP message: PHP Fatal error: Uncaught TypeError: Argument 1 passed to BTCPayServer\Invoice::setBuyer() must be an instance of BTCPayServer\BuyerInterface, array given,

It would be greatly appreciated if someone could supply a fix for this.