PayPal Express recurring payment causes warning messages
I created a contribution page using the PayPal Express payment processor. It works ok, but when I click on th "Make Contribution" button and get to the "Thank you" page, a lot of warning messages are displayed about unset variables.
In order to get rid of these messages, I had to edit a number of files. The first was CRM/Contribute/BAO/Contribution/Utils.php:
198,199c198,199
< if ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution',
< 'status_id', 'Pending') && $payment->isSendReceiptForPending()) {
---
> if ( (!empty($result['payment_status_id'])) && ($result['payment_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution',
> 'status_id', 'Pending') && $payment->isSendReceiptForPending()) ) {
The next file was CRM/Core/Payment/PayPalProIPN.php:
569c568
< if ( (!empty($input['trxn_id'])) && ($this->transactionExists($input['trxn_id'])) ) {
---
> if ($this->transactionExists($input['trxn_id'])) {
The final file was CRM/Core/Payment/PayPalImpl.php:
382,384c382,384
< $args['invnum'] = $params['invoiceID'];
< $args['returnURL'] = $params['returnURL'];
< $args['cancelURL'] = $params['cancelURL'];
---
> if (!empty($params['invoiceID'])) $args['invnum'] = $params['invoiceID'];
> if (!empty($params['returnURL'])) $args['returnURL'] = $params['returnURL'];
> if (!empty($params['cancelURL'])) $args['cancelURL'] = $params['cancelURL'];
391c391
< $args['totalbillingcycles'] = $params['installments'];
---
> if (!empty($params['installments'])) $args['totalbillingcycles'] = $params['installments'];
410,418c410,418
< $params['trxn_id'] = $result['transactionid'];
< $params['gross_amount'] = $result['amt'];
< $params['fee_amount'] = $result['feeamt'];
< $params['net_amount'] = $result['settleamt'];
< if ($params['net_amount'] == 0 && $params['fee_amount'] != 0) {
< $params['net_amount'] = number_format(($params['gross_amount'] - $params['fee_amount']), 2);
< }
< $params['payment_status'] = $result['paymentstatus'];
< $params['pending_reason'] = $result['pendingreason'];
---
> // $params['trxn_id'] = $result['transactionid'];
> // $params['gross_amount'] = $result['amt'];
> // $params['fee_amount'] = $result['feeamt'];
> // $params['net_amount'] = $result['settleamt'];
> // if ($params['net_amount'] == 0 && $params['fee_amount'] != 0) {
> // $params['net_amount'] = number_format(($params['gross_amount'] - $params['fee_amount']), 2);
> // }
> // $params['payment_status'] = $result['paymentstatus'];
> // $params['pending_reason'] = $result['pendingreason'];
Note that the last set I commented out because, as far as I could tell from the PayPal documentation, those parameters are never returned from that particular call.
Hopefully I haven't broken anything.
Regards,
Carl