Joomla https://imrodmartin.com/ en How to Use RSForm! Pro for PayPal Recurring Donations https://imrodmartin.com/blog/joomla/how-use-rsform-pro-paypal-recurring-donations <span class="field field--name-title field--type-string field--label-hidden">How to Use RSForm! Pro for PayPal Recurring Donations</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">Rod</span></span> <span class="field field--name-created field--type-created field--label-hidden">Wed, 03/25/2015 - 09:43</span> <div class="layout layout--onecol"> <div class="layout__region layout__region--content"> <div class="field-blocknodeprovus-blogfield-provus-media-image block block-layout-builder block-field-blocknodeprovus-blogfield-provus-media-image"> <div class="content"> <div class="field field--name-field-provus-media-image field--type-entity-reference field--label-hidden field__item"> <img src="/sites/default/files/styles/provus_landscape_large/public/2022-09/SafariScreenSnapz069.jpg?h=fe23adcd&amp;itok=9s7ejdFl" width="1600" height="500" alt="Donations and Membership" loading="lazy" typeof="foaf:Image" class="image-style-provus-landscape-large" /> </div> </div> </div> <div class="extra-field-blocknodeprovus-blogcontent-moderation-control block block-layout-builder block-extra-field-blocknodeprovus-blogcontent-moderation-control"> <div class="content"> </div> </div> </div> </div> <div class="layout layout--twocol-section layout--twocol-section--50-50"> <div class="layout__region layout__region--first"> <div class="field-blocknodeprovus-blogfield-provus-publish-date block block-layout-builder block-field-blocknodeprovus-blogfield-provus-publish-date"> <div class="content"> <div class="field field--name-field-provus-publish-date field--type-datetime field--label-hidden field__item"><time datetime="2015-03-25T12:00:00Z" class="datetime">Wednesday, March 25, 2015</time> </div> </div> </div> </div> <div class="layout__region layout__region--second"> <div class="field-blocknodeprovus-blogfield-blog-categories block block-layout-builder block-field-blocknodeprovus-blogfield-blog-categories"> <div class="content"> <div class="field field--name-field-blog-categories field--type-entity-reference field--label-hidden field__item"><a href="/blog/joomla" hreflang="en">Joomla</a></div> </div> </div> </div> </div> <div class="layout layout--onecol"> <div class="layout__region layout__region--content"> <div class="field-blocknodeprovus-blogbody block block-layout-builder block-field-blocknodeprovus-blogbody"> <div class="content"> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I had a friend ask if I could create a donation/membership page for their non-profit using PayPal.  The site is built in Joomla! 3.x so I naturally thought of an excellent extension like <a href="https://www.joomdonation.com" rel="noopener noreferrer" target="_blank">JoomDonation</a>.  However, they wanted a number of tweaks that meant modifying the extension which I hesitate to do.  Enter <a href="https://www.rsjoomla.com/joomla-extensions/joomla-form.html" rel="noopener noreferrer" target="_blank">RSForm! Pro</a>.  It's pretty much been my go-to form builder on any Joomla! site I've built over the years.</p> <p> </p> <h3>Basic View:</h3> <div style="display:block"> <div> <div class="field field--name-field-media-image field--type-image field--label-visually_hidden"> <div class="field__label visually-hidden">Image</div> <div class="field__item"> <img loading="lazy" src="/sites/default/files/styles/image_full_width/public/2022-09/SafariScreenSnapz069.jpg?itok=6ZVTqkKA" width="1200" height="1247" alt="Donations and Membership" typeof="foaf:Image" class="image-style-image-full-width" /></div> </div> </div> </div> <h3> Requirements:</h3> <ul><li>Select a pre-set amount or enter a custom donation amount.</li> <li>One-Time or Recurring donations (recurring donations required a PayPal account - users would manage them there...)</li> <li>Recurring Donations on a Monthly, Quarterly, Semi-Annual or Annual basis.</li> <li>Recurring donations would be empty for on-going donations, or at least 2, since 1 throws an error at PayPal.  (RSForm has a "range" validation feature).</li> <li>Clean looking.</li> <li>If you clicked on the Custom Donation Amount a field appears, allowing the amounts to be a required field, even if a donor chose the custom option.</li> </ul><h3>Code: (download at the bottom of the article)</h3> <p>The magic happens upon form submission.  The php tests for all the variables then sends the appropriate link to PayPal. (Please don't write to me and tell me my code could be improved... I know it could. - I haven't done any coding in years lol).</p> <pre> /*Recurring Donation */ if ($_POST['form']['recurring'] == 'Recurring') { $business = '<a href="mailto:design@navigatetomorrow.com'">design@navigatetomorrow.com'</a>;; /* getting the donation name */ if ($_POST['form']['other'][0] != '') {$item_name = str_replace($replace, $with, 'Custom Amount');} if ($_POST['form']['membership'][0] != '0') {$item_name = str_replace($replace, $with, '{membership:text}');} /* getting the donation amount */ if ($_POST['form']['membership'][0] != '0') {$total = str_replace($replace, $with, '{membership:value}');} /* getting duration and frequency for PayPal */ $duration = str_replace($replace, $with, '{duration:value}'); $frequency = str_replace($replace, $with, '{frequency:value}'); if ($frequency == 'Q') {$p3 = '3'; $t3 ='M';} if ($frequency == 'Y') {$p3 = '1'; $t3 = 'Y';} if ($frequency == 'S') {$p3 = '6';$t3 ='M';} if ($frequency == 'M') {$p3 = '1';$t3 ='M';} /* PayPal variables set */ $currency_code = 'USD'; $a3 = $total; $src = '1'; $srt = $duration; $no_note = '1'; /* upon successful completion of the donation, RSForm will update the status from Pending to Accepted */ $notify_url = JURI::root().'index.php?option=com_rsform&amp;formId='.$formId.'&amp;submission='.$SubmissionId; $url= '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&amp;business='.urlencode">https://www.paypal.com/cgi-bin/webscr?cmd=_xclick-subscriptions&amp;business='.urlencode</a>($business).'&amp;item_name='.urlencode($item_name).'&amp;currency_code='.urlencode($currency_code).'&amp;a3='.urlencode($a3).'&amp;p3='.urlencode($p3).'&amp;t3='.urlencode($t3).'&amp;src='.urlencode($src).'&amp;srt='.urlencode($srt).'&amp;no_note='.urlencode($no_note).'&amp;notify_url='.urlencode($notify_url); $app = JFactory::getApplication(); $app-&gt;redirect($url); exit(); }</pre> <pre> /* One Time Donation */ if ($_POST['form']['recurring'] == 'One Time') { if ($_POST['form']['membership'][0] != '') {$item_name = str_replace($replace, $with, '{membership:text}');} if ($_POST['form']['other'][0] != '') {$item_name = str_replace($replace, $with, 'Custom Amount');} if ($_POST['form']['other'][0] != '') {$total = str_replace($replace, $with, '{other:value}');} if ($_POST['form']['membership'][0] != '0') {$total = str_replace($replace, $with, '{membership:value}');} $currency_code = 'USD'; $a3 = $total; $p3 = '0'; $t3 = '1'; $src = '0'; $no_note = '1'; $notify_url = JURI::root().'index.php?option=com_rsform&amp;formId='.$formId.'&amp;submission='.$SubmissionId; $url='<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=design">https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=design</a>@navigatetomorrow.com&amp;item_name=One+Time+Donation&amp;amount=' .$total .'&amp;currency_code=USD&amp;notify_url='.urlencode($notify_url); $app = JFactory::getApplication(); $app-&gt;redirect($url); exit(); }</pre> <h3>Test It Out</h3> <p>Feel free to test out the form - you can even send a donation if you'd like :) {rsform 4}</p> <h3>Download</h3> <p>To use this code you must have a Joomla 3.x website (minimum) and a copy of RSForm! Pro.</p> <p><a href="/images/downloads/donations-memberships-rsformpro.tgz" rel="noopener noreferrer" target="_blank">Downloa</a>d</p> </div> </div> </div> <div class="extra-field-blocknodeprovus-blogaddtoany block block-layout-builder block-extra-field-blocknodeprovus-blogaddtoany"> <div class="content"> <span class="a2a_kit a2a_kit_size_32 addtoany_list" data-a2a-url="https://imrodmartin.com/blog/joomla/how-use-rsform-pro-paypal-recurring-donations" data-a2a-title="How to Use RSForm! Pro for PayPal Recurring Donations"><a href="#" class="a2a_button_facebook"><span class="a2a_label">Share this on Facebook</span></a><a href="#" class="a2a_button_twitter"><span class="a2a_label">Share this on Twitter</span></a><a href="#" class="a2a_button_linkedin"><span class="a2a_label">Share this on LinkedIn</span></a><a href="#" class="a2a_button_email"><span class="a2a_label">Share this on Email</span></a><a href="#" class="a2a_button_print"><span class="a2a_label">Print this</span></a></span> </div> </div> </div> </div> Wed, 25 Mar 2015 13:43:17 +0000 Rod 24 at https://imrodmartin.com