Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

2CheckOut integration problem


everyth5

Recommended Posts

Hello all. Hope everyone is having a great summer :D

 

I have been trying to integrate 2CheckOut with my site for about 2 weeks now and just cannot figure it out!

 

I have signed up with 2CO because they said that they have EASY PLUG N PLAY coding but that is NOT the case. They give SOME coding changes that must be done but they don't say WHERE! Below is the information they gave me. What really gets me is the red wording!

 

 

Payment Routine Specifications Using A Shopping Cart

This page covers the specifications for the payment

routine when you use a shopping cart. It is provided for clients that

want to use their own program(s) and believe they can code the procedures.

 

 

If your shopping cart used Authorize.net parameters please, Click Here

Payment Routine

https://www.2checkout.com/2co/buyer/purchase

 

Parameters

sid - your 2checkout vendor account number

total - the total amount to be billed, in decimal form,

with no currency symbol.

cart_order_id - a unique order id from your program.

c_prod or c_prod_[:digit] - assigned_product_id of product in

the 2checkout system. This id may also contain an optional

','( ASCII comma ) followed by an integer which will represent the quantity.

id_type - Indicates type of id in c_prod. It must be either be a

1 for a vendor assigned vendor_product_id or a 2 for a

system assigned assigned_product_id.

Example Link

Here is an example of the string that your link should contain: https://www.2checkout.com/2co/buyer/purchas...t&id_type=1

Passed back parameters

The following parameters will be passed back to your routine :

 

order_number - 2Checkout.com order number

card_holder_name - Card holder's name

street_address - Card holder's address

city - Card holder's city

state - Card holder's state

zip - Card holder's zip

country - Card holder's country

email - Card holder's email

phone - Card holder's phone

cart_order_id - Your cart ID number passed in.

cart_id - Your cart ID number passed in.

credit_card_processed - Y if successful, K if waiting for approval

total - Total purchase amount.

ship_name - Shipping information

ship_street_address - Shipping information

ship_city - Shipping information

ship_state - Shipping information

ship_zip - Shipping information

ship_country - Shipping information

To recieve these parameters, you must specify where they are sent.

You can do so here

Confirmation Email

Once the credit card transaction is approved both you and the buyer will recieve a confirmation email.

The email must contain the following text:

 

 

Distributed By:

Everything Asian ( www.everything-asian.com )

2Checkout.com ( 2CO ) and Everything Asian thank you for your business.

 

2Checkout.com Inc

1785 O'Brien Road

Columbus, Ohio 43228

Contact us: http://www.2checkout.com/contactus.htm

 

 

Optional parameters

sh_cost - Shipping and handling cost, if any in your current currency.

c_name or c_name_[:digit] - Required for new product creation. Name of new product limited to 128 characters.

c_description or c_description_[:digit] - Required for new product creation.

Short description of the product, limited to 255 characters.

Longer description will be stored in the 2Co product database

as long description, and will not show up on checkout pages.

c_price or c_price_[:digit] - Required for new product creation.

Price of the product in your current currency.

Numbers and decimal points only. Maximum value 999999.99

c_tangible or c_tangible_[:digit] - Y or y indicates as tangible or physical product

N or n indicates an e-good or a service.

 

 

Now do I have to add a new contribution to my existing code? What one would be best?

 

Hope someone can help me with the above code changes that 2CO says has to be done.

 

Thanks in advance.

Link to comment
Share on other sites

This also adds to that:

 

NEW CART PURCHASE PARAMETERS

 

It has become necessary for 2Co to know the specific product that is being sold at the time of sale and for that product's description to be stored in our database for reference. This change is required both by 2CO and by our banking partners to better mitigate risk and to monitor items being sold.Because of this requirement, we are asking cart makers and/or users to make changes to their cart or programs so that additional information about the items being sold is passed to 2Co.

 

It is very important to note that:

 

1. All previous parameters remain supported and should continue to be passed in ( 2Co , Authorize.net ) ,

2. The parameter total ( or the authorize.net parameter : x_amount ) passed in for the order will continue to be the amount billed for the sale,

3. The paramaters cart_order_id and sid ( or the authorize.net parameters : x_invoice_num and x_login ) are still manditory with this parameter set.

 

 

 

Teal parameters are required to identify cart products being purchased and should be supplied ASAP.

 

For some clients it may make sense to create 1 or multiple generic products in the 2Co db, like "Premium Hosting", "Super Saver Hosting" and pass in a total for the sale as generated on their site. If this option works for you please make the product name reasonably descriptive, (i.e. "website design services" would be a good description, "web services" a poor one for the same item ).

 

