Jump to content

derektimbrell

Members
  • Content count

    5
  • Joined

  • Last visited

Profile Information

  • Real Name
    Derek Timbrell
  1. derektimbrell

    Store title instead of item on Paypal page

    I've made a change in my paypal_standard.php so that my Paypal Website Standard module now passes through the item details rather than the store name and order information that goes though in the released version. It also passes the product model number and the name and value of the first two product attributes if they've been used. As far as I'm aware Paypal only supports two optional attributes. To make this work, and to keep the shipping, tax and totals that Paypal displays in line with what was actually ordered, I've had to do a slight fiddle when passing the tax and shipping through. The tax and shipping for the entire order are passed through with the first item; the tax and shipping for all remaining items are set to zero. That was the only way I could find to make Paypal display the order totals correctly. Here's the change (to file includes/modules/payment/paypal_standard.php ) Find this $parameters = array('cmd' => '_xclick', 'item_name' => STORE_NAME, 'shipping' => $this->format_raw($order->info['shipping_cost']), 'tax' => $this->format_raw($order->info['tax']), 'business' => MODULE_PAYMENT_PAYPAL_STANDARD_ID, 'amount' => $this->format_raw($order->info['total'] - $order->info['shipping_cost'] - $order->info['tax']), 'currency_code' => $currency, 'invoice' => substr($cart_PayPal_Standard_ID, strpos($cart_PayPal_Standard_ID, '-')+1), 'custom' => $customer_id, 'no_note' => '1', 'notify_url' => tep_href_link('ext/modules/payment/paypal/standard_ipn.php', '', 'SSL', false, false), 'return' => tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'), 'cancel_return' => tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'), 'bn' => 'osCommerce22_Default_ST', 'paymentaction' => ((MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTION_METHOD == 'Sale') ? 'sale' : 'authorization')); if (is_numeric($sendto) && ($sendto > 0)) { and replace it with $parameters = array('cmd' => '_cart', 'upload' => '1', 'business' => MODULE_PAYMENT_PAYPAL_STANDARD_ID, 'currency_code' => $currency, 'invoice' => substr($cart_PayPal_Standard_ID, strpos($cart_PayPal_Standard_ID, '-')+1), 'custom' => $customer_id, 'no_note' => '1', 'notify_url' => tep_href_link('ext/modules/payment/paypal/standard_ipn.php', '', 'SSL', false, false), 'return' => tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL'), 'cancel_return' => tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'), 'bn' => 'osCommerce22_Default_ST', 'paymentaction' => ((MODULE_PAYMENT_PAYPAL_STANDARD_TRANSACTION_METHOD == 'Sale') ? 'sale' : 'authorization')); for ($i=0; $i<sizeof($order->products); $i++) { $j = $i+1; $parameters['item_name_' . $j] = $order->products[$i]['name']; $parameters['item_number_' . $j] = $order->products[$i]['model']; $parameters['amount_' . $j] = $this->format_raw($order->products[$i]['final_price']); $parameters['quantity_' . $j] = $order->products[$i]['qty']; $parameters['on0_' . $j] = $order->products[$i]['attributes'][0]['option']; $parameters['os0_' . $j] = $order->products[$i]['attributes'][0]['value']; $parameters['on1_' . $j] = $order->products[$i]['attributes'][1]['option']; $parameters['os1_' . $j] = $order->products[$i]['attributes'][1]['value']; // the total shipping and tax values for the order are output against the // first product, and tax and shipping are set to zero for all subsequent // products. // the order tax applied to the first product has to be divided by the // quantity for that product because paypal treats this as the tax for // 1 of that product and will multiply it by the quantity. if ( $i == 0 ) { $parameters['shipping_' . $j] = $this->format_raw($order->info['shipping_cost']); $parameters['tax_' . $j] = $this->format_raw($order->info['tax']) / $order->products[$i]['qty']; } else { $parameters['shipping_' . $j] = 0; $parameters['tax_' . $j] = 0; } } if (is_numeric($sendto) && ($sendto > 0)) { While this works i.e. it passes the item details rather than the store name and order details, I'm not sure whether there's anything I've done that makes it any less secure or more hackable than it was before. Any thoughts on that would be appreciated. Anyone wanting to look at the changes in detail might also find this useful : https://www.paypal.com/IntegrationCenter/ic...-reference.html Thanks.
×