I have created a webform using this module and the client would like to add PayPal options which will be required on submission of the form. I have created PayPal buttons, so I have 2 questions:

1) How can I simply add the PayPal buttons I have created to the webform?
2) If I wanted to create a mandatory payment option via PayPal, how can I do this?

Much appreciation.
Josh

Comments

allisonk’s picture

I am working on this too.

It seems some folks were developing a module - but it's only for 5.x:
http://drupal.org/project/webform_payments

And there's this thread too:
http://drupal.org/node/275857

But I'm not sure how it works or how to require certain fields...

allisonk’s picture

There seems to be a working solution here - but I haven't tried it:
http://drupal.org/node/543674

quicksketch’s picture

Webform does not (and won't) support any payment systems directly. Your best bet is to use an add-on module like allisonk has suggested.

JoshR’s picture

What about doing something like viewing the page as full html rather than filtered html and manually inputting the code for the PayPal button on the webform page? Has anyone tried this?

quicksketch’s picture

You can always theme your forms (as described in theming.txt) to manually add your own HTML.

JoshR’s picture

How can I simply add a link on the webform? (I should be able to use this to post the PayPal info)

-J

quicksketch’s picture

How can I simply add a link on the webform? (I should be able to use this to post the PayPal info)

Add a "markup" component and put the link in it.

JoshR’s picture

Status: Active » Closed (fixed)

Thanks for your quick responses! I will try these options, but as far as I am concerned this issue has been resolved.

shai.avi@gmail.com’s picture

Issue tags: +webform, +arrange_fields

I have a follow up question:
PayPal button code is written as a 'post' method and I'd like that to open another window/tab and for the user to complete that transaction on the paypal site; and I have a set of fields in my webform for which I have a submit button that I expect my user to fill the data and hit submit, but now, with the paypal code, clicking the paypal button submits (posts) the form, and doesn't go to the paypal site.

http://www.campgilboa.org/alumni-event-ad

Thank you!

tstermitz’s picture

@joshR

What about doing something like viewing the page as full html rather than filtered html and manually inputting the code for the PayPal button on the webform page? Has anyone tried this?

Yes, this works pretty well. You would create the paypal button using php to in the return page when they submit the webform. Put something like this in the "Confirmation message or redirect URL" window:

<?php
include_once(drupal_get_path('module', 'webform') .'/webform_submissions.inc');
$nid = arg(1); // need to hard-code nid if this is a custom page
$sid = $_GET['sid'];
$submission = webform_get_submission($nid, $sid);

$first_name = $submission->data[6]['value'][0];
$last_name = $submission->data[7]['value'][0];
$thanks = $first_name . " " . $last_name;

$total_to_pay = $submission->data[3]['value'][0];

?>

<h2>Thank you <?php print $thanks ?>... Your registration has been sent.</h2>
				
<ul>
<li>(0) Payment finalizes your registration.</li>
<li>(1) Important: Print out this page <b>and your paypal payment</b> as a receipt.</li>
</ul>

<h4> Paypal Payment  for One Person: $<?php print $total_to_pay; ?> </h4>

<ul>
<li><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="your_email@your_domain.com">
<input type="hidden" name="item_name" value="sd11">
<input type="hidden" name="item_number" value="s">
<input type="hidden" name="amount" value="<?php print $total_to_pay; ?>">
<input type="image" src="http://images.paypal.com/images/x-click-butcc.gif" name="submit" >
</form>
</li>
</ul>

To deal with the calculations based on buttons, I use some javascript code inserted into the "Description" window of the webform page. Something like this (But, don't blame me if my code fails or is ugly):

<?php
 
  drupal_add_js(
    '$(document).ready(function(){

	    $("#webform-component-reg_passtype").click(function() {
		var TotalToPay = 0;
		if ( $("#edit-submitted-reg-passtype-0").is(":checked") ) {
			TotalToPay = 0;
		}
		else if ( $("#edit-submitted-reg-passtype-1").is(":checked") ) {
			TotalToPay = 20;
		}
		else if ( $("#edit-submitted-reg-passtype-2").is(":checked") ) {
			TotalToPay = 100;
		}
		$("#edit-submitted-reg-total-to-pay").val(TotalToPay);
	});

	    $("#webform-component-gender").click(function() {

		if ( $("#edit-submitted-gender-C").is(":checked") ) {
			TotalToPay = 2 * TotalToPay;
		}
		$("#edit-submitted-reg-total-to-pay").val(TotalToPay);
	});

	});',
  'inline'
  );
?>

I'm trying to figure out how to receive the paypal "Payment Data Transfer", and populate the payment completed and payment date fields.

domesticat’s picture

A note for anyone who finds this thread and decides to try implementing it: for the version of webform that we were running, I had to change the include_once() line to point to a slightly different place:

include_once(drupal_get_path('module', 'webform') .'/includes/webform.submissions.inc');

Thanks for posting the code; it got me out of a bind.