mollie / laravel-mollie

Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite
https://www.mollie.com/
MIT License
322 stars 62 forks source link

Get all Payments by metadata? #198

Closed christoph-werker closed 2 years ago

christoph-werker commented 2 years ago

Dear Team,

i'm struggle to get all Payments by a specific meta_data. I set the User in the Metadata and want to get all previous payments from the User.

I can fetch all the payments without any filter by Mollie::api()->payments()->page(); but don't found a solution to add a filter.

Thanks

sandervanhooft commented 2 years ago

Hi,

Can you share a full code sample so we get a good understanding of your issue?

christoph-werker commented 2 years ago

Hi sander,

There is not much code jet. For example, i create several payments with mollie and all the payments have custom metadata. For example a id from the customer.

Creating the Payments:

Mollie::api()->payments->create(
  "method" => 'creditcard',
  "locale" => 'de_DE',
  "amount" => [
      "currency" => "EUR",
  ]
  ....
  "metadata" => [
      "customer" => 123456,
  ],
  ...
)

And after a while, i want to get all the payments with the metadata customer = 123456.

What i've found is, that i can get previous payments by Mollie::api()->payments()->page(); But i dont found a way to get payments with a specific filter like "metadata", "email" …

I hope that this explain my case.

sandervanhooft commented 2 years ago

Hi @christoph-werker ,

Mollie does not offer something like a query filter if that's what you are looking for.

The next best thing would be to iterate over the pages (there are next() and hasNext() helper methods) and build the resulting array yourself.

Hope that helps.