Blue parameters are those required for product creation to take place at the time of sale if the product does not already exist in the 2Co system. These parameters are intended for carts that retain no product database or as a transition method of populating the 2Co database. Although it is desirable to receive as many parameters as possible with the purchase the option of creating products on the fly should only be used when no other options exist.

 

 

REQUIRED PARAMETERS

 

* c_prod or c_prod_[:digit] : This parameter will contain either the assigned_product_id given to the product upon creation in the 2CO system or a vendor specified id. It may, optionally, also contain the id followed by a ?,? ( ASCII comma ) followed by an integer which will represent the quantity. This parameter should not be autogenerated with each individual sale but should be tied to a specific product. The c_prod value should match whatever external vendor id is recorded in the 2Co system. The external vendor id maybe a cart assigned product id or the vendors own internal product id as long as the value matches the value stored in the 2Co system.

o Examples of valid values:

+ 1

+ my_product_17

+ product_5,3

 

* id_type This parameter will contain an integer value representing the type or classification of the ids used in the c_prod parameter(s). This value will apply universally per transaction. That is to say c_prod parameters must contain only assigned_product_id values or only vendor_product_id values. Current valid values for this parameter are defined as follows.

o 1 is defined as vendor_product_id

o 2 is defined as assigned_product_id

o 3 ? 0 are reserved for future use.

 

 

OPTIONAL PARAMETERS

 

* sh_cost (optional) : This parameter will contain shipping and handling cost, if any. The sh_cost parameter is completely optional. This parameter has the same format rules as the parameter containing the total (total or x_amount) that you are currently using. This value received is assumed to be in the selected currency of your 2CO account.

 

o Examples of valid values: 0.50, 5.00, 10

 

* c_name or c_name_[:digit] : This parameter is required for new product creation. The value of this parameter should contain the name of the product to be created. It is limited to 128 characters including spaces and punctuation. If the value is too long it will be cut off at 128 characters.

 

 

* c_description or c_description_[:digit] : This parameter is required for new product creation. The value of this parameter should contain a short description of the product to be sold. It is limited to 255 characters including spaces and punctuation. If the value is too long this value will be stored as the long description instead. The long description will not show on the checkout pages but it will be saved in the 2Co product database.

 

 

* c_price or c_price_[:digit] : This parameter is required for new product creation. This value should reflect the price of the product in your 2CO account selected currency. This parameter has the follow format restrictions

 

 

 

o Numbers and decimal point only.

o Max value: 999,999.99

 

 

* c_tangible or c_tangible_[:digit] ( optional ) : This parameter is optional. If you do not provide a value for it a default value of Y will be used. This field indicates if the product is a physical product or an e-good/service. This parameter has the following format restrictions:

 

 

 

o Valid values: y Y n N

Link to comment
Share on other sites

  • 2 weeks later...
You can start with pm2checkout contribution which is a basic inplementation of the 2checkout interface.

I found there are some problems with it (e.g. multi-currency), but it's the best I found yet.

 

Thanks. I have the pm2checkout contribution working but have run into some troubles with it.

 

I wasn't (and still am not) being sent back to my site after the order has been processed by 2checkout.

I have now installed the Order Logging contribution and it works like a dream.....I think.

 

It didn't cause any errors anyway, and there is a message in my Orders In Holding area reading:

 

Copies of Orders in Orders Holding...

In case your customer fails to return after Paypal or 2Checkout...

 

These orders may or may not have been completed! This module logs all orders before the customer is passed to payment processing. The process is seamless and doesn't interfere with the regular checkout process.

 

Please note that EVERY TIME a customer returns to the Order Confirmation Page, the order is stored in holding! Some orders may be saved several times! Use the last one of any such set of orders!

 

You can view or delete the orders with a click of the appropriate icon!

 

Now the problem still persists that if the customer doesn't get sent back to the checkout_success.php URL from 2CheckOut, then the items in the shopping cart do not get removed from there.

 

Does anyone have any idea what code changes must be done to make this work???

 

I have my 2Checkout set up like such in 2CheckOut:

 

Approved URL

Input a url for your customers to be sent to on a successful purchase.

http://everything-asian.com/checkout_success.php

Example: https://www.yoursite.com/yourscript.php

 

is the green URL correct? I checked it on my computer and it seemed to go there. but it still didn't get rid of the items in the shopping cart.

 

