PayPal Advanced – 2 edge case errors with possible solutions
-
I noted I had some failed transactions in woocommerce which were successful in PayPal, obviously concerning. I found the cause and possible solution, and while looking another possible problem with solution.
Problem 1: [RESPMSG] => Approved: 10431-Item amount is invalid.
This response was being sent by Paypal as relay response(?), not silent. The [RESULT] is 0 (success) and the payment is successful in paypal, but in woocommerce this does not trigger pending->processing. The invalid amount is being caused by a creative use of negative fees, which may or may not be a good idea.
Proposed solution:
file:wc-gateway-paypal-advanced-angelleye.php, line ~412//handle the successful transaction switch ($_REQUEST['RESULT']) { case 0 : //stephen //handle exceptional cases if ($_REQUEST['RESPMSG'] == 'Approved' || $_REQUEST['RESPMSG'] == 'Verified') { $this->success_handler($order, $order_id, $silent_post); } else if ( substr($_REQUEST['RESPMSG'],0,9) == 'Approved:') { $order->add_order_note( __('Payment warning via PayPal Advanced.', 'paypal-for-woocommerce') . ' ' . $_POST['RESPMSG']); $this->success_handler($order, $order_id, $silent_post); } else if ($_REQUEST['RESPMSG'] == 'Declined') { $this->decline_handler($order, $order_id, $silent_post); } else { $this->error_handler($order, $order_id, $silent_post); } break; //.stephen /* old code removed by stephen //handle exceptional cases if ($_REQUEST['RESPMSG'] == 'Approved' || $_REQUEST['RESPMSG'] == 'Verified') { $this->success_handler($order, $order_id, $silent_post); } else if ($_REQUEST['RESPMSG'] == 'Declined') { $this->decline_handler($order, $order_id, $silent_post); } else { $this->error_handler($order, $order_id, $silent_post); } break; */
This detects “Approved:” and treated like “Approved” with the addition of adding an oder note.
Problem 2 – [RESPMSG] => Failed AVS Check.
While testing the above I noticed my silent post for the same transaction was failing [RESULT] => 112. I was careless with my address I guess. If a transaction is declined the order status is changed to failed and a note is added. Because this was an unspecified error no note is added to the order which to me seems like an oversite as I would like to know if Paypal sends this sort of information.
I suggest adding notes for error to the order:
file:wc-gateway-paypal-advanced-angelleye.php, line ~300private function error_handler($order, $order_id, $silent_post) { //stephen add $order->add_order_note( __('Payment failed via PayPal Advanced because of.', 'paypal-for-woocommerce') . ' ' . $_POST['RESPMSG']); //.stephen
Consideration: I am not very familiar with Paypal process or practices. These changes might have ramifications I do not appreciate.
- The topic ‘PayPal Advanced – 2 edge case errors with possible solutions’ is closed to new replies.