?
Solved

How do I display and calculate the shipping along with the paypal cart?

Posted on 2009-02-18
23
Medium Priority
?
342 Views
Last Modified: 2012-05-06
I am trying to add the shipping calculation with the product total price. How do I do that? Can anyone help me please? Look at the attachment.

1) Can I display the modified total along with product total?

2) Is there any way to do?
MSC-paypal2.JPG
0
Comment
Question by:Loganathan Natarajan
  • 12
  • 6
  • 4
  • +1
23 Comments
 
LVL 4

Accepted Solution

by:
markgooding earned 1000 total points
ID: 23679418
It's a little unclear of the context in which you are working, but I assume you are passing the cart to paypal using the paypal API? In which case you need to pass the shipping amount to paypal.

See: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
0
 
LVL 20

Expert Comment

by:Gawai
ID: 23679481
can you post code so that we can guide u well.

dim shipping
shipping = 9.90
grandTotal = totals + shipping
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23680352
Ok, I am passing the shipping variable as some amount 9.90 ...

On the second page of Paypal, it is not shown the shipping amount deduction.. it displays only the product calculation total price...?

how do i display the shipping price? Do I need to enable anything on my paypal profile settings?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:markgooding
ID: 23680398
yes. go to your profile page -> shipping calculations

can check the box that says "Click here to allow transaction-based postage values to override the profile postage settings listed above (if profile settings are enabled)."
0
 
LVL 4

Expert Comment

by:markgooding
ID: 23680404
https://www.paypal.com/uk/cgi-bin/webscr?cmd=_profile-shipping

I hope the above links to the right page in your profile.
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23682584
Hi,

thanks for your reply, i went to the place but it displays like this message,


<checkbox> Click here to allow transaction-based shipping values to override the profile shipping settings listed above (if profile settings are enabled).

Do I need to check (enable) this box?

please tell me? it is urgent also. i have to complete..

am waiting to see the shipping amount to come on the page..


0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 total points
ID: 23683345
Regarding this: "Click here to allow transaction-based shipping values to override the profile shipping settings listed above" -- that is a question you need to answer based on your business logic.  If you are sending separate shipping costs along with the transactions you would probably want that feature turned on.  If you are using stored buttons or have set consistent shipping rules in PayPal you would probably want that turned off.  But either way, it is up to you - you will know what amounts you need to charge for shipping.

I like the shipping profile that allows you to specify the shipping costs based on the number of items purchased, but that's just me - it works for my business apps.

Best, ~Ray
0
 
LVL 4

Expert Comment

by:markgooding
ID: 23683620
if you are passing the shipping information as a variable in the PayPal API you will need to turn that on.
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23683810
Fantastic,.. Thanks Guys.. I think I am on the track.

I am passing the shipping information as Paypal Variable ... So I have also turn ON.. i mean checked/enabled. now..

I will test it..
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 23683835
Roger!  Best of luck, ~Ray
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23684058
now ,shipping displays 0.0 ...

I have a question, do I need to clear off my settings values ... see the attachment of Shipping Settings



Paypl.JPG
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23684070
Can anyone help me please? it is really annoying to me
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23684091
I use this PAYPAL variable

<input type='hidden' name='shipping' value='10.79'>

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 23684104
Are you sure your transaction-based settings are being sent correctly?

You can see this in the IPN, but it is asynchronous so you need to do a little bit of work to get the data.  In there, you can use ob_start() and var_dump() to capture the variables, then you can email them to yourself.
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23684184
I unable to do ob_start() or getting the response. because my client is testing it with CC

I have a question?

I just send only one paypal shipping variable to deduct... Is this correct?

any other parameter to this need to be passed?



<input type='hidden' name='shipping' value='10.79'>

Open in new window

0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23684367
any other variable to be passed to paypal for the shipping charge?

i have not used shipping2 or handling_cart ? do i need to use those?

my goal is to deduct one time charge for whole product purchase.... how to do this please?
0
 
LVL 4

Expert Comment

by:markgooding
ID: 23684562
You do not need to clear the other shipping information. This value should override them.
Your line of html looks correct.
You do not need shipping2 or handling.

You say you wish to deduct shipping. Are you trying to send a negative value? That is not possible with PayPal. That would be your problem!
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23688714
No, I am sending the shipping value as "10.79" to deduct as shipping,
0
 
LVL 4

Expert Comment

