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

Generate QR code for the payment #197

Closed ShafiKh closed 2 years ago

ShafiKh commented 2 years ago

As per the documentation, calling the following API will return a qrCode object in the details object

POST https://api.mollie.com/v2/payments?include=details.qrCode.

How can I achieve that?

sandervanhooft commented 2 years ago

Hi @ShafiKh ,

In that same codedocumentation you'll find php examples that can be used with this package. What have you tried so far?

ShafiKh commented 2 years ago

@sandervanhooft I haven't tried because i can't attach ?include=details.qrCode to the API call, how can i attach ?include=details.qrCode to the API call? sorry i am understanding it wrong

ShafiKh commented 2 years ago

I just tried it, here is the payload :

$payment = Mollie::api()->payments->create([
    "amount" => [
        "currency" => "EUR",
        "value" => "1.20"
    ],
    "description" => "Order #" . $invoice->id,
    "redirectUrl" => 'redirect URL',
    "webhookUrl" => 'webhook URL',
    "method" => "ideal",
    "metadata" => [
        "order_id" => 123123,
    ],
    [
        "include" => "details.qrCode",
    ]
]);

It is returning this :

{"error":{"message":"[2022-08-24T18:52:04+0000] Error executing API call (422: Unprocessable Entity): Non-existent body parameter \"0.include\" for this API call. Did you mean: \"locale\"?. Field: 0.include. Documentation: https:\/\/docs.mollie.com\/overview\/handling-errors"}}

ShafiKh commented 2 years ago

Made it working, had to move this :

[ "include" => "details.qrCode", ]

outside of the first array.

Thanks, good work

sandervanhooft commented 2 years ago

Try


$filters = ["include" => "details.qrCode"];

$payment = Mollie::api()->payments->create($payload, $filters);
ShafiKh commented 2 years ago

Yep, that's better, thanks