Closed timvdalen closed 5 years ago
@timvdalen Good wish 👍🏻
This field (merchant_category_code) is also not in the documentation (https://doc.bunq.com/#/payment/Read_Payment_for_User_MonetaryAccount), that is probably the cause @kojoru ?
Indeed, I found it through raw requests to the API
Any update on this?
🤷♂️, you could always edit the generated code manually and use that until this is fixed.
If you can provide a raw response example i could show you where/how to change the generated code.
Sure!
Considering this raw payment (with a bunch of fields omitted):
{"Payment":{
...,
"counterparty_alias":{
"iban":null,
"is_light":null,
"display_name":"AH",
"avatar":{},
"label_user":{
"uuid":null,
"display_name":"AH",
"country":"NL",
"avatar":null,
"public_nick_name":"AH"
},
"country":"NL",
"merchant_category_code":"5499"
},
...
}}
I'm trying to get the merchant_category_code
value.
Add the following
/**
* Why does it take so long to fix this.....
*
* @var string
*/
protected $merchantCategoryCode;
/**
* @return string
*/
public function getMerchantCategoryCode(): string
{
return $this->merchantCategoryCode;
}
in src/Model/Generated/Object/LabelMonetaryAccount.php
and it should magically work fine.
Works great, thanks!
One minor tweak to anyone else wanting to use this in the meantime, the category code is optional (as it only works for card payments) so remove the : string
return type.
Np. I told them to let me maintain my maintainer status even thought i dont work there anymore (as an outside contributer/maintainer) but 🤷♂️. This takes 5 mins to fix in the generator :(.
Steps to reproduce:
Payment
made with a card at a merchant POS$payment->getCounterpartyAlias()->getMerchantCategoryCode()
What should happen:
What happens:
getMerchantCategoryCode()
is not defined onLabelMonetaryAccount
(rightly so, as it is a more generic model than a specific merchant alias)SDK version and environment
Extra info:
Alternatively, getting access to the raw JSON through a
BunqResponse
would be a good compromise if there is no way to fit this into the existing models. That way, users can extract extra fields they need themselves.