by:markgooding
ID: 23690441
Just tried it and found I had the same problem. Their API seems a little faulty. Try using "shipping_1" to set the shipping. The _x sets the shipping per item, but if it only set for the one item then it doesn't matter. It still works
<html>
<head><title>testpage</title>
</head><body>
<form action="https://www.paypal.com/uk/cgi-bin/webscr" method="post" target="_TOP">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="my business">
<input type="hidden" name="item_name_1" value="Item 1">
<input type="hidden" name="amount_1" value="7.00">
<input type="hidden" name="item_name_2" value="Item 2">
<input type="hidden" name="amount_2" value="7.00">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="shipping_1" value="2.50">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_xpressCheckout.gif" name="submit" alt="Make payments with PayPal - 
 
it's fast, free and secure!">
</form>
 
</body>
</hmtl>

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 23692692
I have found that name_x notation to be somewhat confounding, and I wish that PayPal could get to some kind of an XML-based interface so we could use iterators.  In most cases it seems if you send ONE item, they call the fields "name" but if you send more than one item they call the fields "name_x" where "x" is a number incrementing from 1 (not zero) upwards.  I deal with that issue in my IPN starting at about line 77 of the code snippet.  HTH, ~Ray
<?php // RAY_paypal_ipn.php - CUSTOM PayPal IPN PROCESSING
 
// LOCAL FUNCTIONS AND VARIABLES, CF: warning_RAY() SENDS AN EMAIL MESSAGE
require_once('_config.php');
 
// READ THE POST FROM PayPal AND ADD 'cmd'
$postdata	= '';
$req		= 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
	$postdata	.= "\n $key = $value ";				// SAVE THE COLLECTION
	$$key		= trim(stripslashes($value));		// ASSIGN LOCAL VARIABLES
	$value		= urlencode(stripslashes($value));	// ENCODE FOR BOUNCE-BACK
	$req		.= "&$key=$value";
}
 
// POST BACK TO PayPal SYSTEM TO VALIDATE
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
 
// TEST FOR VERIFICATION
if (!$fp) { // HTTP ERROR
	warning_RAY("IPN HTTP ERROR", "fsockopen failed \n\n ERRNO=$errno \n\n ERRSTR=$errstr \n\n");
	die();
}
 
// HTTP OPEN - WRITE HEADER AND REQUEST
fputs ($fp, $header . $req);
 
// HTTP OPEN - READ PayPal RESPONSE, DISCARDING HEADERS TO THE VERY END
$paypal_reply 	= '';
$paypal_headers	= '';
while (!feof($fp)) {
	$paypal_reply	= fgets ($fp, 1024);
	$paypal_headers	.= $paypal_reply;
}
fclose ($fp);
 
