mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
552 stars 191 forks source link

Feature Request: allow to easily determine which Invoice "covers" a specific Payment #215

Closed holtkamp closed 6 years ago

holtkamp commented 6 years ago

Specifications

Describe the request

Context

Sometimes it is required to process a Payment in an administration. Which is explained here:

It would be nice if this can be automated, especially when a lot of Payments are processed.

Feature Request To properly process a Mollie Payment in a financial administration, it would be nice to be able to easily determine which Mollie Invoice "covers" the Payment.

Currently it is possible to determine which Invoice "covers" a Payment with identifier X by:

Maybe this can be simplified? For example using one of the following approaches:

willemstuursma commented 6 years ago

In v2, you can go from Payment => Settlement => Invoice using the _link property, does this cover your case?

The payment will have a Settlement if it is settled, and the Settlement will have an Invoice if it is invoiced.

holtkamp commented 6 years ago

@willemstuursma thanks for the swift reply!

In v2, you can go from Payment => Settlement => Invoice using the _link property, does this cover your case?

https://docs.mollie.com/reference/v2/payments-api/get-payment#response describes this part of _links as:

settlement: The API resource URL of the settlement this payment has been settled with. Not present if not yet settled.

Mmm, yeah, I guess this is useful. Only when navigating object graphs, the use of API resource URLs is less useful / elegant. We should then extract the SettlementID from the URL. A more "native" approach, which does not care about APIs or URLs might be preferred?

When I think of it allowing the Invoice API to "load Invoice by SettlementId" might also do the job, since Payment.settlementId exists, the approach would then be:

willemstuursma commented 6 years ago

I see that we are missing some useful accessors on the Payment object, e.g. getSettlement() which would make live a bit easier for you.

Smitsel commented 6 years ago

I think @willemstuursma his suggestion is the way to go. But using the _links for navigation is not really elegant for the client.

I could however add it to the Payment resource like this: $payment->settlement().

But we currently don't have a /settlement/{token}/invoices endpoint. So we can't do the same for the Settlement resource. And loading an invoice by settlementId is also not supported right now.

holtkamp commented 6 years ago

But we currently don't have a /settlement/{token}/invoices endpoint. So we can't do the same for the Settlement resource. And loading an invoice by settlementId is also not supported right now.

Would that be feasible to add?

I guess adding a property Settlement.invoiceId would be a first step which already would simplify life a bit 😄

Smitsel commented 6 years ago

We'll discuss internally and come back to you.

willemstuursma commented 6 years ago

Hi @holtkamp. We've added an invoiceId property and a link to the invoice on the Settlement resources (still needs to be added to this client though).

Hope this helps.

Adding an v2/invoice/inv_xxxxx/settlements endpoint is not on the roadmap, sorry.

holtkamp commented 6 years ago

Thanks for the response @willemstuursma

We've added an invoiceId property and a link to the invoice on the Settlement resources (still needs to be added to this client though).

Is this for both version v1 and v2 of the API?

willemstuursma commented 6 years ago

Only in v2 @holtkamp.