4

The redirectURL does not seem to POST any data back. It seems to use a GET request. How do I know the payment ID or payment status on the return URL?

$payment = \mollie::api()->payments()->create([
    'amount'        => $price,
    'customerId'    => $customer->id,
    'description'   => 'My Initial Payment',
    'redirectUrl'   => \URL::to('/after-payment'),
]);
Z0q
  • 1,689
  • 3
  • 28
  • 57

2 Answers2

5

The POST request Daan describes is for the webhook only. Mollie will redirect back to your website using a GET request to the redirectUrl you provide. There is no data sent back to your redirectUrl, however you could add your payment/invoice id to the GET parameters in the redirectUrl:

$payment = \mollie::api()->payments()->create([
    'amount'        => $price,
    'customerId'    => $customer->id,
    'description'   => 'My Initial Payment',
    'redirectUrl'   => \URL::to('/after-payment').'?invoice_id='.$invoice->id,
]);
Mark de Groot
  • 51
  • 1
  • 2
3

Edit: as pointed out in the comments, I was talking about the webhook URL. Mark’s answer is the correct one, as he’s describing the redirect URL.

As stated in Mollie's docs, a POST request is sent with one parameter id=tr_xxxxxx. Are you sending a 301 or 302 redirection header? In that case the post data is lost and you'll receive a GET request.

Note that you can always add your own transaction identifier to the webhook URL if you need the redirection.

Daan
  • 327
  • 3
  • 10
  • 1
    You are talking about a different thing, the calling of the Webhook instead of the final call to the redirect which is for sure a GET request without any parameters to identify for which transaction the order is complete (paid, canceled, expired, etc.). But as Mark de Groot stated you can include your own unique invoice id to the redirectUrl and pick it up afterwards when the redirectUrl is called. – Youp Bernoulli Jan 18 '19 at 11:28
  • 1
    @BernoulliIT You are correct, I’ve added a notice above my answer to point to Mark’s correct answer. – Daan Feb 05 '19 at 21:23
  • is this i get id in the query or params or body in the redirectUrl ?? – Nishang Raiyani Jun 06 '23 at 11:08