Closed dqos closed 6 years ago
Hey @qarizma,
Have you looked at the examples ?
I think this is what you are looking for: https://github.com/bunq/sdk_php/blob/develop/example/request_example.php
@OGKevin
Okay that got me goig. Few questions:
RequestInquiry::get
returned in $request
?RequestInquiry::FIELD_REDIRECT_URL => "http://google.nl"
in $requestMap
but it doesn't seem to be working?I'm using the exact same code as the example you pointed out.
Thanks!
@qarizma
RequestInquiry::get returns: https://github.com/bunq/sdk_php/blob/39fd6bf95f858383caad13dc4e3ae03177f09b4b/src/Model/Generated/Endpoint/BunqResponseRequestInquiryList.php
You can find this out by reading the code and or doc blocks above the methods you are using. There are plans to make SDK documentation better! But for now, please read the code and or doc blocks that are written.
How do do you mean FIELD_REDIRECT_URL is not working ? What have you done/tried exactly ?
And no, sandbox links indeed dont work, they are dummy links. The ones on production do work!
@OGKevin thanks! Do you have a code example for me how to get those results into an array?
About 2, I want to redirect users to a specific page after the payment. So I guessed and added FIELD_REDIRECT_URL to:
$requestMap = [
RequestInquiry::FIELD_AMOUNT_INQUIRED => new Amount(REQUEST_AMOUNT, CURRENCY_EUR),
RequestInquiry::FIELD_COUNTERPARTY_ALIAS => new Pointer(POINTER_TYPE_EMAIL, REQUEST_COUNTERPARTY_EMAIL),
RequestInquiry::FIELD_DESCRIPTION => REQUEST_DESCRIPTION,
RequestInquiry::FIELD_ALLOW_BUNQME => true,
RequestInquiry::FIELD_REDIRECT_URL => "http://google.nl"
];
Not sure if that's correct? The response $request
does not contain an url, but this: ["redirectUrl":protected]=> NULL
Thanks again, I think I almost know how to get this working.
@qarizma I don't understand, what do you want to get into an array ? And i'm not quite sure if this is really SDK related :sweat_smile:.
Regarding the FIELD_REDIRECT_URL
, this seems to be a bug in our backend. This field seems to not be returned in the response at all hence the SDK sets it to null. Thanks for reporting this we will pick it up internally.
This wont stop the redirect url from working however. If you open the bunq sandbox app and pay the request you will still get redirected to the url :thumbsup:.
So in other words, the redirect url is set correctly, we just dont return it in the response while it should.
Okay great! Well maybe it’s not fully related to the SDK, probably my PHP skills. I’m used to get API responses in JSON and decode them into an array so I can access values easier. How am I doing that with this object that is returned?
Let’s say I want to save the bunq payment link in the variable $link.
I already tried casting the object to an array, but that isn’t really nice I think.
Thanks for your help!
I don't understand, why would you want to cast the object to an array ? The object is populated with data and you can get the data via accessors ?
$request = RequestInquiry::get($apiContext, static::$userId, static::$monetaryAccountId, $id);
$request->getValue()->getRedirectUrl();
$request->getValue()->getDescription();
$request->getValue()->getAmountInquired()->getValue();
By reading the doc blocks above the methods you can see what is being returned.
If you still want to make it an array, which I don't really understand why you would want to do that just to access the data, you can use this method: https://github.com/bunq/sdk_php/blob/39fd6bf95f858383caad13dc4e3ae03177f09b4b/src/Model/Core/BunqModel.php#L359
Im closing this issue as its not an bug, feel free to comment afterwards.
The first time that I saw the bunq PHP SDK, I was quite shocked. It looked very hard to work with and I was wondering why there are so many functions, is that really needed? Why not start with the basic things? Anyway let's proceed.
Case: I want to create an iDeal request using the API.
How am I supposed to do this? I have read the docs and still didn't got any further.
I was expecting something like this: POST /api/ideal-request/ Params(description, amount, redirecturl, account) Results{"STATUS","REQUESTID", "PAYMENTURL"} GET /api/ideal-request-status/$requestid Results{"ALL INFO ABOUT THE REQUEST"}
In the end, I want to be able to call a function like this: getiDealRequest($description, $amount, $redirect); That would return the payment URL.
Maybe someone could help me in the right direction?