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

Cannot receive POST object of type Message #7781

Closed
Dekari opened this issue Aug 28, 2015 · 2 comments
Closed

Cannot receive POST object of type Message #7781

Dekari opened this issue Aug 28, 2015 · 2 comments

Comments

@Dekari
Copy link
Contributor

Dekari commented Aug 28, 2015

Steps to reproduce the issue

Need a webhook that returns data to a controller with post data of type
Message

The issue is that if you try to get data via the JInput, the data is not there..
also the deprecated:
$post = JRequest::get('post');
is not bringing any data...

Instead you need to use:

$postdata = file_get_contents("php://input");

Which i feel is pretty unsafe..for joomla standards in order to use!

the url that returns that explains the webhook is here:

https://github.com/VivaPayments/API/wiki/Webhooks

Expected result

the actual post data to be inside JINPUT....

the above function with file_get_contents gets the following data:

stdClass Object
(
[Url] => https://www.keeppet.gr/develop/index.php?option=com_keeppet&task=api.receiveVivaWebHook
[EventData] => stdClass Object
(
[Email] => chrisvalmas@gmail.com
[ParentId] =>
[Amount] => 340
[ClientId] =>
[MerchantId] => a488534f-b418-4a01-8031-7499f784ee1a
[OrderCode] => 334178772608
[ProductId] =>
[StatusId] => F
[FullName] => dasdas
[Statement] =>
[ResellerId] =>
[InsDate] => 2015-08-28T17:07:15.33
[TotalFee] => 0
[CardNumber] => 411111XXXXXX1111
[SourceCode] => Default
[CompanyName] => 6978999659
[TransactionId] => f6f18164-5e62-44e7-9fda-892ce1a771ad
[CurrencyCode] => 978
[OrderCulture] => el-GR
[MerchantTrns] => b1
[CustomerTrns] => dasddasdsa
[IsManualRefund] =>
[TargetPersonId] =>
[TransactionTypeId] => 5
[TotalInstallments] => 0
[TotalCommission] => 8.4
[CurrentInstallment] => 0
[ResellerSourceCode] =>
[ResellerSourceName] =>
[ResellerCompanyName] =>
[ResellerSourceAddress] =>
[CardTypeId] => 0
[AssignedMerchantUsers] => Array
(
)

        [AssignedResellerUsers] => Array
            (
            )

    )

[Created] => 2015-08-28T14:07:15.4848312Z
[EventTypeId] => 1796
[MessageId] => d3bd60c1-5760-4ecd-b4c6-3b6dc6a589c5
[RecipientId] => a488534f-b418-4a01-8031-7499f784ee1a
[MessageTypeId] => 512

)

Actual result

no data in jinput:

