Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

2Checkout V2 Instructions


Mark Russell

Recommended Posts

I got my cart to work with 2CO V2. I'm running a real old version of OSC - a snapshot from Sept 02, so I guess 2CO's claim that V2 will work with MS2 V2 is not true.

 

Here's what I did:

 

Change pm2checkout.php code. Note: newer versions of OSC will look different than this, but the overall concept of the script is the same. The 'for' loop is to capture multiple products in the cart, if needed. The reason to pass c_prod, c_name, etc is so 2CO can read those variables off the pass through URL, match them in the 2CO database and list the items on the order page when the customer hits the order page at 2CO. See the jpg down below. The 'demo' variable is to put the cart in/out of test mode. The id_type of '1' identifies that the product passed through has a an id assigned by me. A '2' would be for a system-assigned prod_id. Note: I'm passing through the product name in the description field also.

 

 function process_button() {
     global $HTTP_POST_VARS, $CardNumber, $order, $i; 

for ($i=0; $i<sizeof($order->products); $i++) {
 $process_button_string .= tep_draw_hidden_field('c_prod_' . $i, $order->products[$i]['model'] . ',' . $order->products[$i]['qty']);
 $process_button_string .= tep_draw_hidden_field('c_name_' . $i, $order->products[$i]['name']);
 $process_button_string .= tep_draw_hidden_field('c_price_' . $i, $order->products[$i]['price']);
 $process_button_string .= tep_draw_hidden_field('c_description_' . $i, $order->products[$i]['name']); // input name as the description
}

    $process_button_string .= tep_draw_hidden_field('x_login', MODULE_PAYMENT_2CHECKOUT_LOGIN) .
                              tep_draw_hidden_field('x_amount', number_format($order->info['total'], 2)) .
                              tep_draw_hidden_field('x_invoice_num', date('YmdHis')) .
                              tep_draw_hidden_field('demo', N) .
                              tep_draw_hidden_field('id_type', 1) .                               
                              tep_draw_hidden_field('x_first_name', $order->customer['firstname']) .
                              tep_draw_hidden_field('x_last_name', $order->customer['lastname']) .
                              tep_draw_hidden_field('x_address', $order->customer['street_address']) .
                              tep_draw_hidden_field('x_city', $order->customer['city']) .
                              tep_draw_hidden_field('x_state', $order->customer['state']) .
                              tep_draw_hidden_field('x_zip', $order->customer['postcode']) .
                              tep_draw_hidden_field('x_country', $order->customer['country']['title']) .
                              tep_draw_hidden_field('x_email', $order->customer['email_address']) .
                              tep_draw_hidden_field('x_phone', $order->customer['telephone']) .
                              tep_draw_hidden_field('x_ship_to_first_name', $order->delivery['firstname']) .
                              tep_draw_hidden_field('x_ship_to_last_name', $order->delivery['lastname']) .
                              tep_draw_hidden_field('x_ship_to_address', $order->delivery['street_address']) .
                              tep_draw_hidden_field('x_ship_to_city', $order->delivery['city']) .
                              tep_draw_hidden_field('x_ship_to_state', $order->delivery['state']) .
                              tep_draw_hidden_field('x_ship_to_zip', $order->delivery['postcode']) .
                              tep_draw_hidden_field('x_ship_to_country', $order->delivery['country']['title']) .
                              tep_draw_hidden_field('x_receipt_link_url', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'NONSSL')) .
                              tep_draw_hidden_field('x_email_merchant', MODULE_PAYMENT_2CHECKOUT_EMAIL_MERCHANT);

     return $process_button_string;
     
     }

 

Upload Product File - I used the contribution Easy Populate to download a complete tab-delimited .txt file. I then opened in Excel and escaped all the commas (,) with (\,). I also modified the file to meet 2COs file spec available here: https://www2.2checkout.com/2co/admin/product_upload. I then saved as a CSV and opened in Textpad. I removed the header column and added my 5-digit SID to the first line (commented out below) . The first couple of lines of the product file are below. Alex (arm1tage) wisely pointed out the following "I've learned the c_prod and associated variables have to be passed once in a LIVE transaction so they are entered into 2CO's database, before they show up in the cart details. So for those of you that do not see the itemized list, it is because you have not had a live sale of that item yet. One way around this is to upload your inventory in a .CSV file." That was critical for me because I was expecting the itemized products to show up on the 2CO order page upon the products being passed through in the URL. They don't. They have to already be in the 2CO database.

 

Product File:

