-
Notifications
You must be signed in to change notification settings - Fork 48
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
refactored IPN to use base IPN class from civicrm #225
base: 4.7-dev
Are you sure you want to change the base?
Conversation
This allows use of webhook in format /civicrm/payment/ipn/N drastik#221
*/ | ||
|
||
static public function handlePaymentNotification() { | ||
$data_raw = file_get_contents("php://input"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this line... Most of the payment processors seem to do something like $params = array_merge($_GET, $_REQUEST);
Can we do that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That format also caught my eye because I'm not used to that format either.
However, I investigated and noticed that the Stripe payment processor recommends that syntax (https://stripe.com/docs/webhooks) and the PHP manual suggests that in some cases it is better then $_POST (https://secure.php.net/manual/en/wrappers.php.php).
But most importantly, it will fail if we switch to $_POST because stripe is not sending a normal key value pair - instead it is sending raw JSON.
Here's the difference - I wrote a test script:
<?php
print_r($_POST);
print_r(file_get_contents("php://input"));
echo "\n";
And here's the difference:
0 jamie@turkey:cdtemp.Q7dESJ$ curl --data-raw '{"name":"bob"}' https://wfan.loc.cx/test.php
Array
(
[{"name":"bob"}] =>
)
{"name":"bob"}
0 jamie@turkey:cdtemp.Q7dESJ$
If we use $_POST we have to extract the index which is cumbersome compared with simply getting the raw data, which is what we ultimately want.
This allows use of webhook in format /civicrm/payment/ipn/N
#221