PayPal Set Up for VirtueMart

How do I install PayPal?
You don’t have to install it. PayPal is a part of the official distribution and installed per default.
You just have to go to “Store” => “Payment method list” and click on “PayPal”.
If you want to know which files are responsible for PayPal:
* /site_root/administrator/components/com_virtuemart/notify.php
This is the script where should post to when a transaction is made. If the transaction was VERIFIED, the order status is usually update to the oder status you have set in the configuration (you can set that for Confirmed, Pending & Failed payments).
* /site_root/administrator/components/com_virtuemart/classes/payment/ps_paypal.php
This is the main class for the paypal configuration. It actually doesn’t play any role on checkout.
* site_root/administrator/components/com_virtuemart/classes/payment/ps_paypal.cfg.php
The configuration file for the paypal settings. Remember that this file must be writable to save changes to the configuration.

How do setup PayPal?
This payment method is to be set up as every other payment method: go to “Store” => “List Payment Methods”, then select “PayPal” from the list. Once the payment method form for PayPal has opened, you can activate/deactivate it, rename it (the name of the payment method doesn’t really matter!), restrict it to a shopper group, define a discount value and change the method’s position in a list with other payment methods (list order).
Please note that there’s an important Configuration Panel, which can be reached by clicking on the Tab Heading “Configuration”.
Test Mode [yes/no; default=no]
When you enable the test mode, you can debug the script using Eliteweaver’s ipn testing environment. Last time I used that, i didn’t worked and didn’t recognize that the script was posting back (I know it did!). This is NOT FOR THE PAYPAL SANDBOX!
PayPal Email
Your business email, which is your login at paypal (or paypal sandbox).
Order Status for confirmed Payments
Order Status for Pending Payments
Order Status for failed Payments

With these settings you can define, which Order Status should be set when a payment was successful / is pending / has failed.
IMPORTANT: PayPal seems to return “Pending” very often, although the payment will be no problem. A further investigation, why the payment is still pending is not made at this time (we’ll have to improve the paypal notify script to check that).
That’s why you see “An error occured while processing your transaction. The status of your order could not be updated“: You obviously haven’t set the Order Status for pending payments to “confirmed”.
Payment Extra Info
The textarea is used by each payment method. You can fill in HTML/PHP/Javascript here. It is executed:
* on the “Thankyou” page
* each time the order is viewed by the customer (and it’s order status is not “confirmed”)
So you can use it to
* process additional affiliate tasks
* show your bank account details
* whatever you want to display to the customer
I have rewritten the Payment Extrainfo Code for PayPal, so i directly redirects the customer to PayPal after clicking on “Confirm” to place the order. Just copy and paste it into your PayPal Extrainfo box.

$db1 = new ps_DB();
$q "SELECT country_2_code FROM #__vm_country WHERE country_3_code='".$user->country."' ORDER BY country_2_code ASC";

$url "";
$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$post_variables = Array(
"cmd" => "_ext-enter",
"redirect_cmd" => "_xclick",
"upload" => "1",
"business" => PAYPAL_EMAIL,
"receiver_email" => PAYPAL_EMAIL,
"item_name" => $VM_LANG->_('PHPSHOP_ORDER_PRINT_PO_NUMBER').": "$db->f("order_id"),
"order_id" => $db->f("order_id"),
"invoice" => $db->f("order_number"),
"amount" => round$db->f("order_subtotal")+$tax_total-$discount_total2),
"shipping" => sprintf("%.2f"$db->f("order_shipping")),
"currency_code" => $_SESSION['vendor_currency'],

"address_override" => "1",
"first_name" => $dbbt->f('first_name'),
"last_name" => $dbbt->f('last_name'),
"address1" => $dbbt->f('address_1'),
"address2" => $dbbt->f('address_2'),
"zip" => $dbbt->f('zip'),
"city" => $dbbt->f('city'),
"state" => $dbbt->f('state'),
"country" => $db1->f('country_2_code'),
"email" => $dbbt->f('user_email'),
"night_phone_b" => $dbbt->f('phone_1'),
"cpp_header_image" => $vendor_image_url,

"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",
"cancel_return" => SECUREURL ."index.php",
"undefined_quantity" => "0",

"test_ipn" => PAYPAL_DEBUG,
"pal" => "NRUBJXESJTY24",
"no_shipping" => "1",
"no_note" => "1"
if( $page == "checkout.thankyou" ) {
$query_string "?";
foreach( $post_variables as $name => $value ) {
$query_string .= $name"=" urlencode($value) ."&";
vmRedirect$url $query_string );
} else {
echo '<form action="'.$url.'" method="post" target="_blank">';
echo '<input type="image" name="submit" src="" border="0" alt="Click to pay with PayPal - it is fast, free and secure!" />';

foreach( $post_variables as $name => $value ) {
echo '<input type="hidden" name="'.$name.'" value="'.htmlspecialchars($value).'" />';
echo '</form>';


If you don’t want your customer to be redirected after confirmation, but still want him to click on “Pay with PayPal”, change

if( $page == "checkout.thankyou" ) {


if( false ) {

Don’t forget to save all your changes.  Roll Eyes
Common Questions
My PayPal doesn’t work. What’s wrong?
It could be anything. Please review your settings and read the other Questions/Answers.
How can I use the PayPal Sandbox for debugging my PayPal Payment Method?
This is really easy: you just need to change the payment extrainfo in the payment method form for PayPal:

$url = "";


$url = "";

I’m getting the message “An error occured while processing your transaction. The status of your order could not be updated.” when returning from PayPal.
Please be careful before you blame VirtueMart.
There are many reasons why this message could be displayed.

  • Your script can’t be reached from the internet
    It’s important that your notify.php is not protected by .htaccess files (which is the case when you secure your /administrator directory).
    Try to point to it with your browser.
  • There’s a parsing error in your script.
    If you have no idea why things go wrong, do the following:
    * Enable Debug Mode
    * Go to and debug your script.
    * Click on “Follow IPN” after you have clicked on “Submit IPN” to see the real debug output of your notify.php script
  • Your Payment returned the payment status “Pending” or “Failed”.
    When you have a pending or failed payment, the notify.php script changes the order status to whatever you have set in the paypal configuration for it. BUT: if this isn’t “confirmed”, you will see this error message.

How can I change the return page?
The file behind that default return page is
You can also change the return page in the payment extrainfo in the payment method form for PayPal or set your own Notify URL in your PayPal Account.
I hope that clears it a little bit.