MYSID

A-1044,Ivory Velvet Bow Clip,,2.99,,,1,Ivory Velvet Bow Clip

A-1005,Hair Accesory - Yellow Flower Hair Elastic,,3.99,,,1,Hair Accesory - Yellow Flower Hair Elastic

A-1005,Hair Accesory - Yellow Flower Hair Elastic,,3.99,,,1,Hair Accesory - Yellow Flower Hair Elastic

A-1013,Harlequin Headband,,4.99,,,1,Harlequin Headband

 

 

Test Mode - V2 does not work like V1 where you use the drop-down menu in the admin area to turn test mode on/off. You have to pass the variable 'Y' to indicate a test transaction.

 

Test Credit Card - use 597910143452349, any expiration date in the future, and 000 for the security code.

 

Pass Through URL - when you hit the Confirmation button on checkout_confirmation.php and hit the first page at 2CO, the pass through URL should be in the browser address bar. Mine looked like the following for the successful transaction. (I modified some of the variables.)

 

(Removed 'http://w' to prevent this from being a link)ww.2checkout.com/2co/buyer/purchase?TCOID=c393c06c94e930f050f18563b086b1?=&c_prod_0=S-6063,2&c_name_0=Girls socks - Light Blue and white stripes and flowers Size 6.5&c_price_0=2.9900&c_description_0=&c_prod_1=S-4013,1&c_name_1=White Sunflower Lace Cuffed Girls Socks Size 4 - 5.5&c_price_1=4.4900&c_description_1=&x_login=MYSID&x_amount=13.76&x_invoice_num=20050401084151&demo=Y&id_type=1&x_first_name=joe&x_last_name=schmo&x_address=377 Anywhere Dr &x_city=Somewhere&x_state=California&x_zip=90210&x_country=United States&[email protected]&x_phone=5555551212&x_ship_to_first_name=joe&x_ship_to_last_name=schmo&x_ship_to_address=377 Anywhere Dr &x_ship_to_city=Somewhere&x_ship_to_state=California&x_ship_to_zip=90210&x_ship_to_country=United States&x_receipt_link_url=http://www.mydomain.com/checkout_process.php&x_email_merchant=FALSE&x=43&y=19

 

I hope this helps.

 

Mark

 

checkout_page.jpg

Link to comment
Share on other sites

Great work Mark! Easy Populate is the best way to upload all your inventory to 2CO without buying it. Do you mind if I add your instructions to the next update?

 

One other thing, if you want to import the actual product description, here's is the code for that! This strips out HTML and only leaves line breaks. Descriptions under 255 chars go into the short desciprtion box. Anything longer goes into the long description.

 

replace

                $process_button_string .= tep_draw_hidden_field('c_description_' . $i, $order->products[$i]['name']); // not sure how to input the description here

 

with

                // format product description 
               $product_id = $order->products[$i]['id'];
               $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . $product_id . "' and language_id = '" . $languages_id . "'");
               $product_description = tep_db_fetch_array($product_query);
               $text = $product_description['products_description'];
               $text = strip_tags($text);
               $text = nl2br($text);
               $text = str_replace("<br />","<br>",$text);
               $process_button_string .= tep_draw_hidden_field('c_description_' . $i, $text);

Link to comment
Share on other sites

Product File:

MYSID

A-1044,Ivory Velvet Bow Clip,,2.99,,,1,Ivory Velvet Bow Clip

A-1005,Hair Accesory - Yellow Flower Hair Elastic,,3.99,,,1,Hair Accesory - Yellow Flower Hair Elastic

A-1005,Hair Accesory - Yellow Flower Hair Elastic,,3.99,,,1,Hair Accesory - Yellow Flower Hair Elastic

A-1013,Harlequin Headband,,4.99,,,1,Harlequin Headband

 

Thank you for all of your help with this, I have one question regarding the csv upload, 2Checkout included return URLs in their instructions as part of the requirements, but I see you don't have them here. Do you need to add the return URLs to the csv or is it okay to leave them out?

 

Thank you!

Lia

Edited by jeweltomes
Link to comment
Share on other sites

Lia,

 

Those fields are not required, so I decided in my case not to upload them with my products.

 

The Approved URL is the URL to redirect the buyer to when the purchase succeeds.

 

- I didn't enter this URL because 2CO already has my redirect URL to checkout_process.php. This redirect works and I didn't want to take the chance that entering the URL with products would screw something up.

 

The Pending URL is the URL to redirect the buyer to when the purchase cannot be immediately determined.

 

