TOPIC:

How to Use PayPal with Classic Forms 11 years 1 month ago #8488

  • Topic Author
  • arc_admin
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 4
First, many thanks to user 'glwright' who helped me figure this out.

Here is working code with only the site domain obfuscated. Note that PayPal has a 'sandbox' mode for testing plus the live site to accept real payments. There are two 'return' links. One returns to my 'Thank You' page which triggers an email to be sent. If the customer clicks cancel while at the PayPal site they return to the &cancel_return URL where you can tell tell them their transaction was not completed.

On the PayPal site you must do the following:
1) Set up a payment button, but you do not need the code from there. All you need is the generated button ID to include in the code below
2) In your PayPal Profile/Web Site Payments Preferences: set Auto Return ON

And in your form's Begin Submit piece include the following code:
// ----  Paypal Processing  ---------------------------------------------
$business = "OnlinePayments@mydomain.org" ;   // email addr for your PayPal merchant acct
$rurlraw  = "http://mydomain.org/index.php?option=com_facileforms" .
            "&ff_name=arcRNEW12&ff_page=1&Itemid=142" ;  // raw URL for return
$rurl     = urlencode($rurlraw) ;                        // url encoded
$canurl    = "http://mydomain.org/index.php?option=com_facileforms" .
             "&ff_name=arcRNEW13&ff_page=1&Itemid=143" ;  // raw URL for cancel
$cancelurl = urlencode($canurl) ;                         // url encoded
$PPURL = 'https://www.paypal.com/cgi-bin/webscr?' ;
$button = '1234567' ;   // PayPal Button ID

//  Adjust if Test Site
if ($site == "Test") {
$business = "ken_1234567890_biz@mydomain.org" ;
$rurlraw  = "http://mydomain.org/test/index.php?option=com_facileforms" .
            "&ff_name=arcRNEW12&ff_page=1&Itemid=142" ;  // raw URL for return
$rurl     = urlencode($rurlraw) ;                        // url encoded
$canurl    = "http://mydomain.org/test/index.php?option=com_facileforms" .
             "&ff_name=arcRNEW13&ff_page=1&Itemid=143" ;  // raw URL for cancel
$cancelurl = urlencode($canurl) ;                         // url encoded
$button = '9876543' ;   // PayPal Button ID
$PPURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr?' ;
}  //  site = "Test"

$item_name = "Club Membership Renewal" ;
$amount    = $AMTPAID ;
$logo      = "http://mydomain.org/images/site_logo.gif" ;
$retmsg    = "RETURN TO Our Club to COMPLETE YOUR RENEWAL" ;

$data  = "cmd=_xclick&business=$business&item_name=$item_name&item_number=1" .
         "&amount=$amount&no_shipping=1&cancel_return=$cancelurl" .
         "&no_note=1&currency_code=USD&lc=US&cpp_header_image=$logo" .
         "&address1=$ADDRESS&city=$CITY&state=$ST&zip=$ZIP" .
         "&first_name=$FIRSTNAME&last_name=$LASTNAME" .
         "&return=$rurl&cbt=$retmsg&custom=$Badge&rm=2" .
         "&hosted_button_id=$button" ;

$url = $PPURL . $data ;
ff_redirect("$url","top","post") ;

//  That's it -----  You do not return to here; 
//  but to one of the above return URLs
The following user(s) said Thank You: wartime

Please Log in or Create an account to join the conversation.

Last edit: Post by arc_admin.

Re:How to Use PayPal with Classic Forms 11 years 1 month ago #8492

  • Topic Author
  • arc_admin
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 4
Just one note: I notice the forum software stripped the
"http://"
from all of the URLs I posted in the above code, but all of the URLs do require this specification.

Never mind - corrected by displaying as code.

Ken
The following user(s) said Thank You: wartime

Please Log in or Create an account to join the conversation.

Last edit: Post by arc_admin.

Re:How to Use PayPal with Classic Forms 11 years 1 month ago #8539

  • rewing
  • Visitor
  • Visitor
I don't know why I get an error with the above instruntion:

Fatal error: Call to undefined function ff_redirect() in /home4/mydomain/public_html/components/com_facileforms/facileforms.process.php(1049) : eval()'d code on line 27

Another thing is how to get the field value that user input? ff_getSubmit?

if you can export a full working example package and attached in the thread, this would be great help. Because people can modified from a working example.

I would appreciate if you could help me with it. my email is rewing#howfortune.com

Please Log in or Create an account to join the conversation.

Last edit: Post by rewing.

Re:How to Use PayPal with Classic Forms 11 years 1 month ago #8546

  • Topic Author
  • arc_admin
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 22
  • Thanks: 4
The first line of any of your piece code when working with Breezing Forms should generally be:
$this->execPieceByName('ff_InitLib');
This defines all of the BF functions and should make your php error go away.

Yes, you get user input from your defined fields on form pages using:
$func = ff_getSubmit('arcHiddenFunc',   0);
In my example I am retrieving the value of a field named 'arcHiddenFunc'. If that field is null then 0 will be returned.

Happy coding!
Ken
The following user(s) said Thank You: wartime

Please Log in or Create an account to join the conversation.

Re:How to Use PayPal with Classic Forms 11 years 1 month ago #8551

  • rewing
  • Visitor
  • Visitor
Hi,Ken,

Thanks! But I don't know why my test form can't work.

Would you please help me check with it?

File Attachment:

File Name: mypck_001-...0908.zip
File Size:2 KB
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: Post by rewing.

Re:How to Use PayPal with Classic Forms 11 years 1 month ago #8569

  • iamwaggle
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 2
  • Thanks: 2
Hi Ken!

Nicely done! I've got everything working per your example.

I want to use this script in the After Submit area so I can capture the user's form data. Is there any way to get the Paypal transaction id back from Paypal and into the database like Easy Mode does it?

I've been working on it for a while but I can't seem to figure it out. My only other thought is to have the return URL send the user to another form and take the "tx" from the address bar REQUEST and plunk it into the form as a hidden field. I'm just wondering if you have any thoughts on this. Making Paypal available in the Classic Form is definitely needed. This is the only function holding me back from pure bliss.

Thanks for your help!
Justin
The following user(s) said Thank You: wartime

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.055 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!