News:

Looking for documentation? Take a look on our wiki

Main Menu

vm 1.15 AND PAYPAL PLEASE HELP

Started by thebigman, August 25, 2010, 21:45:51 PM

Previous topic - Next topic

thebigman

Hi
Could some one tell me what the idiots guide is to setting up paypal.  How does VM know what account to pay the money into.  Where do you set it up.

Thanks for any help.  I am sruggling a bit.


xdev

I would need some help with this also. Where can we find more info on setting up paypal on version 1.1.5 stable ?

And another question... If I have a normal, verified paypal account, can I use that with VirtueMart? (I am at the stage of choosing what cart I will use and VirtueMart seems the best so far).

Thanks,

Daniel

AH

xdev and the bigman

questions

1. Are you in the UK
2. Do you charge Tax on goods and is this included in your shopper group pricing (show prices inclusive of TAX)
3. Is this for your test site (localhost) or live site
4. Have you got a "PayPal sandbox" account setup
5. Have you got a "Paypal business standard" account setup

If you answers these I can help you further.



Regards
A

Joomla 4.4.5
php 8.1

thebigman

Yes in the UK
No tax added
live site
yes have a paypal sandbox

have a paypal premier account.

Is this OK.

Thanks

AH

Yep premier account is ok

Premier account is linked to your personal name, and your account name (you) will show up on the payment pages and on the customer receipt.
It's all in how you want to appear to your customers mostly.

A Business account lets you associate a business name with the account instead of just your personal name.

That's really the only significant difference.

So have you configured your PayPal payment type yet?
Regards
A

Joomla 4.4.5
php 8.1

xdev

#5
1. No
2. I do not charge tax.
3. For live site
4. Yes
5. Account Type: Premier, Status: Verified  (What do I have to do to transform this into a Business Account?)


"So have you configured your PayPal payment type yet?" - what do you mean by that? You mean from virtuemart settings?

I hope I can get further help.

AH

This should work for you and save you and others time and effort! :-

Admin/store/payment methods/add new payment method

Payment method form panel
1. Active checked
2. Payment method name = PayPal (can use anything)
3. Code I use pp  you can use what you like
4. class= ps_paypal
5. Payment method type = HTML_formbased  

Hit apply (this will refresh the configuration panel to show the following details that you need to input)

Go to the configuration panel

Configuration panel
1. Test mode = no THIS IS NOT A PAYPAL SANDBOX SETTING!!!
2. Payment e-mail = YOUR paypal email address live or sandbox as required (select the apporpriate URL as needed)
3. Order Status for successful transactions - confirmed
4. Order status for pending - pending payment confirmation
5. Accept verified buyers = No
6. Failed transactions - Up to you, but I use pending

7. Copy the code below into the Payment extra information box:-

Edit out one of the URLs from below to coneect to either the PayPal live or PayPal sandbox as needed.

Live vs Sandbox

Sandox testing URL
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
Live URL
$url = "https://www.paypal.com/cgi-bin/webscr";

You need to change you PayPal e-mail address as well to flip between sandbox and live.
PayPal payment email:
For Live Your business email, which is your login at paypal or
For sandbox Your seller e-mail address if you use paypal sandbox (e.g. seller_12592_biz@xxxx.com). Not your Sandbox login.



<?php
//Choose either live or sandbox from below but not both!
$url "https://www.sandbox.paypal.com/cgi-bin/webscr";
$url "https://www.paypal.com/cgi-bin/webscr";
//end of choice

$order_id $db->f("order_id");
$tax_total $db->f("order_tax") + $db->f("order_shipping_tax");
$discount_total $db->f("coupon_discount") + $db->f("order_discount");
$shipping_inc_tax $db->f("order_shipping") + $db->f("order_shipping_tax");
 
// Query for Order Items
$dboi = new ps_DB;
$q_oi "SELECT * FROM #__vm_order_item ";
$q_oi .= "WHERE #__vm_order_item.order_id='$order_id'";
$dboi->query($q_oi);
 
$row_num $dboi->num_rows();
 
//Getting Cart Items
$auth $_SESSION['auth'];
$cart $_SESSION['cart'];
$t_quantity 0;
$disc_perItem 0;
$i=1;
 
