Web Hosting Talk







View Full Version : 2checkout question -- passback variables


gargonzo
02-07-2002, 10:11 PM
hiya,

quick question about passback variables...

well, basically i was wanting to grab the variables (somehow) and put them into a form for the user, to simplifiy for the end user so that they do not have to retype the infor supplied for the CC processing.. name, etc.

can someone give me an exampe of how they are using this? to populate a form?

I do not have a db setup to capture this info..

would it be like:
<input type="textfield" name="variable_passback" value="">

thanks in advance.. some example code would be the best :p

regards
garz

jffmrk
02-07-2002, 10:45 PM
Here is the list of variables:
http://www.2checkout.com/cart_specs.htm

And you could use cgi, php to retrieve the returned variables. Or if you wanted to collect the information before hand and pass it to 2CheckOut you could do that too:

If you use php then it's pretty easy:
<input type=text name=email value="<?=$email?>">

would pre-populate the form on return from 2Checkout with the email they entered.

-Jeff

gargonzo
02-07-2002, 11:36 PM
thanks will give it a try.. i would not have to define the variables.. since 2checkout is sending them, right?

is the syntax correct? heh bbiab will try
regards
garz

jffmrk
02-08-2002, 01:33 AM
For me... I have an order form, collect the details, send the user to 2CheckOut passing in variables 2CheckOut expects. The credit card form gets pre-populated and the user fills out the rest. After they 2CheckOut returns to my "receipt" page that says thanks but also emails me the data passed from 2CheckOut so I can go ahead and setup the account.

The following code is what I have in my "receipt.php" page. This loads after the user completes the 2CheckOut order form:

<?
$body =
"Credit Card Status .. $credit_card_processed \n" .
"Total Billed ........ $total \n" .
"Order Number ........ $order_number \n" .
"Merchant Order ID ... $merchant_order_id \n" .
"Cart Order ID ....... $cart_order_id \n" .
"Product ID .......... $product_id \n\n" .
"Card Holder Name .... $card_holder_name \n" .
"Email Address ....... $email \n" .
"Phone Number ........ $phone \n" .
"Street Address ...... $street_address \n" .
"City, State Zip ..... $city, $state $zip \n" .
"Country ............. $country \n" .
"Demo ................ $demo \n\n";

mail("orders@beanbaghost.com",
"$merchant_order_id",
$body,
"From: receipt@beanbaghost.com");
?>
You don't need to define the variables. If the variable is not defined it'll print an empty string.

Hope that helps,

-Jeff

Perfecthost
02-20-2002, 07:18 PM
Hi all-

I am trying to set up 2 checkout on my site. However, I have run into a snag. I need to add a text-box form field so that clients may tell us what domain name they want us to host. All the rest of the variables are hidden. I want the domain name to be passed through the 2checkout system to the order email sent to me.

I have written the code(html), but 2checkout will not pass the variable back to me via email. I tried to be clever and use ship_name as the variable for the domain field since it is a 2checkout variable for shipping(which is not used). Still it will not pass the domain name to the email.

Has anyone had success with this?

Oh, I am not a fluent php person.:stickout

(SH)Saeed
02-20-2002, 08:00 PM
If I'm not misstaking, from what I've understood, you can set any information you want to be returned to you in the variable $merchant_order_id. You could also have a database and store the domain name in there and give the user an uniquw order id and send it as $merchant_order_id and then get it from the database when the order is finished and the users is sent back to your website.

Perfecthost
02-20-2002, 08:38 PM
BINGO!!!!!

That's what I needed! merchant_order_id did the trick.

Thanks. I owe you one!:D

-Lamar

peachtreewebworks
04-08-2002, 11:41 AM
Hate dragging an old post back again, but, got a question about passing back variables. On 2CheckOut's cart specs page, there is a line on the bottom that states:

Note: Any parameters sent into the routine will be passed back to your routine after the sale is complete.

Has anyone been successful in getting something you've sent in passed back to you? (ie. Like a param called "MyParm") All the ones that are specifically stated, like cart_id and such, work fine, but I can't get my custom ones to come back.

(SH)Saeed
04-08-2002, 02:16 PM
Here is a little tip for those of you that want to get more information from the user before sending them to 2CheckOut.com..

[list=1]
Create a database with the fields you want (i.e. frontpage extensions, domain name, comments, etc) and add an additional field named uniqueID.

Make a form with all these extra fields that you want and have it send the information to a verification script that makes sure everything is filled out correctly. This script should then generate a random and unique order ID for each order and save it along with all the other information in the database you've created. After that it should send the user to 2CheckOut.com site for payment with the unique order ID as "merchant_order_id" (e.g. recpurchase.2c?sid=12345&product_id=3&merchant_order_id=uniqueID).

Now you have to make a thank you page for when your users are returned to your website after payment. Here should be a script that will grab the information that is sent back from 2CheckOut.com (address and stuff) and also grab your unique order ID that is returned in the merchant_order_id variale to grab the additional information from the database and email them all to you. Don't forget, it should also display a thank you message :D
[/list=1]


