Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow access to merchant_category_code in the counterparty_alias #171

Closed
2 tasks done
timvdalen opened this issue Jan 22, 2019 · 9 comments · Fixed by #179
Closed
2 tasks done

Allow access to merchant_category_code in the counterparty_alias #171

timvdalen opened this issue Jan 22, 2019 · 9 comments · Fixed by #179

Comments

@timvdalen
Copy link

Steps to reproduce:

  1. Get a reference to a Payment made with a card at a merchant POS
  2. Try to call $payment->getCounterpartyAlias()->getMerchantCategoryCode()

What should happen:

  1. Get the merchant's category code

What happens:

  1. getMerchantCategoryCode() is not defined on LabelMonetaryAccount (rightly so, as it is a more generic model than a specific merchant alias)

SDK version and environment

  • Tested on 1.2.2
  • Sandbox
  • Production

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.

@basst85
Copy link

basst85 commented Jan 23, 2019

@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 ?

@timvdalen
Copy link
Author

Indeed, I found it through raw requests to the API

@timvdalen
Copy link
Author

Any update on this?

@OGKevin
Copy link
Contributor

OGKevin commented Mar 9, 2019

🤷‍♂️, you could always edit the generated code manually and use that until this is fixed.

@OGKevin
Copy link
Contributor

OGKevin commented Mar 9, 2019

If you can provide a raw response example i could show you where/how to change the generated code.

@timvdalen
Copy link
Author

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.

@OGKevin
Copy link
Contributor

OGKevin commented Mar 9, 2019

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.

@timvdalen
Copy link
Author

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.

@OGKevin
Copy link
Contributor

OGKevin commented Mar 9, 2019

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 :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants