rotassator / omnipay-payway-restapi

PayWay REST API gateway for Omnipay payment processing library
MIT License
4 stars 11 forks source link

Adding Merchant and Bank Account List Requests #1

Closed brucealdridge closed 7 years ago

brucealdridge commented 7 years ago

Adding the ability to grab available Merchant / Bank Accounts

rotassator commented 7 years ago

Hi Bruce.

Thanks for your PR! Your change looks pretty straightforward.

I notice though that the "List" APIs are actually paginated, so a simple once-off call will only return the first page of items (20 items per page - https://www.payway.com.au/docs/rest.html#links-and-pagination ). While this may not affect lists of merchants or bank accounts as often, it would immediately come into play for lists of transactions, customers, etc. If there's a need for these two list functions then we'll probably come across this again in the future, so it would be good to solve it early.

Have you thought about how you might approach dealing with list pagination? Looks like the Omnipay Paypal integration has done something similar (but obviously with a quite different API):

Thoughts?

Blessings, Steve.

brucealdridge commented 7 years ago

I agree, long term it makes good sense to look at. But short term I'm not so sure. I had a look at those two samples you linked and to me they don't look like they actually handle pagination at all. You can just set the start index / id by the request parameters.

In practice it depends on how its going to be used. My expectation would be that you could use the following code

$data = $response->getData();
foreach($data['customers'] as $customer) {
    echo $customer['name'];
}

But that would mean that $response->getData() needs to return an object rather than an array. Then we just need to extend the Iterator class - http://php.net/manual/en/class.iterator.php

I think accept this PR and then creating a new issue to look into that would be the best course of action and implement on these methods once sorted.

brucealdridge commented 7 years ago

@ArjunKishore create a new issue, don't hijack an irrelevant issue. Also be specific about what you want sample code for.

ArjunKishore commented 7 years ago

@brucealdridge Apologies, I will delete my posts and will create new one