![]() ![]() * Implements hook_webform_submission_insert(). In my site's custom module (I'm running Drupal 7 - code might need minor adaptations for 6.x), I added two simple hooks, shown below with comments to help define what's going on: I have drupal version 8.5.4 and I want to integrate paypal button which directs users to paypal website where users can submit information and pay to the website. PayPal has relatively robust documentation of it's Website Payments Standard API, and all we need to do is send an HTTP/HTTPS request to PayPal with certain parameters, defining to whom the payment should be sent, what the payment amount is, and some other options (including values sent in via our Webform). The way it works is you create a Paypal button with a drop-down menu with payment options and you copy the buttons ID as usual to create the webform Paypal button. hook_webform_submission_insert() is the perfect time to hook into Webform's process and send a user to PayPal, along with that user's data. I needed the ability to have multiple payment options, so I wrote this patch. However, after reading Additional processing in Drupal's Webform 3 module (from Drupal Coder), I found that Webform 3 has a hook that runs just after webform has saved a form's data to the database, but before the webform returns the user to a predefined redirected page. With older versions of PayPal, one could add some PHP code into a webform on the site to do this, but it was (a) hackish, and (b) a much less maintainable and secure way of accomplishing the goal I was trying to achieve. Drupal Form Builder is an advanced & easy-to-use module for creating submission forms, and is one of the best form builders available for Drupal sites. Add a new field to the content type: Field type: Reference - other. ![]() For quite some time, I've wanted to integrate a particular webform with PayPal, since many nonprofits I help use that payment service. Create a new form: /admin/structure/contact. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |