Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry,

I am following your design in part 3 of the book to create a cart which is all fine - great guidance! But the website owner insists that the payment will be via PayPal (PP).  I have looked at part 2 where you use PayPal but with fixed amounts. I am trying to create a button/link to PP for a variable amount and in Australian dollars.  The code works fine as long as I do not try to change the currency.  I also need to add 'thankyou' and 'cancel' links back to the website but I can't seem to do that either. I have Googled for hours without finding the solution.

 

<!-- now the button -->
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_blank">
  <input type="hidden" name="cmd" value="_cart">
  <input type="hidden" name="business" value="xxxx@yyyy.com.au">
  <input type="hidden" name="item_name" value="Item Description">
  <input type="hidden" name="item_number" value="">
  <input type="hidden" name="amount" value="$total">
  <input type="hidden" name="handling" value="0.00">
  <input type="hidden" name="shipping" value="0.00">
  <!-- <input type="hidden" name="currency_code" value="AUD"> -->
  <input type="hidden" name="lc" value="AU">
  <input type="hidden" name="bn" value="PP-BuyNowBF">
  <input type="image" src="https://www.paypalobjects.com/en_AU/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
  <img alt="" border="0" src="https://www.paypalobjects.com/en_AU/i/scr/pixel.gif" width="1" height="1">
  <input type="hidden" name="add" value="1">
</form>

You can see that I have commented the currency out - with it 'in' I get an error from PP.

Any guidance will be much appreciated.

Best regards from Oz :-)

Link to post
Share on other sites

Hi Larry,

Found some more code which displays the button nicely but even though the yellow PayPal bar shows the link/hand icon it goes nowhere.  I do have a developer id etc but don't know where to paste it.

 

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_blank">
				<div id="smart-button-container" style="width: 60%; margin-left: 21%;">
				<div style="text-align: left"><label class="checkout_form_mt_right v_align_top" for="description">Item:&nbsp;&nbsp;&nbsp;</label><input type="text" name="descriptionInput" id="description" size="40" value="Selected Jane Welsh Works of Art"></div>
				  <p id="descriptionError" style="visibility: hidden; color:red; text-align: center;">Please enter a description</p>
				<div style="text-align: left"><label  class="checkout_form_mt_right v_align_top" for="amount">Amount:&nbsp;&nbsp;</label><input name="amountInput" type="string" id="amount" value="$total"><span> AUD</span><span class='v_align_top white_text'><small><i>&nbsp;&nbsp;Australian dollars</i></small></span></div>
				  <p id="priceLabelError" style="visibility: hidden; color:red; text-align: center;">Please enter a price</p>
				<div id="invoiceidDiv" style="text-align: center; display: none;"><label for="invoiceid"> </label><input name="invoiceid" maxlength="127" type="text" id="invoiceid" value="" ></div>
				  <p id="invoiceidError" style="visibility: hidden; color:red; text-align: center;">Please enter an Invoice ID</p>
				<div style="text-align: center; margin-top: 0.625rem;" id="paypal-button-container"></div>
			  </div>
		  <!-- </form> 	   -->

I tried it with and without the closing form tag.  There's also a heap of JavaScript which comes with this example from PayPal which I have not touched nor included here.

Again, any advice will be most appreciated.

Link to post
Share on other sites

Hi Larry,  From SO the second code should not have the HTML form tags so I removed them but it still does not work.  I have also tried that code just in a simple HTML script but still no access to PP.  I would prefer to use the first script as at least it got me to PayPal if only I could find a way to set the currency to Australian dollars!  This must be a common thing to do - have a shopping cart in your PHP code and then just interface to PayPal with a single amount to process the financial transaction.  I have done similar with Stripe and that works fine but, as mentioned, the website owner insists on PP.  I look forward to your advice and thank you in anticipation.

Link to post
Share on other sites

I got there in the end after going down many 'blind alleys'.

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_blank">
			   <input type="hidden" name="cmd" value="_xclick">
			   <!-- <input type="hidden" name="cmd" value="_cart"> -->
			   <input type="hidden" name="business" value="xxxx@yyyy.com.au">
			   <input type="hidden" name="item_name" value="Item Description">
			   <input type="hidden" name="item_number" value="">
			   <input type="hidden" name="amount" value="$total">
			   <input type="hidden" name="handling" value="0.00">
			   <input type="hidden" name="shipping" value="0.00">
			   <input type="hidden" name="currency_code" value="AUD">
			   <input type="hidden" name="lc" value="AU">
			   <input type="hidden" name="bn" value="PP-BuyNowBF">
			   <input type="hidden" name="add" value="1">
			   <input type="image" src="./images/PayPal_Button.jpg" alt="Submit" width="100"> <!-- the submit button -->
			</form>

Cheers from Oz.

Link to post
Share on other sites
  • 1 month later...

This is now in production.  I've attached the code for anyone else who might be in a similar situation.

if ($local)
	{	// development
		echo <<<DD1
			<!-- DEVELOPMENT TEST!!!-->
			<div class="paypal_box">	<!-- right-shifts the div -->
			<!-- first the PayPal Logo - see: https://www.paypal.com/us/webapps/mpp/logo-center -->
			<img class="PP_logo" src="./images/PP_logo.jpg" alt="PayPal Logo">
			<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
			   <input type="hidden" name="cmd" value="_xclick">
			   <input type="hidden" name="business" value="xxx@yyy.com.au">
			   <input type="hidden" name="item_name" value="Selected Items">
			   <input type="hidden" name="item_number" value="">
			   <input type="hidden" name="amount" value="$total">
			   <input type="hidden" name="handling" value="0.00">
			   <input type="hidden" name="shipping" value="0.00">
			   <input type="hidden" name="currency_code" value="AUD">
			   <input type="hidden" name="lc" value="AU">
			   <input type="hidden" name="bn" value="PP-BuyNowBF">
			   <input type="hidden" name="add" value="1">
			   <input type="image" src="./images/PayPal_Button.jpg" alt="Submit" width="100"> <!-- the submit button -->
			</form>
			</div>	<!-- end paypal_box class div -->
			<br /><br />
DD1;
	}	// end development
else
	{	// production - see: https://cvconnect.commercevision.com.au/display/KB/PayPal+Payments
		echo <<<DD2
			<!-- PRODUCTION!!!-->
			<div class="paypal_box">	<!-- right-shifts the div -->
			<!-- first the PayPal Logo - see: https://www.paypal.com/us/webapps/mpp/logo-center -->
			<img class="PP_logo" src="./images/PP_logo.jpg" alt="PayPal Logo">
			<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
			   <input type="hidden" name="cmd" value="_xclick">
			   <input type="hidden" name="business" value="xxx@yyy.com.au">
			   <input type="hidden" name="item_name" value="Selected Items">
			   <input type="hidden" name="item_number" value="">
			   <input type="hidden" name="amount" value="$total">
			   <input type="hidden" name="handling" value="0.00">
			   <input type="hidden" name="shipping" value="0.00">
			   <input type="hidden" name="currency_code" value="AUD">
			   <input type="hidden" name="lc" value="AU">
			   <input type="hidden" name="return" value="https://xxx/index.php?p=thanks_3">
			   <input type="hidden" name="cancel_return" value="https://xxx/index.php?p=cancel_3">
			   <input type="hidden" name="bn" value="PP-BuyNowBF">
			   <input type="hidden" name="add" value="1">
			   <input type="image" src="./images/PayPal_Button.jpg" alt="Submit" width="100"> <!-- the submit button -->
			</form>
			</div>	<!-- end paypal_box class div -->
			<br /><br />
DD2;
	}	// end production

You will recognise the "$local" from one of your other books 🙂

As an aside, when obtaining guidance from your E-Commerce book, I used PDO for all database activities and that has worked fine.

All the best, Necuima

Link to post
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.
Note: Your post will require moderator approval before it will be visible.

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

Loading...
×
×
  • Create New...