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

Simple way to create a iDeal request? #103

Closed
dqos opened this issue Jan 12, 2018 · 7 comments
Closed

Simple way to create a iDeal request? #103

dqos opened this issue Jan 12, 2018 · 7 comments

Comments

@dqos
Copy link

dqos commented Jan 12, 2018

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?

@OGKevin
Copy link
Contributor

OGKevin commented Jan 12, 2018

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

@dqos
Copy link
Author

dqos commented Jan 12, 2018

@OGKevin

Okay that got me goig. Few questions:

  1. How can I correctly access the data that RequestInquiry::get returned in $request?
  2. I added RequestInquiry::FIELD_REDIRECT_URL => "http://google.nl" in $requestMap but it doesn't seem to be working?
  3. Returned sandbox links aren't working right?

I'm using the exact same code as the example you pointed out.

Thanks!

@OGKevin
Copy link
Contributor

OGKevin commented Jan 12, 2018

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

@dqos
Copy link
Author

dqos commented Jan 12, 2018

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

@OGKevin
Copy link
Contributor

OGKevin commented Jan 12, 2018

@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 😅.

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 👍.

So in other words, the redirect url is set correctly, we just dont return it in the response while it should.

@dqos
Copy link
Author

dqos commented Jan 12, 2018

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!

@OGKevin OGKevin closed this as completed Jan 12, 2018
@OGKevin
Copy link
Contributor

OGKevin commented Jan 12, 2018

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:

public function jsonSerialize(): array

Im closing this issue as its not an bug, feel free to comment afterwards.

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

No branches or pull requests

2 participants