// Query to get User Info
$dbb = new ps_DB;
$q "SELECT * FROM #__vm_user_info ";
$q .= "WHERE user_id ='".$my->id."' ";
$dbb->setQuery($q);
$dbb->query();
 

//query to optain product attributes
while($dboi->next_record()) {
 
  
$prod_attrib $dboi->f("product_attribute");
  
$supp_var['item_name_' $i] = strip_tags("Order #"$db->f("order_id").": "$dboi->f("order_item_name"));
 
  if(
$prod_attrib ''){
    
$attributes_array explode('<br/>',$prod_attrib);
    
$v 0;
    
$z 1;
    foreach ( 
$attributes_array as $attributes_value){
      
$attrib_name trim(substr($attributes_value0strpos($attributes_value':')), " ");
      
$supp_var['on' $z '_' $i] = $attrib_name;
      
$attrib_sel trim(substr_replace(substr_replace($attributes_value""0strrpos($attributes_value':')), ""02));
      
$supp_var['os' $z '_' $i] = $attrib_sel;
      
$v++;
      
$z++;
      unset(
$attributes_value);
    }
  }
 
  
$supp_var['item_number_' $i] = $dboi->f("order_item_sku");
  
$supp_var['quantity_' $i] = $dboi->f("product_quantity");
//  $supp_var['amount_' . $i] = round(($dboi->f("product_item_price") - $disc_perItem),2);
$supp_var['amount_' $i] = round($dboi->f("product_final_price"),2);
  
$i++;
}
 
 
//Query used to find whether to use Bill Address or Ship to address
$dboui = new ps_DB;
$q_oui "SELECT * FROM #__vm_order_user_info ";
$q_oui .= "WHERE #__vm_order_user_info.order_id='$order_id' ORDER BY #__vm_order_user_info.order_info_id DESC";
$dboui->query($q_oui);
 
$oui_id $dboui->f("order_info_id");
 
if(
$oui_id == $order_id){
  
$first_name $dbb->f("first_name");
  
$last_name $dbb->f("last_name");
  
$address1 $dbb->f("address_1");
  
$address2 $dbb->f("address_2");
  
$city $dbb->f("city");
  
$state $dbb->f("state");
  
$address_country $dbbt->f("country");
  
$zip $dbb->f("zip");
  
$H_PhoneNumber $dbb->f("phone_1");
}
else {
  
$first_name $dboui->f("first_name");
  
$last_name $dboui->f("last_name");
  
$address1 $dboui->f("address_1");
  
$address2 $dboui->f("address_2");
  
$city $dboui->f("city");
  
$state $dboui->f("state");
  
$address_country $dboui->f("country");
  
$zip $dboui->f("zip");
  
$H_PhoneNumber $dboui->f("phone_1");
}
 
// Builds array for the form
$post_variables = Array(
"cmd" => "_cart",
"upload" => "1",
"page_style" => "paypal",
"business" => PAYPAL_EMAIL,
"currency_code" => $_SESSION['vendor_currency'],
"amount" => round$db->f("order_total"),2),
"handling_cart" => $shipping_inc_tax,
//"tax_cart" => $tax_total,
"discount_amount_cart" => $discount_total,
"invoice" => $db->f("order_number"),
"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),
"notify_url" => SECUREURL ."notify.php",
"cancel_return" => SECUREURL ."index.php",
"no_shipping" => "1",
"no_note" => "1",
"email" => $dbb->f("user_email"),
"address_override" => "1",//change this to 0 if you have - Paypal does not allow your country of residence to ship to the country you wish to - errors
"first_name" => $first_name,
"last_name" => $last_name,
"address1" => $address1,
"address2" => $address2,
"city" => $city,
"state" => $state,
"address_country" => $address_country,
"zip" => $zip,
"night_phone_b" => $H_PhoneNumber
);
//add and send the new variables
if( $page == "checkout.thankyou" ) {
  
$query_string "?";
 
  foreach( 
$post_variables as $name => $value ) {
    
$query_string .= $name"=" urlencode($value) ."&";
  }
 
  if(
is_array($supp_var) && count($supp_var)) {
    foreach(
$supp_var as $name => $value) {
      
$query_string .= $name"=" urlencode($value) ."&";
    }
  }
 
  
vmRedirect$url $query_string );