I am also not being sent back any of the information about the customer. If they make up an alias name for the account on my site, because I don't have SSL just yet and I DO let them know that in my information pages, then when they finish the order and I am sent a copy of the order, I don't have the correct information in order to send them the product. This causes a bit of a problem, right?

 

In 2CheckOut "Setting Up Your Site" area they say the following:

 

Passed back parameters The following parameters will be passed back to your routine:

Parameter Name Description

order_number 2Checkout.com order number

card_holder_name Card holder's name

street_address Card holder's address

city Card holder's city

state Card holder's state

zip Card holder's zip

country Card holder's country

email Card holder's email

phone Card holder's phone

credit_card_processed Y if successful, K if waiting for approval

total Total purchase amount

ship_name Shipping information

ship_street_address Shipping information

ship_city Shipping information

ship_state Shipping information

ship_zip Shipping information

ship_country Shipping information

product_id 2Checkout product ID for purchased items will append a number if more than one item. ex. product_id,product_id1,product_id2

quantity quantity of corresponding product will append a number if more than one item.ex. quantity,quantity1,quantity2

merchant_product_id your product ID for purchased items will append a number if more than one item.ex. merchant_product_id,merchant_product_id1,merchant_product_id2

product_description your description for purchased items will append a number if more than one item.ex. product_description,product_description1,product_description2

 

Confirmation E-mail

Once the credit card transaction is approved both you and the buyer will recieve a confirmation email.

 

Ideally, I would rather have all this information sent to my email and not back to the website until such time that I get SSL, but I am not sure if this is possible.

 

Hope someone smarter than I can figure this one out.

 

Thanks

 

Kelvin

Edited by everyth5
Link to comment
Share on other sites

Hi,

I am integrating the 2checkout module as well and I have noticed I few things in what is returned by 2checkout,

(I am in demo mode currently), and may be this could be where some of the integration problems might come from (not sure...)

 

- The first one is just for information. Although strange, I think is it not dangerous:

both $_POST['x_address'] and $_POST['x_Address'] are returned , with the same value...

 

- The second one bothers me more, because I would like to test the Hash thing, and I don't receive $_POST['x_MD5_Hash'] at all (My secret word is set). instead (I suppose it's instead...), I receive an empty $_POST['md']

 

It their documentation on line, they say

"We intentionally break the hash code for demo orders so that you can compare the hash we provide with what it should be to determine whether or not to provide the customer with your goods or not."

 

Returning another variable, and empty, is this what they call "break the hash code"?

Did someone else notice that?

(precision: of course this "md" is not something that I would have sent myself I that would then be passed back)

 

- The third one point could obviouly give some integration problems.

If you specify a return URL with GET parameters, those parameters will be POSTED back, so your processing script must take them in $_POST. (Is this the reason why there is an autosubmit form in the contribution?)

 

Thanks for any comment, and if someone could test the Hash thing in demo mode...

Link to comment
Share on other sites

...I forgot one:

$_POST['x_response_code'], which is use in before_process, is not returned (is there a relationship with the test mode?), so if you uncomment the before_process thing to use the Hash thing, don't use the x_response_code anyway.

Link to comment
Share on other sites

Hi,

I am integrating the 2checkout module as well and I have noticed I few things in what is returned by 2checkout,

(I am in demo mode currently), and may be this could be where some of the integration problems might come from (not sure...)

 

- The first one is just for information. Although strange, I think is it not dangerous:

both $_POST['x_address'] and $_POST['x_Address'] are returned , with the same value...

 

- The second one bothers me more, because I would like to test the Hash thing, and I don't receive $_POST['x_MD5_Hash'] at all (My secret word is set). instead (I suppose it's instead...), I receive an empty $_POST['md']

 

It their documentation on line, they say

"We intentionally break the hash code for demo orders so that you can compare the hash we provide with what it should be to determine whether or not to provide the customer with your goods or not."

 

Returning another variable, and empty, is this what they call "break the hash code"?

Did someone else notice that?

(precision: of course this "md" is not something that I would have sent myself I that would then be passed back)

 

- The third one point could obviouly give some integration problems.

If you specify a return URL with GET parameters, those parameters will be POSTED back, so your processing script must take them in $_POST. (Is this the reason why there is an autosubmit form in the contribution?)

 

Thanks for any comment, and if someone could test the Hash thing in demo mode...

 

Thanks for the reply P Lao. But because I am a fairly NEW at coding php,,.... you lost me after the first sentence. :blush:

 

Either way, I am not sure at all if I am even being returned anything from 2Checkout. I don't know how to check other than looking into my Admin to see if anything came through. Maybe you could fill me in, in more layman terms, how to check for this.

 