- I guess it would be good to redirect back to my shop if something went wrong in the checkout process, but again, I just wanted to get it to work. Also, if something happens during checkout that requires redirect back to my shop, I figure there's a good chance I'll lose the customer anyway. I may upload this URL in the future and point them back to checkout_confirmation. Maybe they'd try again...

 

Mark

Link to comment
Share on other sites

Why would we not redirect 2c0 back to checkout_success.php?

 

Why pm2checkout_process.php ?

 

If you redirect to "checkout_success" the OSC admin won't be update with your order, all the order need to pass to "ckeckout_process" to be updated in the OSC admin.

 

 

For the V2, using easypopulate is not easy, we need to make a lot of modification to update the file in 2Co..... bad luck, but all is good now.

Link to comment
Share on other sites

thanks !

 

I used my froogle contribution for setting up the 2co database and adjusted that file. A bit of work, but it is all there now.

 

What are the pros /cons on itemized cart or no itemized cart? I want to get it right so that 2co v2 accepts it. I dont care if I receive a receipt from 2co listing the items. On the same token, I dont want to have to go through updating my product list in 2co everytime I add an item - I have over 3000 items now. Which is the best way to go ?

Link to comment
Share on other sites

I used my froogle contribution for setting up the 2co database and adjusted that file.  A bit of work, but it is all there now.

 

uh oh. the froogle contribution takes the products_id and 2co is looking for the products_model..... what would be the best way of getting around this? Can I comment something out?

 

help please :blink:

Link to comment
Share on other sites

hold on, I thought that this new version of pm2checkout sent the cart details and inserted them into the database on the fly ?  Perhaps I dont have something set up correctly ?

 

Products do get inserted into the db on the fly. However, the first time a product is purchased and passed to 2CO (i.e. it isn't already in the 2CO db) that product will not show up as an itemized entry on the order page for that purchase only. Subsequent purchases of that same product will be itemized on the order page.

 

Uploading a full product file to start ensures that all products get itemized on the order page from the start. That's all...

 

Mark

Link to comment
Share on other sites

ok so what i have seen here, we have to setup a DB on 2CO side, so the Products will Show up on the 2CO Order Page am i right? And we have to have Force Cookies enable, if we have Shared SSL just disable it in the Config file? But setting up the Product Database for 2CO how you do this correctly?

 

Sorry, i freak out when they upgraded and just been crazy about this update. Sorry if i have been annoy.

Link to comment
Share on other sites

Products do get inserted into the db on the fly.    However, the first time a product is purchased and passed to 2CO (i.e. it isn't already in the 2CO db) that product will not show up as an itemized entry on the order page for that purchase only.  Subsequent purchases of that same product will be itemized on the order page.

 

Uploading a full product file to start ensures that all products get itemized on the order page from the start.  That's all...

 

Mark

 

Hey mark - what if i had v1 of pm2checkout installed and i updated my pm2checkout.php file with the new one? Would this work? I tried it and still got the error, but now im thinking maybe it was because it was the first purchase...

 

I really hope i can make a few additions to my pm2checkout.php file and call it a day...

any thoughts?

Link to comment
Share on other sites

  • 2 weeks later...

Hi Guys.

 

Isn't it wonderfull to be able to worry about the detail with 2CO now after having to operate the most crude workarounds for ages!

 

Can I just check my understanding on something Mark Russell wrote on 2 April.

 

I have implemented the hack he detailed and my order details screen looks pretty much like his screen grab - the purchases are nicely detailed under "product name".

 

However, as with mark's screen grab, my "purchase item description" directly above that in the screen grab is typically something like "Cart 20050416170359".

 

This is also the description provided later in the 2CO sales receipt emailed to the customer (and copied to me of course).

 

Here's the question:

Is this what that the pm2checkout/easypopulate combination is supposed to achieve or is the 2CO receipt expected to have a proper description of the goods purchased?

 

Sorry to be thick. But I want to check before i waste any more time trying to fix a problem that does not exist.

 

BTW - I do not bother with test mode any more. I just give myself a 100% refund on my "test" purchases.

 

Cheers

 

Tim

Link to comment
Share on other sites

Here's the question:

Is this what that the pm2checkout/easypopulate combination is supposed to achieve or is the 2CO receipt expected to have a proper description of the goods purchased?

 

Tim,

 

The easypolpulate step gets you the Product Detail section with the itemized products.

 

Hope that answers your question.

 

Mark

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...