I needed this functionality for a project I'm working on. I've added the following items:

  • Adjusted the component for various tasks - now includes checkbox (and permissions) to update payment status when "editing" a previous submission
  • Updated the component to include new "Private" field that is part of Webform
  • Store the value of "paid" or "unpaid" in the database for each submission - instead of the button ID.
  • Display the value of "Paid" or "Unpaid" when viewing previous submissions
  • Added value of "Paid" or "Unpaid" to results/reporting - table & CSV download

So far, this still doesn't receive/make updates after payment is completed at PayPal - it is still a manual process for the site admin.

Please take a look and review - I'm still new to actually submitting code for review and could use feedback.

Comments

avr’s picture

StatusFileSize
new7.25 KB

And here's the patch.

avr’s picture

StatusFileSize
new7.65 KB

Updated patch - previous patch broke the submission/button ID.

mrf’s picture

Category: support » feature

Still wrapping my head around the paid / unpaid thing and testing the patch, but I like the direction this is going.

I really like the private field addition, any chance you could move that to a separate issue with its own patch? I could test that separately and simplify how much is being changed here.

avr’s picture

@mrf

The "private" field is actually part of Webform - so it should be just built in now that it's included in the component.

I haven't really worked with PayPal much, but after looking at their info, i think the 'callback' should be possible. It probably would be easy enough to look into Commerce to see how they are handling the postback/update information.

I also went ahead and added a few more options for my own needs - they aren't 'flexible' but I'll post to a sandbox if you want to take a look.

mrf’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Status: Needs review » Needs work

Hi avr, here is some initial feedback on the patch. I still haven't thoroughly tested everything, but wanted to offer some tips while I'm still working on it.

+++ b/webform_paypal.module
@@ -58,6 +78,17 @@ function _webform_edit_paypal($component) {
+/**
+ * Implementation of hook_form_FORM_ID_alter().
+ */
+
+function webform_paypal_form_webform_component_edit_form_alter(&$form, &$form_state, $form_id) {
+  if ($form['type']['#value'] == 'paypal') {
+    // Remove unnecessary elements that could confuse the user when editing the component
+    $form['display']['#access'] = FALSE;
+    $form['extra']['description']['#access'] = FALSE;
+  }
+}

This is probably a useful UI addition but should be pulled into a separate issue to simplify this one.

+++ b/webform_paypal.module
@@ -69,48 +100,113 @@ function _webform_edit_paypal_validate($form, &$form_state) {
+  ¶

Nitpicky change, but shouldn't be spaces at beginning of this line.

+++ b/webform_paypal.module
@@ -144,3 +240,28 @@ function webform_paypal_submit(&$form, &$form_state) {
+  return empty($value['status']) ? '' : ucfirst($value['status']);

Drupal devs usually prefer the long form to help increase readability of code.

+++ b/webform_paypal.module
@@ -144,3 +240,28 @@ function webform_paypal_submit(&$form, &$form_state) {
+  return empty($value['status']) ? '' : ucfirst($value['status']);

Ditto to above about long form usage.

mrf’s picture

Status: Needs work » Closed (fixed)

Went ahead and made the above changes and committed to 7.x-1.x-dev.

Thanks for the useful addition avr!

avr’s picture

Thanks for the feedback - very helpful!