Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

3 ways to create a small Joomla! shopping cart with RSForm!Pro and PayPal - payment confirmation

04 Jul 2011

3 ways to create a small Joomla! shopping cart with RSForm!Pro and PayPal - payment confirmation

Posted by. Mihaela This article was posted in RSForm!Pro Tagged with forms , PayPal
HomePrintE-mail

RSForm!Pro with PayPal integration

When we first started to write this article, we were planning to structure it as a 3 part series.
Yet, our readers' feedback has determined us to write the 4th part of the article, to further analyze the payment process, once the user completes the transaction.

While the first 3 articles have coverred the required steps in setting up a small shopping cart with RSForm!Pro, whether by using the PayPal plugin or a given custom script, this article we'll explain how can you receive the payment confirmation right in the RSForm!Pro "Manage submissions" tab.

We're going to extend the custom script used in the 3rd part of the article, to record through a hidden field, the payment status: confirmed or not.

Once the user submits the form and completes the transaction, the RSForm!Pro status field value will be updated as "confirmed". By default, this field is "not confirmed".

Backend preview:

RSForm!Pro Paypal payment confirmation - Joomla! back-end area

You can later check the payment status by accessing the backend Joomla! panel >>Components >> RSForm!Pro >> Manage Submissions.

RSForm!Pro Paypal payment confirmation - manage submissions

The 4th part of the article comes with a new form field (hidden field), that allows us to trigger the payment status. That involves several script changes.

Basically, the steps of creating the PayPal form are as described in the 3rd article.
In this article, we will only show the changes made to the above mentioned script to receive the payment confirmation.

Step 1: Add products, prices and quantities

In addition to the form components described in the previous article (textboxes for the First Name, Last Name, Email Address and Total, checkbox groups for products, dropdown for the quantity), you will need to create a hidden field , used to record the payment status: confirmed or not.

Step 2. Modify form layout

Once you have created the hidden field, head to the RSForm!Pro "Form layout" tab and add, at the end of the HTML code, the corresponding placeholder: {status:body}

Step 3: check the 3rd part of the article

Step 4:

When submitting the form, just before redirecting to PayPal, we need to pass the URL that will receive the confirmation. This will be the direct URL for the form. The new script is as follows:

if($_POST['form']['Total'] != '0')
{
$business = 'me@mybusiness.com';
$item_name = 'Products';
$currency_code = 'USD';
$amount = $_POST['form']['Total'];
$return = JURI::root();
$db = JFactory::getDBO();
$notify = urlencode(JURI::root().'index.php?option=com_rsform&formId='.$db->getEscaped($_POST['form']['formId']).'&submission='.$SubmissionId);
$url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business='.$business.'&item_name='.$item_name.'&currency_code='.$currency_code.'&amount='.$amount.'&return='.$return.'&notify_url='.$notify;
header('Location: '.$url);
exit();
}

Explanations

The new addition is the use of the PayPal notify URL parameter: ¬ify_url . This will simply point back to the form with a parameter that will uniquely identify the submission that is being processed.
Notice the $SubmissionId variable.

Up next, we need to process the confirmation and update the status field. We can easily do this by using the following script, placed in the "Scripts called on form display" area, "Manage forms" tab :

$db = JFactory::getDBO();
$sid = $db->getEscaped(JRequest::getVar('submission'));
if(!empty($sid))
{
$db->setQuery("UPDATE #__rsform_submission_values SET `FieldValue` = 'confirmed' WHERE `SubmissionId` = '".$sid."' AND `FieldName` = 'status'");
$db->query();
die();
}

Explanations

Based on the earlier mentioned $SubmissionId variable, we can identify the submission that is being confirmed and update the value of the status field. Note that the script will be executed only if the submission confirmation is received.

Notice:

You can read more on the RSForm!Pro scripting areas here.

The example is available for download on the www.rsjoomla.com website. Notice that you must have at least RSForm!Pro rev. 36 in order to work.

Once you have downloaded the sample form, head to the Joomla! backend panel >> Components >> RSForm!Pro >>"Backup/Restore" tab and restore the package that you've just downloaded. You will find the Custom PayPal example listed in the RSForm!Pro "Manage Forms" tab.

Download the PayPal example with payment confirmation

Related articles:



Gravatar
LEANNE DOLCE (15.09.2011 (17:12:41))
1 the post back from paypal is not updating the status field. It is taking me back to the site homepage instead.Quote
Gravatar
LEANNE DOLCE (15.09.2011 (17:14:42))
Paypal Script does not post back to form 1 http://www.rsjoomla.com/blog/view/145-3-ways-to-create-a-small-joomla-shopping-cart-with-rsformpro-and-paypal-payment-confirmation.html

the scripts are incorrect on this page. when youdownload the script, those are actually right (I think). The issue is that when I try out the system with paypal sandbox, it posts back to my homepage, not to the form page. and the status field is not being updated though the payment says it went through successfully.
Quote
http://web.napturalroots.com/index.php?option=com_rsform&formId=8
Gravatar
Alexandru Plapana (16.09.2011 (01:50:12))
@LEANNE -1 The scripts have been tasted prior from being posted on the blog. If you are facing difficulties in implementing this, please submit a support ticket, and one of my colleagues will help you out. Quote
http://rsjoomla.com
Gravatar
donia (18.04.2012 (21:56:22))
need help to submit email values Yes No I already have the total going to paypal, just need to have it the values, submitted to emailQuote
Gravatar
Richard Bygrave (09.05.2012 (09:33:14))
Paypal script does not post back to form Yes No I am having the same issue as Leanne. I am using the downlaoded code but it posts back to my homepage not the form.Quote
http://www.rsjoomla.com/blog/view/145-3-ways-to-create-a-small-joomla-shopping-cart-with-rsformpro-and-paypal-payment-confirmation.html
Gravatar
Andrei Cristea (10.05.2012 (02:31:06))
@Richard Yes No Same answer applies... please submit a support ticket and one of my colleagues will help you.Quote
http://rsjoomla.com

1000 Characters left

Antispam Refresh image Case sensitive

Feedback