mollie / mollie-api-php

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

Testmode in _links: impact #434

Closed sandervanhooft closed 3 years ago

sandervanhooft commented 4 years ago

Specifications

Describe the issue

Propagating the testmode setting to subsequent calls is now dealt with by the Mollie API. Including the testmode parameter in subsequent calls is however hardcoded in some places in this client (see here). This may cause some issues.

sandervanhooft commented 4 years ago

I'll look into this tomorrow

sandervanhooft commented 4 years ago

Problem scope is a bit larger than I thought, will continue this next week.

Most Subresource Endpoints (i.e. CustomerPayment) generate the urls, so any _links passed in via the parent resource are not being used to pass on the testmode setting.

sandervanhooft commented 4 years ago

Scenarios:

Impacted resource methods

Impacted endpoint methods

Other

sandervanhooft commented 4 years ago

Also see #417 .

@willemstuursma Significant impact. Any thoughts? I'll continue work on this this afternoon.

sandervanhooft commented 4 years ago

This php client was initially build to mirror all API endpoints, and generate the links itself.

Now, the API is providing urls for subsequent calls, including preset parameters for testmode. Using these provided urls instead of generating them in the client seems to be the preferred way.

I think it's best to distinguish between base resources (i.e. /payments) and subresources (i.e. /customer/<id>/payments).

Both of the following options are scattered throughout the client. Best to favour one of these for consistency:

Option A

  1. For root resources, use the urls generated by the client (no other choice here).
  2. For subsequent calls to subresources, use the urls provided by the base resource. Ensure additional parameters can be provided.
  3. For direct calls to subresources, keep on generating the url in the subresource endpoint. Parameters can be passed in manually.

Option B

Same as A, but for point 2:

For subsequent calls to subresources, generate the url in the client, use the base resource attributes to determine parameters like testmode and merge these with additional parameters. Use direct calls (option A point 3) for this.

sandervanhooft commented 4 years ago

@willemstuursma from previous issue discussions it seems you're favouring option A, correct?

I'm personally leaning towards option B as it's closer to the client's original design and less complex (less url/parameter parsing). Then again, I may be missing something.

sandervanhooft commented 3 years ago

Closing this for now, let me know if it should be reopened.