Hi all,
Posted a couple of times on here in the Coding section, but felt this section was more worthy as I've not worked with PayPal functions before.
I've got a shopping cart that I've adapted the code of to fit the purpose intended but not touched the payment processing code that it came with. Everything works fine, I've tested the payment through Paypal Sandbox and everything completes ok.
However, its not picking up the correct values from my checkout.
It will have the correct value of the goods, but is adding the wrong amount for shipping.
In my database for the shop, the shipping cost is saved under the shop details.
This is then called for when the checkout is opened.
I currently have it set to 2.95 as opposed to 5.00 that is was set to when I installed it.
I've checked the MySQL table and the value is indeed 2.95 and not 5.00 and this is reflected on the total of the order.
So, in short, if my order on the cart is £19.25 when it's sent to paypal, it recognises payment for £21.30
Hopefully, I'll detail relevant code below. Please let me know if I've not supplied enough info.
checkoutConfirmation.php
<tr class="content">
<td colspan="2" align="right">Shipping</td>
<td align="right">
<?php echo displayAmount($shopConfig['shippingCost']); ?> // this is giving correct value
</td>
</tr>
<tr class="content">
<td colspan="2" align="right">Total</td>
<td align="right">
<?php echo displayAmount($shopConfig['shippingCost'] + $subTotal); ?> // this is also giving correct value
</td>
</tr>
payment.php
<?php
/*
This page will submit the order information to paypal website.
After the customer completed the payment they will return to this site
*/
if (!isset($orderId)) {
exit;
}
require_once 'paypal.inc.php';
$paypal['item_name'] = "Blue Marra Purchase";
$paypal['invoice'] = $orderId;
$paypal['amount'] = $orderAmount;
?>
<center>
<p> </p>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="333333">Processing
Transaction . . . </font></p>
</center>
<form action="<?php echo $paypal['url']; ?>" method="post" name="frmPaypal" id="frmPaypal">
<input type="hidden" name="amount" value="<?php echo $paypal['amount']; ?>">
<input type="hidden" name="invoice" value="<?php echo $paypal['invoice']; ?>">
<input type="hidden" name="item_name" value="<?php echo $paypal['item_name']; ?>">
<input type="hidden" name="business" value="<?php echo $paypal['business']; ?>">
<input type="hidden" name="cmd" value="<?php echo $paypal['cmd']; ?>">
<input type="hidden" name="return" value="<?php echo $paypal['site_url'] . $paypal['success_url']; ?>">
<input type="hidden" name="cancel_return" value="<?php echo $paypal['site_url'] . $paypal['cancel_url']; ?>">
<input type="hidden" name="notify_url" value="<?php echo $paypal['site_url'] . $paypal['notify_url']; ?>">
<input type="hidden" name="rm" value="<?php echo $paypal['return_method']; ?>">
<input type="hidden" name="currency_code" value="<?php echo $paypal['currency_code']; ?>">
<input type="hidden" name="lc" value="<?php echo $paypal['lc']; ?>">
<input type="hidden" name="bn" value="<?php echo $paypal['bn']; ?>">
<input type="hidden" name="no_shipping" value="<?php echo $paypal['display_shipping_address']; ?>">
</form>
<script language="JavaScript" type="text/javascript">
window.onload=function() {
window.document.frmPaypal.submit();
}
</script>
Sorry if the code seems sloppy, its just what I'm used too :o
I've also got a paypal.inc.php file which has all the account information in and socket information. I assume I don't need to post this one up cause there's quite a lot of code in it.
Any help, or not enough info?