View Full Version : Deposit order calculation
clvdh
05-18-2009, 06:49 AM
Hi,
I have to do a calculation for the client pays only a deposit of 30% from the total amount of an order.
is what someone would have an idea of how it can be done?
I don't see how to change the "GrandTotal" and pass it to the Paypal gateaway
thank you
Ray Borduin
05-18-2009, 07:53 AM
You can use math to change a number at any point in the process, so getting 30% of a number should be as easy as adding: * 0.3
Maybe the easiest way to do it is on an item by item basis, you can update the existing calculation from:
TotalPrice = Price * Quantity
to:
TotalPrice = Price * Quantity * 0.3
clvdh
05-18-2009, 09:01 AM
Hi Ray,
thank you for your reply,
actually it is a possibility but in this case each product invoice payment and the only option I have cancellation insurance which must take into account the subtotal of the basket.
French laws requires us to be transparent, so the client must know what it would cost in total and what it pays for the deposit
So how ; and ; is it possible to calculate the deposit payment on sub-total addition and send this variable to Paypal
Ray Borduin
05-18-2009, 09:55 AM
Are you using paypal standard or pro?
clvdh
05-18-2009, 09:42 PM
I use Paypal Buisness Pro
Ray Borduin
05-19-2009, 06:07 AM
Both direct pay and express checkout use server behaviors to pass the values to paypal. If you wanted to update the amounts I think you could just update the server behaviors associated with the local checkout on the confirm and pp_confirm pages and add "* 0.3" in the appropriate places where the individual and total prices are passed to paypal.
clvdh
05-20-2009, 01:14 AM
Thanks ; I've done that , but it return the pp_checkout_failure.php
Where I am now :
in the cart page :
for the total order :
<?php echo WA_eCart_DisplayMoney($PIERROT, $PIERROT->GrandTotal()); ?>
for the deposit :
<?php $PIERROT_B = $PIERROT->GrandTotal()*0.3; ?>
<?php echo $PIERROT_B ?></td>
Normaly in the QUERY_STING's form I should have the $PIERROT_B
in the checkout page for the $WA_PP_ECO_SetResult = WA_PP_ECO_SOAPObject(); string :
$WA_PP_ECO_Set_params[0][$nextIndex] = "OrderTotal";
$WA_PP_ECO_Set_params[1][$nextIndex] = "".$PIERROT->GrandTotal()."";
I tried to change the value $WA_PP_ECO_Set_params[1][$nextIndex] = "".$PIERROT->GrandTotal().""; by
$WA_PP_ECO_Set_params[1][$nextIndex] = "".$PIERROT_B."";
and the result is : pp_checkout_failure.php
If I change somethoing on the $PIERROT->GrandTotal(), I got the same result
Do I've to chage something in the PP_ECO_PHP.php ?
How could I input the right value in the $WA_PP_ECO_Set_params[1][$nextIndex] = "".$PIERROT->GrandTotal().""; ?
Thanks a lot
Ray Borduin
05-20-2009, 07:21 AM
You would have to update both the grand total and the individual item totals.
I would want to look at your code to show you where to update it. Are you using shipping, tax, discount, or charge rules of any sort? do those get discounted 30% as well? What you add depends on the very pariticular details of what you want and how your code looks currently.
I would need a detailed description of exactly what you would want, maybe with some samples and I would want to look at the full code block, not just this one line to figure out where it needed to be updated.
Since paypal passes items with the total and validates that the total of the items matches the grand total, you can't just change one number and have it work. You have to be sure your math all adds up at the end for any place values are passed to paypal.
clvdh
05-20-2009, 08:55 AM
Well it will be a long way
Could i send you the files in a personal message ?
Ray Borduin
05-20-2009, 09:13 AM
You can post a submit incident where you can share files privately and post your incident number here and I'll take a look at it.
clvdh
05-20-2009, 09:41 AM
this is the Technical Support Ticket # 95019
hope you will see where i am wrong
regards
clvdh
05-21-2009, 05:34 PM
If it could help, the solution is :
to display the deposit --> a new function in the WA_eCart_Definition_PHP.php
function GrandTotal() {
$grandTotal = 0;
$grandTotal = $this->GetTaxedSubtotal()*0.3;
if (!$this->ShippingIsTaxed) {
$grandTotal += $this->GetShipping();
}
return WA_eCart_FormatNumber($grandTotal, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
function GrandTotalA() {
$grandTotal = 0;
$grandTotal = $this->GetTaxedSubtotal();
if (!$this->ShippingIsTaxed) {
$grandTotal += $this->GetShipping();
}
return WA_eCart_FormatNumber($grandTotal, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
in the cart page :
to display the total
<?php echo WA_eCart_DisplayMoney($PIERROT, $PIERROT->GrandTotalA()); ?>
to display the deposit :
<?php echo WA_eCart_DisplayMoney($PIERROT, $PIERROT->GrandTotal()); ?>
To charge 30% of the cart total, On the pp_confirm.php page,
$WA_PP_ECO_Do_itemized[0][0] = "OrderTotal";
$WA_PP_ECO_Do_itemized[1][0] = "".($PIERROT->GrandTotal() *0.3) + ($PIERROT->GetTax() + $PIERROT->GetShipping()) ."";
Should be:
$WA_PP_ECO_Do_itemized[0][0] = "OrderTotal";
$WA_PP_ECO_Do_itemized[1][0] = "".($PIERROT->TotalColumn("TotalPrice") *0.3) + ($PIERROT->GetTax() + $PIERROT->GetShipping()) ."";
__________________________________________________ _____________
$WA_PP_ECO_Do_itemized[0][$nextIndex] = "Amount" . strval($cartIndex+1) . "";
$WA_PP_ECO_Do_itemized[1][$nextIndex] = "".$PIERROT->DisplayInfo("Price") ."";
to:
$WA_PP_ECO_Do_itemized[0][$nextIndex] = "Amount" . strval($cartIndex+1) . "";
$WA_PP_ECO_Do_itemized[1][$nextIndex] = "".($PIERROT->DisplayInfo("Price") * 0.3) ."";
__________________________________________________ _____________
and:
$WA_PP_ECO_Do_optional[0][$nextIndex] = "ItemTotal";
$WA_PP_ECO_Do_optional[1][$nextIndex] = "".$PIERROT->TotalColumn("TotalPrice") ."";
to:
$WA_PP_ECO_Do_optional[0][$nextIndex] = "ItemTotal";
$WA_PP_ECO_Do_optional[1][$nextIndex] = "".($PIERROT->TotalColumn("TotalPrice") * 0.3) ."";
__________________________________________________ _____________
A great thanks for the WebAssit staff,
specialy for Ray and Jason
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.