Committer: gariev
LJSUP-7675: recbill not crediting properly when enrolling, <1 month is needed and floor trim is appliedU trunk/cgi-bin/LJ/Pay/Payment.pm U trunk/ssldocs/manage/account/cc.bml
Modified: trunk/cgi-bin/LJ/Pay/Payment.pm =================================================================== --- trunk/cgi-bin/LJ/Pay/Payment.pm 2010-12-23 10:04:21 UTC (rev 9888) +++ trunk/cgi-bin/LJ/Pay/Payment.pm 2010-12-24 09:42:26 UTC (rev 9889) @@ -1230,6 +1230,9 @@ # have to set payitem and payment amounts to 0 so we don't mess up stats _debug("get items"); foreach my $it ($self->get_items) { + ## remember the old amount, and set it to zero + my $piid = $it->get_piid; + $self->payvar_add("amount_before_floor:$piid", $it->get_amt()); _debug(Dumper($it)); $it->set_amt(0); _debug("set_amt: $@"); Modified: trunk/ssldocs/manage/account/cc.bml =================================================================== --- trunk/ssldocs/manage/account/cc.bml 2010-12-23 10:04:21 UTC (rev 9888) +++ trunk/ssldocs/manage/account/cc.bml 2010-12-24 09:42:26 UTC (rev 9889) @@ -114,6 +114,7 @@ # escape hatch my $die = sub { $err = shift; + warn $err; if ( shift ) { LJ::Pay::release_lock($u); } if ( my $pmt = shift ) { $pmt->payvar_set('rec_apply_error', $err); } last FOO; @@ -381,16 +382,16 @@ # the account is now created/updated # charge the card. my $finish_pmt = 1; + if ($pmt->get_amount > 0) { $finish_pmt = 0; - $rv = eval {$rec->account_capture($pmt, undef, $requestID, $requestToken) } or $die->(BML::ml('.error.cantsetupaccount', {'aopts' => "href='$LJ::SITEROOT/support/'", 'errormsg' => $@}), 1); $finish_pmt = 1 if LJ::Pay::Payment->authcap_is_success($rv); } - + if ($finish_pmt) { # mark payment as complete $pmt->mark_complete(); @@ -403,12 +404,24 @@ sort { $a->sort_order <=> $b->sort_order } $pmt->get_items() ){ - ## Without the 'next' below, the following use case is wrong: - ## user has maunal paidaccount expiring in 6 months, user buys recbill paidaccout with 2 month interval, - ## price=0, and after delivery paidaccount expires in 2 monthes. - ## However, userpics must be delivered even if their price==0 to do their resize - next if $pit->get_amt <= 0 && $pit->item ne 'userpic_large'; + if ($pit->get_amt <= 0) { + ## two cases: + ## 1. the amount==0 due to LJ::Pay::Payment->insure_floor_amount() method + ## if so, the item must be delivered + ## 2. the amount==0 because user has more paid time then the next check date + + ## Without the 'next' below, the following use case is wrong: + ## user has maunal paidaccount expiring in 6 months, user buys recbill paidaccout with 2 month interval, + ## price=0, and after delivery paidaccount expires in 2 monthes. + ## However, userpics must be delivered even if their price==0 to do their resize + my $piid = $pit->get_piid; + my $amount_before_floor = $pmt->payvar_get("amount_before_floor:$piid"); + if ($amount_before_floor <= 0 && $pit->item ne 'userpic_large') { + next; + } + } + # we don't set "invite" as recbillable item next if $pit->get_item eq 'invite';