Further update: I now get paypal express checkout payments and full and partial refunds to show up correctly as SO payments. Refunds are negative value payments and not refunds, but I'll live with this for now.
What I did was take Frank's code snippet (above) to modify cc_line_item in super_order.php. During the checkout process, this adds a so_payments record with info from the paypal transaction. I also modified order.php as indicated above so that this would get called during checkout.
Next I added a function to modules/payment/paypal/paypal_functions.php:
Code:
function ipn_create_so_payments_array($new_order_id, $txn_type) {
$sql_data_array = array('orders_id' => $new_order_id,
'payment_number' => $_POST['txn_id'],
'payment_name' => $_POST['last_name'],
'payment_amount' => $_POST['mc_gross'],
'payment_type' => $txn_type,
'date_posted' => datetime_to_sql_format($_POST['payment_date']),
);
return $sql_data_array;
}
Then, in ipn_main_handler.php, I inserted this for txn_type parent. Starting line 279:
Code:
if ($txn_type == 'parent') {
$sql_data_array = ipn_create_order_array($ordersID, $txn_type);
zen_db_perform(TABLE_PAYPAL, $sql_data_array);
// put refund info into SO
require(DIR_WS_CLASSES . 'super_order.php');
$sql_data_array = ipn_create_so_payments_array($ordersID, $txn_type);
zen_db_perform(TABLE_SO_PAYMENTS, $sql_data_array);
} else {
This probably still isn't complete, I've only tested a couple of transactions, but I've seen many asking for this feature and I hope it helps some. I'm sure I could have done this more completely or more consistently - feedback welcome!
Bookmarks