The variables that 2Checkout says that they will pass back are fine and dandy, but how and where in my code are they being sent back and received?????

 

I do know a little about programming but as I said, I am NEW to php, only been working with it for the past 2 months and still learning everyday.

 

Hope you can help me figure this one out.

 

Thanks again.

 

Kelvin

Link to comment
Share on other sites

Hi, sorry I was too technical...hard not to be sometimes...

 

- 2Checkout (and any payment 3rd party for osc) posts variables back to checkout_process.php.

 

Basically, checkout_process.php :

- calls the function before_process() of the module

- saves all the order data in the database

- calls the function after_process() of the module.

 

variables are posted, which means you get them by $_POST['variable_name' ] (or $HTTP_POST_VARS['variable_name']) for the old fashion style, still used in the "core" osc)]

 

if you want to know what is returned by 2Checkout you can add

 

print_r($_POST);

die;

 

in the begining of the function before_process() of the module, and then try again with 2CO (of course you need to get back to your site), and you will get the array of what is posted. (don't forget to remove that afterwards)

 

By the way, here is how you can enable the module 2CO to work with multicurrency:

 

The reason why it doesn't work with multicurrency is just that x_amount is always interpreted in USD by 2Checkout, and they convert to the currency specified in tco_currency (from which documentation does this one come from?? if someone knows....)

for example, today if you sent for x_amount, tco_currency 1,39, USD you will get 1,39 USD on the payment page ( normal...)

if you sent 1,39, EUR you will get 1,13 EUR because 2CO converts 1,39 USD in EUR

and if you senf 1,39, GBP you will get 0,78 GBP because 2CO converts 1,39 USD in GBP

 

so to make it work multi currency, you just have to convert x_amount in USD before sending the POST

 

for that you can add this little function that does some currency conversion in /includes/classes/currencies.php

 

function convert($price, $codefrom, $codeto) {

return $price*$this->currencies[$codeto]['value']/$this->currencies[$codefrom]['value'];

}

 

and replace

 

$cOrderTotal = $order->info['total']

 

by

 

$cOrderTotal = currencies->convert($order->info['total'],DEFAULT_CURRENCY,'USD')

 

in the module

 

Don't forget in this case that 2CO applies exchange fees, so except for USD, the price displayed on their payment page will always be a little bit higher than what is shown by the order total in osc...

 

 

 

 

Thanks for the reply P Lao. But because I am a fairly NEW at coding php,,.... you lost me after the first sentence. :blush:

 

Either way, I am not sure at all if I am even being returned anything from 2Checkout. I don't know how to check other than looking into my Admin to see if anything came through. Maybe you could fill me in, in more layman terms, how to check for this.

 

The variables that 2Checkout says that they will pass back are fine and dandy, but how and where in my code are they being sent back and received?????

 

I do know a little about programming but as I said, I am NEW to php, only been working with it for the past 2 months and still learning everyday.

 

Hope you can help me figure this one out.

 

Thanks again.

 

Kelvin

Link to comment
Share on other sites

a little correction, for the multicurrency thing:

 

I think that 2CO might (Their documentation is a little bit everywhere so I am not 100% sure) assume x_amount to be in the selected currency of your 2CO account.

 

so If your 2CO currency is not USD, instead of

 

$cOrderTotal = currencies->convert($order->info['total'],DEFAULT_CURRENCY,'USD')

 

you might need to write

 

$cOrderTotal = currencies->convert($order->info['total'],DEFAULT_CURRENCY,the currency selected in 2CO)

 

 

 

and a comment.

 

2CO has 3 parameter sets for their interface:

- the "Plug and play"

-the standard

- the authorized.net compliant set: the one with many variables beginning by x_...

 

The one used by the module is the 3rd one.

The one in your post is the first one.

But those variables sets can not be mixed, so I you try things, use the 3rd one...

If in your code you used variables of the 1st set in the module, this won't work

Link to comment
Share on other sites

Thanks P Lao:

 

I got my 2checkout working. It finally passed back all the information to my admin section and sent out the emails as it should. At least it did this ONCE!!!!

 

I tried it another time and it didn't work. It went through the entire process and when I went to confirm on the last page of 2checkout, it sent me back to my site alright......... back to the checkout_confirmation site. It looked as though the customer had not even made the purchase. So maybe the customer would try again and get billed a second time for the same item.

 

I have sent in a ticket to 2checkout to see what they think but I don't know.

 

Any ideas???

 

Thanks

 

Kelvin

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...