Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different POST data for different notifications #112

Open
rafaellop opened this issue Nov 3, 2020 · 1 comment
Open

Different POST data for different notifications #112

rafaellop opened this issue Nov 3, 2020 · 1 comment

Comments

@rafaellop
Copy link

I'm testing using the sandbox and for a finalized transaction the notification script passed as notifyUrl receives data POST data as array e.g.:

{
    "order":{
        "orderId":"DHRGFXKV5B201103GUEST000P01",
        "extOrderId":"50024",
...
        "status":"COMPLETED",
...
    },
    "properties":[
        {
            "name":"PAYMENT_ID",
            "value":"5000986497"
        }
    ]
}

In my notifications handler I can now check the status using e.g.

$response = OpenPayU_Order::consumeNotification($data);
$response->getResponse()->order->status;

as mentioned in the readme.

but if the notification is for example for a refund issued manually from the web Payu Manager Panel the POST data sent to the notifyUrl script is in this format:

{
    "orderId":"DHRGFXKV5B201103GUEST000P01",
    "extOrderId":"50024",
    "refund":{
        "refundId":"5000024357",
        "status":"FINALIZED",
        "reason":"refund",
        "refundDate":"2020-11-03T17:58:46.567+01:00"
    }
}

It's a mess. I cannot use the same logic because the $response from the consumeNotification() returns an object with different methods and properties.

Is this intentionally and if so how to handle refunds like this using the notification handler script? Or the only way is a hardcoded POST data analyzer which will decide if this is a refund notification sent in different format than expected.

@rafaellop
Copy link
Author

At the moment I must do the following:

$response = OpenPayU_Order::consumeNotification($data);
if ($response->getResponse()->refund) {
    // handle refund
} else {
    // handle other notifications
}

I'd prefer to have a nice switch/case for statuses, but this will do...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant