Skip to content

[Bug] Return controller fails to process JSON-encoded PUSH notifications #267

Description

@Bugfunder

The Buckaroo3ReturnModuleFrontController currently assumes that PUSH notifications are always form-encoded, failing to process JSON payloads correctly. This leads to errors in the logs where the response object cannot be properly initialized.

Observed Behavior:
When receiving a JSON-encoded PUSH notification, ResponseFactory::getResponse() fails to interpret the input, resulting in an error and inability to parse the transaction status.

Proposed Fix/Workaround:
In controllers/front/return.php, the controller needs to explicitly read the raw input when form data is absent. We implemented the following workaround:

1 // In controllers/front/return.php
2 $jsonInput = file_get_contents("php://input");
3 $responseData = json_decode($jsonInput, true);
4 $transactionResponse = new \Buckaroo\Transaction\Response\TransactionResponse(null, $responseData);
5 $response = ResponseFactory::getResponse($transactionResponse);

Request for Feedback:
Could you provide guidance on whether this logic should be integrated into ResponseFactory::getResponse() directly? I believe making the factory JSON-aware would resolve this without needing custom logic in the controller.

Diff for controllers/front/return.php

1 diff --git a/controllers/front/return.php b/controllers/front/return.php
2 index f4b2545e..2c6947a6 100644
3 --- a/controllers/front/return.php
4 +++ b/controllers/front/return.php
5 @@ -65,7 +65,10 @@ class Buckaroo3ReturnModuleFrontController extends BuckarooCommonController
6              $statuses[$stat['id_order_state']] = $stat['name'];
7          }
8  
9 -        $response = ResponseFactory::getResponse();

10 + $jsonInput = file_get_contents("php://input");
11 + $responseData = json_decode($jsonInput, true);
12 + $transactionResponse = new \Buckaroo\Transaction\Response\TransactionResponse(null, $responseData);
13 + $response = ResponseFactory::getResponse($transactionResponse);
14 $this->logger->logInfo('Parse response', $response);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions