Jump to content


Photo

Paypal


  • Please log in to reply
25 replies to this topic

#1 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 26 June 2005 - 01:56 PM

I have added a new snippet to the Snippet Library!

Snippet name: PayPal
Author: Robsta
Version: 1.0 (Beta)
More info: View this snippet
Description:
A simple PayPal snippet, allowing single item purchases to a PayPal hosted cart.

Please feel free to comment on this snippet, suggest improvements, or simply praise my work! ;)

[This is an automatically created message]

#2 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 26 June 2005 - 01:58 PM

I welcome any feedback, and please let me know how you get on with it. :)

#3 Dean

Dean

    Loves Etomite Forums!

  • Admin
  • 4,790 posts

Posted 26 June 2005 - 02:43 PM

Looks Good :D

#4 Guest_MikeFairbrother_*

Guest_MikeFairbrother_*
  • Guests

Posted 26 June 2005 - 05:22 PM

Hi There,

If you have an issue with pricing so that it only shows the default price you set, even if your button is setup with a price like:
[[PayPal?amount=5.99&name=Gold Watch]]

Then you either need to do one of the following:

(Red is the section edited)

1)
Change: [[PayPal?amount=5.99&name=Gold Watch]]
To: [[PayPal?price=5.99&name=Gold Watch]]

OR

2)
Change:
// Amount of the item, if non passed to the snippet, default value used.
if (empty($price)) $PAYPAL_AMOUNT = $PAYPAL_AMOUNT;
Else $PAYPAL_AMOUNT = $price;

To:
// Amount of the item, if non passed to the snippet, default value used.
if (empty($amount)) $PAYPAL_AMOUNT = $PAYPAL_AMOUNT;
Else $PAYPAL_AMOUNT = $amount;


PLEASE NOTE:
It's probably easier to edit the snippet, if your page is filled with different:
[[PayPal?amount=5.99&name=Gold Watch]] because currently, the snippet looks for 'price' not 'amount' like it is in that line.

However, if you only have one:
[[PayPal?amount=5.99&name=Gold Watch]]

Then just change the line, not the snippet.

Just to avoid any confusion, here it is re-done:
// -----------------------
// Snippet: PayPal
// -----------------------
// Version: 0.1a
// Date: 21 June 2005
// Written by Rob Freemantle (Robsta), www.inspired-solutions.net
//
// This snippet was designed to make it easy to use PayPal buttons in Etomite.
//
// IMPORTANT NOTE: This Snippit has not been tested with the requirements of a real transaction.
//
// Display 'Buy Now' button...   
// Usage   [[PayPal?amount=5.99&name=Gold Watch]]
//
// Display the shopping cart...  
// Usage   [[PayPal?cart=1]]
//
// To also include specific text which appears over the image, 
// add  '&text=New text'
//
// Display 'Buy Now' button...   
// Usage   [[PayPal?amount=5.99&name=Gold Watch&text=Click here to buy a gold plated watch]]
//
// Display the shopping cart...  
// Usage   [[PayPal?cart=1&text=Click here for the shopping cart]]

//********************************************************************************
**********
//********************************************************************************
**********
// Default Settings - General
//********************************************************************************
**********
//********************************************************************************
**********

// Email account to pay the money to.
$PAYPAL_BUSINESS= "name@domain.co.uk";

$PAYPAL_IMAGE = "https://www.paypal.com/en_GB/i/btn/x-click-but22.gif";           //Default payment button image
$PAYPAL_IMAGE_ALT = "Make payments with PayPal - its fast, free and secure!";     //Default payment button mouseover text

$PAYPAL_ADD = "1";                      //default number of items
$PAYPAL_ITEM_NAME = "Unnamed Item";     //default item name, configurable per Snippet call
$PAYPAL_AMOUNT = "1";                   //Default item price, configurable per Snippet call


$PAYPAL_CMD = "_cart";
$PAYPAL_PAGE_STYLE = "Primary";

//include the address to the root of Etomite, 
// excluding the last forward slash. Basically 
// to the location of the index.php.
// For example: "www.domain.co.uk/etomite" 
// where index.php can be found http://www.domain.co.uketomite/index.php
$YOUR_URL = "www.domain.co.uk";       

// On completion of the purchase, customers are returned to this document ID.
$PAYPAL_RETURN_PAGE_ID = "0";                                 

$PAYPAL_NO_NOTE = "1";
$PAYPAL_CURRENCY_CODE = "GBR";       // currency setting
$PAYPAL_LC = "GB";                   // currency setting

// Default view cart details
$PAYPAL_CART_IMAGE = "https://www.paypal.com/en_GB/i/btn/view_cart_02.gif";            //Default payment cart image
$PAYPAL_CART_IMAGE_ALT = "Make payments with PayPal - its fast, free and secure!";     // Default payment cart mouseover text


//********************************************************************************
**********
//********************************************************************************
**********
// The Snippet code
//********************************************************************************
**********
//********************************************************************************
**********


// Amount of the item, if non passed to the snippet, default value used.
if (empty($amount)) $PAYPAL_AMOUNT = $PAYPAL_AMOUNT;
Else $PAYPAL_AMOUNT = $amount;

// Name of the item to appear in the shopping cart, if non passed to the snippet, default value used.
if (empty($name)) $PAYPAL_ITEM_NAME = $PAYPAL_ITEM_NAME;
Else $PAYPAL_ITEM_NAME = $name;


// Shows buy now form or entire shopping cart.
// If the cart = empty (not set in the call), the 'buy now' button is shown. 
//       Else if cart=anything, the cart is opened.

if(!$cart) 

{

// Text appearing over the buy now button, if non passed to the snippet, default value used.

if (empty($text)) $PAYPAL_IMAGE_ALT = $PAYPAL_IMAGE_ALT;
Else $PAYPAL_IMAGE_ALT = $text;

$Output .= "<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
$Output .= "<input type='image' src='".$PAYPAL_IMAGE."' border='0' name='submit' alt='".$PAYPAL_IMAGE_ALT."'>";
$Output .= "<input type='hidden' name='add' value='".$PAYPAL_ADD."'>";
$Output .= "<input type='hidden' name='cmd' value='".$PAYPAL_CMD."'>";
$Output .= "<input type='hidden' name='business' value='".$PAYPAL_BUSINESS."'>";
$Output .= "<input type='hidden' name='item_name' value='".$PAYPAL_ITEM_NAME."'>";
$Output .= "<input type='hidden' name='amount' value='".$PAYPAL_AMOUNT."'>";
$Output .= "<input type='hidden' name='page_style' value='".$PAYPAL_PAGE_STYLE."'>";
$Output .= "<input type='hidden' name='return' value='http://".$YOUR_URL."/index.php?id=".$PAYPAL_RETURN_PAGE_ID."'>";
$Output .= "<input type='hidden' name='no_note' value='".$PAYPAL_NO_NOTE."'>";
$Output .= "<input type='hidden' name='currency_code' value='".$PAYPAL_CURRENCY_CODE."'>";
$Output .= "<input type='hidden' name='lc' value='".$PAYPAL_LC."'>";
$Output .= "</form>";

}
else
{

// Text appearing over the buy now button, if non passed to the snippet, default value used.

if (empty($text)) $PAYPAL_CART_IMAGE_ALT = $PAYPAL_CART_IMAGE_ALT;
Else $PAYPAL_CART_IMAGE_ALT = $text;

$Output .= "<form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
$Output .= "<input type='image' src='".$PAYPAL_CART_IMAGE."' border='0' name='submit' alt='".$PAYPAL_CART_IMAGE_ALT."'>";
$Output .= "<input type='hidden' name='cmd' value='".$PAYPAL_CMD."'>";
$Output .= "<input type='hidden' name='business' value='".$PAYPAL_BUSINESS."'>";
$Output .= "<input type='hidden' name='display' value='1'>";
$Output .= "<input type='hidden' name='page_style' value='".$PAYPAL_PAGE_STYLE."'>";
$Output .= "</form>";

}

return $Output;

^^ Just put this into a snippet, named PayPal (case sensative) If you name it anything else, you will need to change the: [[PayPal?]]
To:
[[Whatever you called it?function]]

So, if you called it Shopping
You need to use:
Show Cart: [[Shopping?cart=1]]
Add To Basket: [[Shopping?amount=10.00&name=My Item Costing £10]]
etc...

-------------------------------------------------------------------------------------

Apart from that little glitch, excellent code Robsta - Thank you ;)

(Apologise for the LONG post...)

#5 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 26 June 2005 - 05:47 PM

I have updated this snippet in the Snippet Library!

[This is an automatically created message]

#6 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 26 June 2005 - 05:51 PM

Hi There,

If you have an issue with pricing so that it only shows the default price you set, even if your button is setup with a price like:
[[PayPal?amount=5.99&name=Gold Watch]]

Then you either need to do one of the following:

(Red is the section edited)

1)
Change: [[PayPal?amount=5.99&name=Gold Watch]]
To: [[PayPal?price=5.99&name=Gold Watch]]

-------------------------------------------------------------------------------------

Apart from that little glitch, excellent code Robsta - Thank you  ;)

Hi Mike. Thanks for noticing my slight oversight :) . I did have it labelled 'amount' at the start, but thought it made more sense to change it to 'price'. Just forgot to change the instructions. Doh! :D I've updated the instructions in Snippet the library.

Glad you like it. :D

#7 Guest_MikeFairbrother_*

Guest_MikeFairbrother_*
  • Guests

Posted 01 August 2005 - 11:44 AM

Sorry, just post this just incase some don't realise.

Change:
$PAYPAL_CURRENCY_CODE = "GBR"; // currency setting

To:
$PAYPAL_CURRENCY_CODE = "GBP"; // currency setting

This is only if you wish to use the currency of £
$ = USD

Edited by MikeFairbrother, 01 August 2005 - 11:45 AM.


#8 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 01 August 2005 - 11:48 AM

Sorry, just post this just incase some don't realise.

Change:
$PAYPAL_CURRENCY_CODE = "GBR";    // currency setting

To:
$PAYPAL_CURRENCY_CODE = "GBP";    // currency setting

This is only if you wish to use the currency of £
$ = USD

Good point. Thanks.

#9 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 01 August 2005 - 11:49 AM

I have updated this snippet in the Snippet Library!

[This is an automatically created message]

Snippet updated to GBP for UK Pounds. Thanks Mike, a slight oversight. :blush:
I have also updated the version to 'b'.

Edited by Robsta, 01 August 2005 - 12:57 PM.


#10 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 01 August 2005 - 12:54 PM

I have updated this snippet in the Snippet Library!

[This is an automatically created message]

#11 ricardon

ricardon

    Etomite Forum Newbie

  • Member
  • 3 posts

Posted 30 December 2005 - 10:28 AM

This snippet looks good and I have downloaded it. Before puttin it to good use I would like some advice.

1) After the person has completed the transaction I would like to create an entry in a mysql or postgresql database. Can someone help with that task?

2) Is there a way of testing the button? Without getting paypal irate or my credit card overdrawn?

thanks

Richard

#12 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 01 January 2006 - 09:39 PM

2) Is there a way of testing the button? Without getting paypal irate or my credit card overdrawn?

The buttons all work this side of the payment system, ie it doesn't have any influence after payment has been made. Therefore you don't need to worry about going through with a payment.

#13 Dev63

Dev63

    Etomite Forum Newbie

  • Member
  • 9 posts

Posted 26 May 2006 - 05:55 AM

Hi guys.
Hi robsta. Thanks for your contribution.
Nothing new with this snippet since january?
May I offer some suggestions to help further the functionality of what you have created?

Allow sandbox usage for testing purposes.
It is a wise thing to use the paypal testbed when testing your paypal buttons/cart...
The sandbox behaves like a live paypal site. It allows the purchases to be made and then you can see how the return is working , ie:did user cancel, was the transaction successful, what to do if was successful (send email attachment with a download link to digital goods, or a code to unblock a software, etc..).
For the sandbox account you have, you login to paypal with it and enable IPN (Instant payment notifications), and disable automatic return url.
NONE of the transaction are commited to your real business account! They all commit to the fake email business acount you create when you sign on with the developer sandbox.

make use of it because it will allow you to test your snippet(s) FOR SURE, knowing that the snippet is working as it should..

There's plenty of documentation on how to parse for either successful, cancellation, or pending transactions at the paypal site(s).

Here's the link to sandbox:
https://developer.paypal.com/

maybe this will inspire some more work on your snippet.
I like your snippet btw.
I'd like to see you develop a small shopping cart.

Ok, enough. I'm outta here.

#14 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 08 August 2006 - 09:37 PM

I like your snippet btw.
I'd like to see you develop a small shopping cart.

Hi Dev63.

Thanks for your feedback. Although I would love to create a small shopping cart, there are some great carts out there that will integrate nicely with Etomite. Why re-invent the wheel ;)

This PayPal snippet is ideal for those small projects that people may have. But then there is always room for improvement ;)

Rob.

#15 Jordan

Jordan

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 19 October 2006 - 05:16 AM

Hi guys

I just still don't get it how to change the currency to USD.

I've searched a lot to find a way to convert that snipppet tu USD sites functionnallity, but since I am no programmer, I just couldn't do it by mysels. Here is a link to the PDF telling what to do.

https://www.paypal.com/en_US/pdf/PP_Website...rationGuide.pdf

Read it all, but cant figure...

any hints?

Thanks,

Jordan

Edited by Jordan, 19 October 2006 - 05:58 AM.


#16 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 20 October 2006 - 03:43 PM

You need to change both currency settings...

$PAYPAL_CURRENCY_CODE = "USD"; // currency setting
$PAYPAL_LC = "US"; // currency setting

I think those are correct.

Edited by Robsta, 20 October 2006 - 03:43 PM.


#17 Jordan

Jordan

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 23 March 2007 - 08:39 PM

I have tried this but it isn't working!

Jordan

EDIT

It gives me this error:
Parse error: parse error, unexpected T_VARIABLE in /home/content/j/o/r/jordanroy/html/index.php(589) : eval()'d code on line 38

Edited by Jordan, 23 March 2007 - 08:49 PM.


#18 Robsta

Robsta

    Likes Etomite Forums!

  • Member
  • PipPip
  • 360 posts

Posted 23 March 2007 - 08:47 PM

I have tried this but it isn't working!

Jordan

What doesn't work exactly?

#19 Jordan

Jordan

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 24 March 2007 - 04:41 AM

I resolved the problem without knowing how... :huh:

I just replaced the snippet with a new copy and made the changes and it works...

Jordan

#20 Jordan

Jordan

    Etomite Forum Newbie

  • Member
  • 10 posts

Posted 24 March 2007 - 12:23 PM

I got another problem though, I can't figure how to resize the image of the button. Any hints?

Jordan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users