You will need a little programming skill to do such thing. I'm sure a lot of you know how to program such simple script or know someone to do it for you.

//Saeed

peachtreewebworks
04-08-2002, 02:22 PM
Thanks for the reply... I kinda figured that was one way to do it, but since 2CheckOut's site says they can pass back whatever, I thought I'd ask... you know, save overhead having to open up another data connection to get data I already had!

Thanks though! :)

(SH)Saeed
04-08-2002, 03:07 PM
What they have written about sending any variable is for their cart (not sure if they mean what it sounds like though). I've tried it and it does not work for the recurring billing. I guess if you don't want to use MySQL, you could use cookies or even sessions to store the information so that the user can make the payment and get back to your site for the thank you message. However, we prefer using MySQL since there is always a chance the email will not get through and this way we don't lose any information.

TopDog07
04-08-2002, 09:49 PM
Where I can get some how-to or tutorials (lol) on fixing the order forms for our website? Something maybe that I could look off of to get a general ideal.

As of now we have the order form where the customer must fill out thier name address, domain name, etc (but not CC info), then they are redirected to 2CheckOut's page to enter thier CC info.

Wonder if that would scare away potential customers (Enterting just thier address twice). :confused:

peachtreewebworks
04-08-2002, 09:55 PM
What do you you have your order form processed with? PHP, ASP, CGI, etc?

(SH)Saeed
04-08-2002, 10:05 PM
TopDog21, why don't you use the address information that the user types in at 2CheckOut.com since they are sent to you via email and also sent to your website if you have chosen to have the user be sent back to your website after payment?

TopDog07
04-09-2002, 12:29 PM
That is the problem Amazon, I do not know how to intergate the passback parameters in a form and such. That is why I need a "template" or something to modify/look off of in order to do it.
eg. complete information ;)

(SH)Saeed
04-09-2002, 01:36 PM
TopDog21,

It is very simple. Here is a quote from 2CheckOut.com:

The following parameters will be passed back to your routine. Optionally a confirmation email with your merchant order number and ours will be sent to you and the buyer when the credit card transaction is approved.

order_number - 2Checkout.com order number
merchant_order_id - Your order number passed back
product_id - 2Checkout.com Product ID #
card_holder_name - Card holders name
street_address - Card holders address
city - Card holders address
state - Card holders address
zip - Card holders address
country - Card holders address
email - Card holders email
phone - Card holders phone number
credit_card_processed - "Y" if successfull
total - Total billed to credit card.

This means that if you're using PHP, the city will be stored into $city and country will be stored into $country, their name will be stored into $card_holder_name, etc..

(SH)Saeed
04-09-2002, 01:44 PM
<?php

// ===== Configure Script ==========

// The email address where you want the order information to be sent to
$toEmail = "name@domain.com";

// The email address you want the order email to be sent from
$fromEmail = "name@domain.com";

// Full URL of your thank you page
$thankURL = "http://www.domain.com/order/thankyou.html";

// ===== Do Not Edit Below This Line ==========

$body =
"Credit Card Status .. $credit_card_processed \n" .
"Total Billed ........ $total \n" .
"Order Number ........ $order_number \n" .
"Merchant Order ID ... $merchant_order_id \n" .
"Cart Order ID ....... $cart_order_id \n" .
"Product ID .......... $product_id \n\n" .
"Card Holder Name .... $card_holder_name \n" .
"Email Address ....... $email \n" .
"Phone Number ........ $phone \n" .
"Street Address ...... $street_address \n" .
"City, State Zip ..... $city, $state $zip \n" .
"Country ............. $country \n" .
"Demo ................ $demo \n\n";

mail("$toEmail", "New Order: $merchant_order_id", $body, "FROM: $fromEmail");

header("Location: $thankURL");

?>


Ok, I've used parts of the code jffmrk posted to create a script that will email you the order information and then send the user to a thank you page. Configure this PHP script and set it as the return URL in your control panel at 2CheckOut.com. I hope this helps.

// Saeed

TopDog07
04-09-2002, 02:13 PM
Thats what I needed to know :)

Just one final question, where do they put in the domain name and such? (sorry I am not too good at forms).

(SH)Saeed
04-09-2002, 04:15 PM
Originally posted by TopDog21
Thats what I needed to know :)

Just one final question, where do they put in the domain name and such? (sorry I am not too good at forms).

You will have to make a form and send the domain name as merchant_order_id..

Here's an example of what an URL would look like..

https://www.2checkout.com/cgi-bin/crbuyers/recpurchase.2c?sid=12345&product_id=3&merchant_order_id=domain.com

The sid is your account number, product_id is the product of course and merchant_order_id is the domain your customer has entered.

If you don't have much experience with these things, I suggest you find someone (pay someone) to help you.

TopDog07
04-09-2002, 06:48 PM
I will try my luck tonight and see what happens. :)