JInput Object
(
[options:protected] => Array
(
)

[filter:protected] => JFilterInput Object
    (
        [tagsArray] => Array
            (
            )

        [attrArray] => Array
            (
            )

        [tagsMethod] => 0
        [attrMethod] => 0
        [xssAuto] => 1
        [tagBlacklist] => Array
            (
                [0] => applet
                [1] => body
                [2] => bgsound
                [3] => base
                [4] => basefont
                [5] => embed
                [6] => frame
                [7] => frameset
                [8] => head
                [9] => html
                [10] => id
                [11] => iframe
                [12] => ilayer
                [13] => layer
                [14] => link
                [15] => meta
                [16] => name
                [17] => object
                [18] => script
                [19] => style
                [20] => title
                [21] => xml
            )

        [attrBlacklist] => Array
            (
                [0] => action
                [1] => background
                [2] => codebase
                [3] => dynsrc
                [4] => lowsrc
            )

    )

[data:protected] => Array
    (
        [option] => com_keeppet
        [task] => receiveVivaWebHook
        [Itemid] => 
    )

[inputs:protected] => Array
    (
        [cookie] => JInputCookie Object
            (
                [options:protected] => Array
                    (
                    )

                [filter:protected] => JFilterInput Object
                    (
                        [tagsArray] => Array
                            (
                            )

                        [attrArray] => Array
                            (
                            )

                        [tagsMethod] => 0
                        [attrMethod] => 0
                        [xssAuto] => 1
                        [tagBlacklist] => Array
                            (
                                [0] => applet
                                [1] => body
                                [2] => bgsound
                                [3] => base
                                [4] => basefont
                                [5] => embed
                                [6] => frame
                                [7] => frameset
                                [8] => head
                                [9] => html
                                [10] => id
                                [11] => iframe
                                [12] => ilayer
                                [13] => layer
                                [14] => link
                                [15] => meta
                                [16] => name
                                [17] => object
                                [18] => script
                                [19] => style
                                [20] => title
                                [21] => xml
                            )

                        [attrBlacklist] => Array
                            (
                                [0] => action
                                [1] => background
                                [2] => codebase
                                [3] => dynsrc
                                [4] => lowsrc
                            )

                    )

                [data:protected] => Array
                    (
                    )

                [inputs:protected] => Array
                    (
                    )

            )

        [get] => JInput Object
            (
                [options:protected] => Array
                    (
                    )

                [filter:protected] => JFilterInput Object
                    (
                        [tagsArray] => Array
                            (
                            )

                        [attrArray] => Array
                            (
                            )

                        [tagsMethod] => 0
                        [attrMethod] => 0
                        [xssAuto] => 1
                        [tagBlacklist] => Array
                            (
                                [0] => applet
                                [1] => body
                                [2] => bgsound
                                [3] => base
                                [4] => basefont
                                [5] => embed
                                [6] => frame
                                [7] => frameset
                                [8] => head
                                [9] => html
                                [10] => id
                                [11] => iframe
                                [12] => ilayer
                                [13] => layer
                                [14] => link
                                [15] => meta
                                [16] => name
                                [17] => object
                                [18] => script
                                [19] => style
                                [20] => title
                                [21] => xml
                            )

                        [attrBlacklist] => Array
                            (
                                [0] => action
                                [1] => background
                                [2] => codebase
                                [3] => dynsrc
                                [4] => lowsrc
                            )

                    )

                [data:protected] => Array
                    (
                        [option] => com_keeppet
                        [task] => api.receiveVivaWebHook
                    )

                [inputs:protected] => Array
                    (
                    )

            )

        [post] => JInput Object
            (
                [options:protected] => Array
                    (
                    )

                [filter:protected] => JFilterInput Object
                    (
                        [tagsArray] => Array
                            (
                            )

                        [attrArray] => Array
                            (
                            )

                        [tagsMethod] => 0
                        [attrMethod] => 0
                        [xssAuto] => 1
                        [tagBlacklist] => Array
                            (
                                [0] => applet
                                [1] => body
                                [2] => bgsound
                                [3] => base
                                [4] => basefont
                                [5] => embed
                                [6] => frame
                                [7] => frameset
                                [8] => head
                                [9] => html
                                [10] => id
                                [11] => iframe
                                [12] => ilayer
                                [13] => layer
                                [14] => link
                                [15] => meta
                                [16] => name
                                [17] => object
                                [18] => script
                                [19] => style
                                [20] => title
                                [21] => xml
                            )

                        [attrBlacklist] => Array
                            (
                                [0] => action
                                [1] => background
                                [2] => codebase
                                [3] => dynsrc
                                [4] => lowsrc
                            )

                    )

                [data:protected] => Array
                    (
                    )

                [inputs:protected] => Array
                    (
                    )

            )

        [files] => JInputFiles Object
            (
                [decodedData:protected] => Array
                    (
                    )

                [options:protected] => Array
                    (
                    )

                [filter:protected] => JFilterInput Object
                    (
                        [tagsArray] => Array
                            (
                            )

                        [attrArray] => Array
                            (
                            )

                        [tagsMethod] => 0
                        [attrMethod] => 0
                        [xssAuto] => 1
                        [tagBlacklist] => Array
                            (
                                [0] => applet
                                [1] => body
                                [2] => bgsound
                                [3] => base
                                [4] => basefont
                                [5] => embed
                                [6] => frame
                                [7] => frameset
                                [8] => head
                                [9] => html
                                [10] => id
                                [11] => iframe
                                [12] => ilayer
                                [13] => layer
                                [14] => link
                                [15] => meta
                                [16] => name
                                [17] => object
                                [18] => script
                                [19] => style
                                [20] => title
                                [21] => xml
                            )

                        [attrBlacklist] => Array
                            (
                                [0] => action
                                [1] => background
                                [2] => codebase
                                [3] => dynsrc
                                [4] => lowsrc
                            )

                    )

                [data:protected] => Array
                    (
                    )

                [inputs:protected] => Array
                    (
                    )

            )

    )

System information (as much as possible)

Joomla 3.4.3 hosted on Bluehost PHP 5.4

Additional comments

I can help in reproduce and check any code suggestions for this in my custom component as it's rather complicated to build up a test environmen!

@mbabker
Copy link
Contributor

mbabker commented Aug 28, 2015

Using JInput you can access $input->json->get('whatever'). The json in there loads up a JInputJson object that will let you pull that data through the API.

@Dekari
Copy link
Contributor Author

Dekari commented Aug 28, 2015

thanks!

worked like a charm!

cann close tracker :)

2015-08-28 18:06 GMT+03:00 Michael Babker notifications@github.com:

Using JInput you can access $input->json->get('whatever'). The json in
there loads up a JInputJson
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/input/json.php
object that will let you pull that data through the API.


Reply to this email directly or view it on GitHub
#7781 (comment).

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

No branches or pull requests

4 participants