Index: payment/ps_paypal.php @@ -260,7 +260,7 @@ $fields = array( 'charset' => $pp_charset, - 'cmd' => "_ext-enter", + 'cmd' => "_cart", 'custom' => $order_secureid, 'invoice' => $pp_ordr, 'redirect_cmd' => '_xclick', @@ -273,9 +273,10 @@ 'last_name' => $bill_lastname, 'business' => $pp_acc, 'amount' => $pp_total, - 'tax_cart' => 0, - 'shipping' => 0, - 'handling' => 0, + 'tax_cart' => func_paypal_convert_to_BasicAmountType($cart["tax_cost"], $pp_curr), + 'shipping' => func_paypal_convert_to_BasicAmountType($cart["shipping_cost"], $pp_curr), + 'handling_cart' => func_paypal_convert_to_BasicAmountType(($cart["need_giftwrap"] == 'Y' ? $cart["taxed_giftwrap_cost"] : 0), $pp_curr), + 'discount_amount_cart' => func_paypal_convert_to_BasicAmountType($cart["giftcert_discount"] + $cart["discount"] + $cart["coupon_discount"], $pp_curr), 'weight_cart' => 0, 'currency_code' => $pp_curr, 'return' => $_location."/payment/ps_paypal.php?mode=success&secureid=$order_secureid", @@ -304,6 +305,39 @@ if ($module_params['use_preauth'] == 'Y') $fields['paymentaction'] = 'authorization'; + # NOTE: Updated, version (http://forum.x-cart.com/showthread.php?t=57734). No product quantity limitation. + # The shipping cost for the whole order goes with the first product. + # This has been done to avoid rounding problems at PayPal and keep correct totals. + $__pp_products_html = ""; $__pp_total_cost = 0; $__pp_counter = 1; + foreach ($cart['products'] as $__pp_product) { + $__pp_products_html .= ""; + $__pp_products_html .= ""; + $__pp_products_html .= ""; + $__pp_products_html .= "\n"; + $__pp_total_cost += func_paypal_convert_to_BasicAmountType($__pp_product['display_price'], $pp_curr) * func_paypal_convert_to_BasicAmountType($__pp_product['amount'], $pp_curr); + $__pp_counter++; + } + + # Gift Certificate(s) + if (isset($cart['giftcerts']) && !empty($cart['giftcerts'])) { + foreach ($cart['giftcerts'] as $__cert) { + $__pp_products_html .= ""; + $__pp_products_html .= ""; + $__pp_products_html .= ""; + $__pp_products_html .= ""; + $__pp_products_html .= ""; + $__pp_products_html .= "\n"; + $__pp_total_cost += func_paypal_convert_to_BasicAmountType($__cert['amount'], $pp_curr); + $__pp_counter++; + } + } + + $fields['discount_amount_cart'] = abs(func_paypal_convert_to_BasicAmountType($fields['discount_amount_cart'] + ($pp_total - $__pp_total_cost - $fields['tax_cart'] - $fields['shipping'] - $fields['handling_cart'] - $fields['discount_amount_cart']), $pp_curr)); + + if ($__pp_products_html) { + $fields['ext_order_info_html'] = $__pp_products_html; + } + x_load('user'); $areas = func_get_profile_areas(empty($login) ? 'H' : 'C'); Index: skin/common_files/payments/payment_form.tpl @@ -4,7 +4,11 @@ *}
{foreach from=$fields key=fn item=fv} - +{if $fn eq "ext_order_info_html"} + {$fv} +{else} + +{/if} {/foreach} {if $autosubmit}