This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

A way to integrate PayPal

  1. MultiMatt

    I just purchased MachForm and I'm very excited about the functionality! I whipped up a contact form for my wife's site in seconds, which rocked!

    I have a non-profit environmental group ( I am doing some work for, and they want to have online registration for their annual conference. I was hoping to create a form which would capture the essential registration information, then incorporate PayPal buttons for the variety of things a person could register for (workshops, etc).
    That way, the visitor is just filling out one form, but the treasurer has the info they need, and the registration folks have the info they need...

    With the old method I used for creating forms, I was able to go into the actual form HTML page and do some tweaking, which would have allowed me to insert the code for the PayPal buttons.
    I know (just enough to be dangerous!) that your forms are database driven, so essentially there isn't a stand-alone page for me to edit and do such a thing.

    Do you have a suggestion for how I might accomplish what I would like to do for them?

    It would be nice to have something like that incorporated into the form building process, if possible!

    Thanks in advance!

    Posted 14 years ago #
  2. yuniar

    I have received many requests regarding PayPal integration, however I'm afraid this feature is not available in current version.

    It is possible to modify the code for PayPal integration, but it requires advanced PHP programming skill.

    I can't help with the customization itself, but I can give you some pointer.

    You only need to modify includes/post-functions.php file. There is a function there called process_form(), you will need to modify this function to redirect to paypal with the necessary parameters from your form.

    Around line 865, you can see the standard code to send the redirect URL.

    $process_result['form_redirect'] = $form_redirect;

    You will need to customize that line. So that $process_result['form_redirect'] would contain the appropriate PayPal URL.

    I hope that helps.

    MachForm Founder

    Posted 14 years ago #
  3. teamwebb2008

    Would I place my url after this: $process_result['form_redirect'] or would I need to continue coding. New to php and learning fast with your help. Thanks again.

    Posted 14 years ago #
  4. yuniar

    Above the $process_result['form_redirect'] line, you can have something like:

    if($form_id == 5){
      $form_redirect = '';

    that's the simplest code sample. you can have another coding there to construct the final paypal URL.

    This PayPal URL generator is quite handy:

    This one more complete:

    This one to generate Subscription URL:

    MachForm Founder

    Posted 14 years ago #
  5. teamwebb2008

    Where can I find the review submission? I would like to place the above code on submission of this form.

    Posted 14 years ago #
  6. yuniar

    Do you mean you would like to enable form review?

    If so, click on your form properties and check the "Show Review Page Before Submitting" checkbox.

    MachForm Founder

    Posted 14 years ago #
  7. tgkennedy

    The redirect doesn't work if you have the "Show Review Page Before Submitting" option checked. If you uncheck it, the redirect code for PayPal above works fine. I too was looking for code in the confirm.php file that would then redirect to PayPal, but I could not find it.

    Posted 14 years ago #
  8. yuniar

    If you have "Show Review Page Before Submitting" enabled, there is some difference to put the code indeed.

    If this is the case, edit "includes/post-functions.php" file, go to the bottom and you'll see this:

    $commit_result['form_redirect'] = $form_redirect;

    simply adjust that line.

    MachForm Founder

    Posted 14 years ago #
  9. teamwebb2008

    I tried the above and now I get the following:

    Parse error: syntax error, unexpected T_STRING in /home/p14acaoh/public_html/machform/includes/post-functions.php on line 876

    Posted 14 years ago #
  10. yuniar

    Try paste your code (few lines before and after line 876) here, it looks like you are having some syntax error.

    MachForm Founder

    Posted 14 years ago #
  11. teamwebb2008

    I tried your advice and I got this error:
    Parse error: syntax error, unexpected T_STRING in /home/p14acaoh/public_html/machform/includes/post-functions.php on line 877

    I removed the code below completely and I got this error:
    Parse error: syntax error, unexpected T_STRING in /home/p14acaoh/public_html/machform/includes/post-functions.php on line 2260

    If(form_id == 2) {
    $form_redirect = ""
    <input type="hidden" name="business" value="">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="add" value="1">
    <input id="element_67_1" name="Family" class="element checkbox" type="checkbox" value="140.00" />
    <input id="element_67_2" name="Senior" class="element checkbox" type="checkbox" value="115.00" />
    <input id="element_67_3" name="Junior" class="element checkbox" type="checkbox" value="100.00" />
    <input id="element_67_4" name="Professional" class="element checkbox" type="checkbox" value="85.00" />
    <input id="element_67_5" name="Associate" class="element checkbox" type="checkbox" value="35.00" />

    I have really messed things up. I got the above code to work in a plain html file, but will not work with my forms.

    Posted 14 years ago #
  12. yuniar

    The $form_redirect variable only accept an URL, so it won't work if you paste the whole form code there. You need to construct the URL using the PayPal generator above.

    MachForm Founder

    Posted 14 years ago #
  13. scutuma

    I have a form where I want the user to specify how many of a specific item he wants to purchase. From that I can calculate the total cost. I can then use a redirect similar to the above redirect for PayPal but to CASHNet instead. The problem I have is that I need to multiply the number of items purchased by the cost per item and include that total in the URL to which the user is redirected. Could you tell me if this is possible to calculate this cost in post-functions.php so that I can fashion the correct URL? If it is possible, could you explain how to do this?

    Posted 11 years ago #
  14. christopherbrooks

    I have a very similar need. The form includes several check boxes from which a somewhat custom calculation would determine the total amount. I was considering putting a trigger on the review table, to do the calculation and post the result to a column (existing or perhaps a new one). If I did that, would the review page show the trigger-generated total? ANy thoughts on whether this would be more or less appropriate that doing the calculation in the php script? Either way I want the user to be able to see the total (and possibly pass it to PayPal or Google Checkout). For even more capability, would there be any way to display the running, recalculated total on the form itself?

    Posted 11 years ago #

RSS feed for this topic