-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/financial#27 Paypal_Standard recurring IPNs don't work #12387
Conversation
(Standard links)
|
@mattwire you can rebase this now |
@mattwire I think your issue description needs some nuance - I don't think all IPNs are broken - and the tests in CRM_Core_Payment_PayPalIPNTest suggest some are tested as working - so I think there is some extra detail to the scenario - we should try to reproduce in the a test. |
@eileenmcnaughton @davejenx @pradpnayak Thanks for taking a look at this and commenting. I've taken a look at the unit test that @eileenmcnaughton found and identified some issues with it which are now included in this PR. Also, below is a much more detailed description of the problems with the PayPal_Standard IPN and the fixes required. @pradpnayak Could you take another look for me please?
Note that PayPal Pro IPN and most other payment processors do already call the repeattransaction API when creating subsequent contributions for a recurring transaction. That is the correct thing for a payment processor to be doing to ensure it's behaviour is consistent. |
$contributionParams = array_merge([ | ||
'total_amount' => '200', | ||
'invoice_id' => $this->_invoiceID, | ||
'financial_type_id' => 1, |
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.
can you change this to 'financial_type_id' => 'Donation',
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.
Wouldn't it be more appropriate to use something like CRM_Core_Pseduoconstant::value(‘CRM_Contribute_BAO_Contribution’, ‘financial_type_id’, 'Donation’)
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.
Done. @JoeMurray Normally yes. In this case we can use API "magic" so can set 'Donation' directly and the API will work it out.
6a8bc5b
to
8d3af43
Compare
$objects['contribution'] = &$contribution; | ||
// In future moving to create pending & then complete, but this OK for now. | ||
// Also consider accepting 'Failed' like other processors. | ||
$input['contribution_status_id'] = $contributionStatuses['Completed']; |
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.
Can we use $input['contribution_status_id'] = 'Completed' ?
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.
@pradpnayak I think it probably works either way?
@mattwire I had setup two instances with CiviCRM 5.3.0 one with current state patch and without patch. Test case: Without patch
Expected result : Record subsequent recurring contribution Test case: With patch
Expected result : Record subsequent recurring contribution I couldn't replicate the issue through paypal ipn callback. However when i tried to use fake ipn call i could replicate the issue i.e subsequent payment were not created for $10 as it was failing silently before applying patch and worked after applying patch. The ipn callback fails when i use civicrm/extern/ipn.php as notification url and current version of civicrm uses civicrm/payment/ipn/1? as notification url from paypal where 1 is a payment processor Id thats the reason i couldn't replicate the issue. @mattwire your client's paypal must be using older version of notification url which doesn't pass payment processor id and the code have to rely on business email or payment processor id from contribution recur. Note: Patch works in both cases using old(civicrm/extern/ipn.php) and new(civicrm/payment/ipn/1) notification URL. |
CRM/Core/Payment/PayPalProIPN.php
Outdated
$input['original_contribution_id'] = $ids['contribution']; | ||
$input['contribution_recur_id'] = $ids['contributionRecur']; | ||
// We don't want to send out email receipts for repeat contributions. | ||
$input['is_email_receipt'] = FALSE; |
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.
this looks like a change in behaviour - and while I think many would prefer it I don't think a change to outgoing emails should be this PR as they need their own discussion
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.
Sure, I've removed that as it's not critical to this PR.
8d3af43
to
5c6e4a1
Compare
…eters for readability to match PayPalIPN
5c6e4a1
to
9f68fe6
Compare
@eileenmcnaughton @pradpnayak I've removed the is_email_receipt parameter as that's not critical to this PR. @pradpnayak Can you confirm if you are happy this should be merged now? |
I looked and the code looks sensible & within scope now. Am happy to merge when @pradpnayak is |
Good to merge!! Thanks @eileenmcnaughton and @mattwire |
@Stoob pinging you as I now you use Paypal std - am merging this but perhaps you could make a point of testing the rc that gets cut on the 1st of next month |
I've sent this email to the dev list
|
Overview
Currently you can setup recurring payments using the Paypal Standard processor, but after the first IPN is processed subsequent IPNs do not get processed because the IPN code does not fully implement code to do so and fails to identify the correct payment processor in CiviCRM if the "business" email does not match.
By replacing the call to completetransaction with one to repeattransaction we have working recurring IPNs for paypal standard.
See: https://lab.civicrm.org/dev/financial/issues/27
Before
Paypal Standard recurring IPNs do not work properly
After
Paypal Standard recurring IPNs work properly.
Technical Details
Switch to calling the internal function completetransaction to the API repeattransaction which is the "correct" thing to do.
Comments
This has been tested on a live site, and has been used with nz.co.fuzion.notificationlog to replay six months of IPNs that were received by CiviCRM but not acted on.