// IF THIS IS TRULY A POST FROM PAYPAL, PROCESS ORDER NOTIFICATION
if (strcmp ($paypal_reply, "VERIFIED") == 0) {
	$errormsg = "";
 
// IF PAYMENT IS NOT COMPLETED (MAY BE E-CHECK?)
	if ($payment_status != "Completed") { $errormsg .= "\nE: payment_status"; }
 
// IF PAYMENT WAS NOT SENT TO ME?
	$receiver_email = strtolower($receiver_email);
	if ($receiver_email == "me@my.org") { } else { $errormsg .= "\nE: receiver_email"; } // ??? SET EMAIL ADDRESS
 
// I AM NOT CHECKING SOME THINGS BECAUSE WE ARE USING ENCRYPTED OR STORED BUY-NOW BUTTONS
	if ($mc_currency != 'USD') { $errormsg .= "\nE: mc_currency"; }
 
// CHECK FOR TXN_ID ALREADY PROCESSED - NORMAL FOR E-CHECK
	$sql = "SELECT txn_id FROM PAYPAL_ORDER_LOG WHERE txn_id = \"$txn_id\" ";
	if (!$result = mysql_query($sql, $db_connection)) { fatal_query_error($sql); }
	$num_rows = mysql_num_rows($result);
	if ($num_rows  > 0) { $errormsg .= "\nE: Transaction id $txn_id already processed $num_rows time(s)"; }
 
// LOG THE TRANSACTION
	$order_date		= date('Y-m-d\TH:i:s');
	$item_number	= mysql_real_escape_string($item_number, $db_connection);
	$mc_gross 		= mysql_real_escape_string($mc_gross,    $db_connection);
	$address_zip	= mysql_real_escape_string($address_zip, $db_connection);
	$txn_id 		= mysql_real_escape_string($txn_id,      $db_connection);
	$receipt_id		= mysql_real_escape_string($receipt_id,  $db_connection);
	$last_name		= mysql_real_escape_string($last_name,   $db_connection);
	$payer_email	= mysql_real_escape_string($payer_email, $db_connection);
	$postdata		= mysql_real_escape_string($postdata,    $db_connection);
	$sql = "INSERT INTO PAYPAL_ORDER_LOG (    order_date,      item_number,      mc_gross,      address_zip,      txn_id,      receipt_id,      last_name,      payer_email,      postdata)
			VALUES						 ( \"$order_date\", \"$item_number\", \"$mc_gross\", \"$address_zip\", \"$txn_id\", \"$receipt_id\", \"$last_name\", \"$payer_email\", \"$postdata\")";
	if (!$result = mysql_query($sql, $db_connection)) { fatal_query_error($sql); }
 
// ISSUE A MESSAGE TO THE HOME OFFICE ?
	warning_RAY("IPN VERIFIED", "IPN REPLY $paypal_headers \n\n$errormsg \n\nPOST DATA FOLLOWS: $postdata \n\n");
 
// GENERATE ARRAYS OF PURCHASE DATA FROM THE WEIRD PAYPAL VARIABLE NAMES
// ACHTUNG: NO POSITION ZERO IN THESE ARRAYS
	$w_item_number	= array();
	$w_quantity		= array();
	$w_mc_gross		= array();
	$w_item_name	= array();
 
// IF TRANSACTION TYPE IS CART, MAY BE MULTIPLE ITEMS IN DIFFERENT QUANTITIES - LOAD ARRAYS
// NO POSITION ZERO IN THESE ARRAYS
	if ($txn_type == "cart") {
		while ($num_cart_items > 0) {
			$proxy	= "item_number" . "$num_cart_items";
			$w_item_number[$num_cart_items] = $$proxy;
 
			$proxy	= "quantity" . "$num_cart_items";
			$w_quantity[$num_cart_items] = $$proxy;
 
			$proxy	= "mc_gross_" . "$num_cart_items";
			$w_mc_gross[$num_cart_items] = $$proxy;
 
			$proxy	= "item_name" . "$num_cart_items";
			$w_item_name[$num_cart_items] = $$proxy;
 
			$num_cart_items--;
		}
	} else {
// NOT A CART - SINGLETON ITEM ONLY - NORMALIZE INTO ARRAY
// NO POSITION ZERO IN THESE ARRAYS
		$w_item_number[1]	= $item_number;
		$w_quantity[1]		= $quantity;
		$w_mc_gross[1]		= $mc_gross;
		$w_item_name[1]		= $item_name;
	}
 
// *****************************************************
// ACTIVATE THIS CODE BLOCK TO SEE WHAT IS IN THE ORDER ARRAYS
//
//	ob_start();
//	echo "<pre>\n";
//	echo "\nW_ITEM_NUMBER"; var_dump($w_item_number);
//	echo "\nW_QUANTITY";    var_dump($w_quantity);
//	echo "\nW_MC_GROSS";    var_dump($w_mc_gross);
//	echo "\nW_ITEM_NAME";   var_dump($w_item_name);
//	$foo	= ob_get_contents();
//	ob_end_clean();
//	warning_RAY("IPN VARDUMPS", "$foo \n\n");
// *****************************************************
 
 
// ITERATE OVER THE ARRAYS
	$kount = 0; // NO POSITION ZERO IN THESE ARRAYS
	while ($kount < count($w_item_number)) {
		$kount++; // BUMP BEFORE WORKING
		$my_item_number	= $w_item_number[$kount];
		$my_quantity	= $w_quantity[$kount];
		$my_mc_gross	= $w_mc_gross[$kount];
		$my_item_name	= $w_item_name[$kount];
 
//
// PROCESS THE ORDERS ???
//
 
	} // END ITERATION
 
// END OF NORMAL PAYPAL IPN PROCESSING
	die();
}
 
// NOT NORMAL PROCESSING
// LOG INVALID POSTS FOR MANUAL INVESTIGATION AND INTERVENTION
if (strcmp ($paypal_reply, "INVALID") == 0) {
	warning_RAY("IPN INVALID", "IPN REPLY $paypal_headers \n\n$errormsg \n\nPOST DATA FOLLOWS: $postdata \n\n");
	die();
}
 
// OTHERWISE, PayPal RETURNED BAD DATA (OR INTERNET HTTP ERRORS OR TIMEOUT)
warning_RAY("IPN REPLY UNKNOWN", "IPN REPLY $paypal_headers \n\n$errormsg \n\nPOST DATA FOLLOWS: $postdata \n\n");
die();
 
?>

Open in new window

0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23693920
I will try this.
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 23708369
Finally, I tried with  "handling_cart" + shipping .. it worked out.. I want to thank  both Ray_Paseur
markgooding

0
 
LVL 36

Author Closing Comment

by:Loganathan Natarajan
ID: 31548329
Thanks for all! ....
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Ranking ecommerce websites is a vital process. You need to have a strong SEO (Search Engine Optimization) strategy. If you don’t have one, you are losing out on brand impressions, clicks and sales. Check this guide on how to improve website traffic …
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question