Hi,
I know that Bursar is the way, but I have urgent customer request to
introduce discount codes. The code in Satchmo is just working and
properly applying discounts, with one strange exception of PayPal
module. It just passes prices to the gateway, without discounts
applied.
Because it's first time I'm dealing with discounts, and it's hard to
believe that such a feature doesn't work with so popular gateway, I
kindly ask you to CORRECT ME IF I'M REINVENTING THE WHEEL ;)
The problem, I think, is here:
apps/payment/templates/shop/checkout/paypal.html:63:
<input type="hidden" name="amount_{{forloop.counter}}"
value="{{item.unit_price|truncate_decimal:2}}" />
The discounts are not included and base price is passed to PayPal.
Changing item.unit_price to item.sub_total also wouldn't work with the
quantity.
To correct this behavior, I made a patch (
http://bitbucket.org/
chris1610/satchmo/changeset/9838081afd30/), which "flattens"
discounts.
What does it mean?
Basically, every discounted item with a discount is, basing on the
quantity and discount amount, divided into 3 or less items:
1. items which are free (unit_price * quantity < discount)
2. items which are to be paid partially
3. items with full price
For example, ordering 4 Books, $6 each, with $8 discount, the
flattened item list will contain:
1 Book for $0.00
1 Book for $4.00
2 Books for $6.00
And this list is going to be passed to PayPal.
How about this?
--
michal