Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

pre-populate paypal form?


Guest

Recommended Posts

How can this be done upon checkout to save the customers some time and save some transactions? Transferring osc customer data to paypal form...

Link to comment
Share on other sites

here is the paypal module from catalogincludesmodulespaymentpaypal.php

 

 

 

<?php

/*

$Id: paypal.php,v 1.29 2002/08/13 16:00:42 dgw_ Exp $

 

The Exchange Project - Community Made Shopping!

http://www.theexchangeproject.org

 

Copyright © 2000,2001 The Exchange Project

 

Released under the GNU General Public License

*/

 

class paypal {

var $code, $title, $description, $enabled;

 

// class constructor

function paypal() {

$this->code = 'paypal';

$this->title = MODULE_PAYMENT_PAYPAL_TEXT_TITLE;

$this->description = MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;

$this->enabled = MODULE_PAYMENT_PAYPAL_STATUS;

}

 

// class methods

function javascript_validation() {

return false;

}

 

function selection() {

return false;

}

 

function pre_confirmation_check() {

return false;

}

 

function confirmation() {

global $checkout_form_action;

 

$checkout_form_action = 'https://secure.paypal.com/cgi-bin/webscr';

}

 

function process_button() {

global $order, $currencies;

 

$process_button_string = tep_draw_hidden_field('cmd', '_xclick') .

tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .

tep_draw_hidden_field('item_name', STORE_NAME) .

tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->currencies['USD']['value'], 2)) .

tep_draw_hidden_field('shipping', number_format($order->info['shipping_cost'] * $currencies->get_value('USD'), 2)) .

tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

 

return $process_button_string;

}

 

function before_process() {

return false;

}

 

function after_process() {

return false;

}

 

function output_error() {

return false;

}

 

function check() {

if (!isset($this->_check)) {

$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_STATUS'");

$this->_check = tep_db_num_rows($check_query);

}

return $this->_check;

}

 

function install() {

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Allow PayPal', 'MODULE_PAYMENT_PAYPAL_STATUS', '1', 'Do you want to accept PayPal payments?', '6', '3', now())");

tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('PayPal ID', 'MODULE_PAYMENT_PAYPAL_ID', '[email protected]', 'Your buisness ID at PayPal. Usually the email address you signed up with. You can create a free PayPal account at http://www.paypal.com.'., '6', '4', now())");

}

 

function remove() {

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_STATUS'");

tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_ID'");

}

 

function keys() {

$keys = array('MODULE_PAYMENT_PAYPAL_STATUS', 'MODULE_PAYMENT_PAYPAL_ID');

 

return $keys;

}

}

?>

 

 

 

Patrick, you guys have a clue how to stick your fields in with the oscommerce format?

Link to comment
Share on other sites

function process_button() {

     global $order, $currencies;



     $process_button_string = tep_draw_hidden_field('cmd', '_xclick') .

                              tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .

                              tep_draw_hidden_field('item_name', STORE_NAME) .

                              tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->currencies['USD']['value'], 2)) .

                              tep_draw_hidden_field('shipping', number_format($order->info['shipping_cost'] * $currencies->get_value('USD'), 2)) .

                              tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

                              tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));



     return $process_button_string;

   }

 

That is the function you want to edit.

I don't know if this will work but try adding this in,

 

add after "$process_button_string = tep_draw_hidden_field('cmd', '_xclick') ."

 

tep_draw_hidden_field("redirect_cmd", "_xclick") .

 

then for each piece of membership info.. (look at above url)

 

tep_draw_hidden_field("first_name", $firstname) .

tep_draw_hidden_field("last_name", $lastname) .

 

i.e. modified function

function process_button() {

     global $order, $currencies;



     $process_button_string = tep_draw_hidden_field('cmd', '_xclick') .

     tep_draw_hidden_field("redirect_cmd", "_xclick") .

     tep_draw_hidden_field("first_name", $firstname) .

     tep_draw_hidden_field("last_name", $lastname) .

                              tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .

                              tep_draw_hidden_field('item_name', STORE_NAME) .

                              tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->currencies['USD']['value'], 2)) .

                              tep_draw_hidden_field('shipping', number_format($order->info['shipping_cost'] * $currencies->get_value('USD'), 2)) .

                              tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

                              tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));



     return $process_button_string;

   }

 

You can probably just test that quickly to see if goings to work.

And you will have to get the customer information and shipping information from somewhere too..

This would be another good contribution :)

Link to comment
Share on other sites

Ok, this is the problem, the paypal checkout for osc first goes to a paypal login page with checkout total that asks if the client is already a paypal user or if he/she needs to create a paypal account. So no user information is sent to that page at all, just the checkout total.

 

ppcheck1.gif

 

 

then the user either logs or creates a new account.... this second page is where the fields need to be added from osc.

 

ppcheck2.gif

 

I cant figure out if that is possible or not.

Link to comment
Share on other sites

ok here's a start to a modified function

function process_button() {

     global $order, $currencies, $customer_id;

 $result = tep_db_query("Select customers_firstname, customers_lastname from customers where customers_id = '$customer_id'");

 $line = mysql_fetch_assoc($result);

 $first_name = $line['customers_firstname'];

 $last_name = $line['customers_lastname'];



     $process_button_string = tep_draw_hidden_field('cmd', '_ext-enter') .

   tep_draw_hidden_field("redirect_cmd", "_xclick") . 

   tep_draw_hidden_field("first_name", $first_name) . 

   tep_draw_hidden_field("last_name", $last_name) . 

   tep_draw_hidden_field("city", $order->customer['city']) . 

   tep_draw_hidden_field("state", $order->customer['state']) . 

   tep_draw_hidden_field("zip", $order->customer['postcode']) . 

               tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .

      tep_draw_hidden_field('item_name', STORE_NAME) .

     tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->currencies['USD']['value'], 2)) .

     tep_draw_hidden_field('shipping', number_format($order->info['shipping_cost'] * $currencies->get_value('USD'), 2)) .

     tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .

     tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));



     return $process_button_string;

   }

 

Use Patricks link above to find the rest of values you need to add.

I'm under the hammer here to meet some deadlines so I can't do it all at the moment. THis worked for me tho, it pre populated a few fields.

 

Take now, the phone number requires the 3 parts separately. So unless you collect those parts separately on your site this could be tricky.

i.e. (123) 1234 1234

perhaps you could guess? take numbers working backwards or something...

Link to comment
Share on other sites

Reap,

 

By far, the easiest thing to do would be to install Pablo's "PayPal IPN" contribution. It already includes the code to pre-populate the fields, and you are going to need it anyway, trust me.

-------------------------------------------------------------------------------------------------------------------------

NOTE: As of Oct 2006, I'm not as active in this forum as I used to be, but I still work with osC quite a bit.

If you have a question about any of my posts here, your best bet is to contact me though either Email or PM in my profile, and I'll be happy to help.

Link to comment
Share on other sites

  • 9 months later...
  • 2 months later...

can this code be added to the join function for a membership to a cart? would really be interested to know how to make a paid membership since I am a theme author and only want to allow paid memberships to access my enhancements off my server.

 

Kel

www.kelsthemes.com

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...