else {
  echo 
'<form action="'.$url.'" method="post" target="_blank">';
 
  foreach( 
$post_variables as $name => $value ) {
    echo 
'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
  }
 
  if(
is_array($supp_var) && count($supp_var)) {
    foreach(
$supp_var as $name => $value) {
      echo 
'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
    }
  }
  echo 
'<input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/x-click-but6.gif" border="0" alt="Make payments with PayPal, it is fast, free, and secure!">';
//Change the above image url for different languages and countries
  
echo '</form>';
}
?>




I secure my administrator directory so IPN might fail.

To enable IPN notifications to update the status of the order. I creat a notify.php
administrator/components/com_virtuemart/notify.php in the ROOT directory of the site

with the following code in:-

I just created a notify.php with this code in

<?php
include('administrator/components/com_virtuemart/notify.php');
?>


The line in the code above that realates to this is:-

"notify_url" => SECUREURL ."notify.php",
If you do not wish to do this, then change the line to this:-
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",


Let me know if this helps.

If this saves you time and effort, Please feel free to donate a small amount to help me feed myself.

Regards
A

Joomla 4.4.5
php 8.1

AH

xdev

Glad I was able to save you some time and effort.

It took me ages to figure this out, I started off using the extra info from a post in here, but had to modify to have something that looked correct for my UK customers. All the other ones were Americanised.

Correct on the Live vs Sandbox

Sandox testing URL
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr";

Live URL
$url = "https://www.paypal.com/cgi-bin/webscr";

You will also need to change you PayPal e-mail address as well to flip between sandbox and live.



Regarding the return URL:-
Change the URL as required

Keep the SECUREURL part below and drop the http://www. or https://www. element of the URL you want)

"return" => SECUREURL ."URL REQUIRED",


Success:-
If you change this your customer will not be directed to the successful order page

"return" => SECUREURL ."index.php?option=com_virtuemart&page=checkout.result&order_id=".$db->f("order_id"),

Cancelled

"cancel_return" => SECUREURL ."index.php",


Note in the extra info code you took from above:-

I secure my administrator directory so IPN might fail.

To enable IPN notifications to update the status of the order. I copy the
administrator/components/com_virtuemart/notify.php to the ROOT directory of the site

The line in the code above that realates to this is:-

"notify_url" => SECUREURL ."notify.php",
If you do not wish to do this, then change the line to this:-
"notify_url" => SECUREURL ."administrator/components/com_virtuemart/notify.php",


Feel free to Donate below.
Regards
A

Joomla 4.4.5
php 8.1

AH

I just created a notify.php with this code in

<?php
include('administrator/components/com_virtuemart/notify.php');
?>


I will amend my instructions above
Regards
A

Joomla 4.4.5
php 8.1

maxifus

Thanks Hutson!!!

I was able to configure paypal after reading your post... finally!

But now, IPN isn't working form me. I can process all payments via Sandbox but I can't get my orders confirmed if payment is succesfull.

Also, if the payment isn't succesfull, when I return to my site my cart is empty :(

Do you know what may be happening?

Regards,
Max

AH

Your cart will always be empty when returning from Paypal regardless of the success or failure of payment.

Try the notify.php for IPN and ensure you have IPN configured in your PayPal account
Regards
A

Joomla 4.4.5
php 8.1

IntraX

Quote from: maxifus on September 24, 2010, 22:15:05 PM

Also, if the payment isn't succesfull, when I return to my site my cart is empty :(


Last time I checked this function the order is yet still there, it is standing at "pending", so people can look up the order details page and see a paypal button there. At any point they can do the payment again or you can also add alternative payments options like wire transfer data somewhere. When they pay alternatively you can set the status to confirmed manually then.

AH

IntraX

They can only review an order f they have registered an account.  I doubt this happens very often!!
Regards
A

Joomla 4.4.5
php 8.1

IntraX

Isnt it that whenever you make an order without account you still get the link "To review your order click here" and the page and also in the confirmation mail from the shop? Yet they have no account to go to but can review the order and the same link also appears in the html version of the mail when using paypal (maybe this was a hack but as far I remember you can still review your order, also when no account is present)