Partial progress - I now have paypal payments showing up on the order. In addition to the code that BlindSide provided for cc_line_item (quoted below), I needed to modify includes/classes/order.php to call the function:
if (zen_not_null($this->info['cc_type']) || zen_not_null($this->info['cc_owner']) || zen_not_null($this->info['cc_number']) || $this->info['payment_module_code'] == 'paypalwpp') {
Works great - now when an order is placed with paypal, the amount from paypal[mc_gross] is applied as a payment.
However, while the so_payments[orders_id] and [payment_amount] are filled in, the [payment_name] and [payment_number] are not. Don't know why.....
Also, this is done at order creation. I think if this were done at report generation instead, you could pick up multiple paypal payments, paypal refunds, and maybe even current status of e-checks (haven't had much experience here).
Other than that- if any other hackers are making progress here, I'd love to know.
Frank - love the SO work you've done - it's really helped me out!
Thanks,
Carl
BlindSide:
Admin > Localization > Payment Types
Like wickedclown said, I have code to automate PayPal payments made at checkout for the next version. If you're feeling adventurous, here's the code for the modified function. Just replace the entire function as it exists in [catalog]/includes/class/super_order.php...
function cc_line_item() {
global $db;
// first we look for credit card payments
$cc_data = $db->Execute("select cc_type, cc_owner, cc_number, cc_expires, cc_cvv, date_purchased, order_total
from " . TABLE_ORDERS . " where orders_id = '" . $this->oID . "' limit 1");
if ($cc_data->RecordCount() ) {
// collect payment types from the DB
$payment_data = $db->Execute("select * from " . TABLE_SO_PAYMENT_TYPES . "
where language_id = " . $_SESSION['languages_id']);
$cc_type_key = array();
while (!$payment_data->EOF) {
$cc_type_key[$payment_data->fields['payment_type_full']] = $payment_data->fields['payment_type_code'];
$payment_data->MoveNext();
}
// convert CC name to match shorthand type in SO payment system
// the name used at checkout must match name entered into Admin > Localization > Payment Types!
$payment_type = $cc_type_key[$cc_data->fields['cc_type']];
$new_cc_payment = array('orders_id' => $this->oID,
'payment_number' => $cc_data->fields['cc_number'],
'payment_name' => $cc_data->fields['cc_owner'],
'payment_amount' => $cc_data->fields['order_total'],
'payment_type' => $payment_type,
'date_posted' => 'now()',
'last_modified' => 'now()');
zen_db_perform(TABLE_SO_PAYMENTS, $new_cc_payment);
}
// now look for PayPal data
$pp_data = $db->Execute("select * from " . TABLE_PAYPAL . " where zen_order_id = " . $this->oID);
if ($pp_data->RecordCount() ) {
$new_pp_payment = array();
while (!$pp_data->EOF) {
$name = $pp_data->fields['first_name'] . ' ' . $pp_data->fields['last_name'];
$new_pp_payment[] = array('orders_id' => $this->oID,
'payment_number' => $pp_data->fields['txn_id'],
'payment_name' => $name,
'payment_amount' => $pp_data->fields['mc_gross'],
'payment_type' => 'PP',
'date_posted' => 'now()',
'last_modified' => 'now()');
$pp_data->MoveNext();
}
foreach ($new_pp_payment as $key => $payment) {
zen_db_perform(TABLE_SO_PAYMENTS, $payment);
}
}
}
> I'd also like to hear from those of you who use PayPal extensively (I don't at all). What other stuff can I do here to make this more useful?