($ML{'error.noremote'}) unless $remote; my $authas = $GET{'authas'} || $remote->{'user'}; my $u = LJ::get_authas_user($authas); return $err->($ML{'error.invalidauth'}) unless $u; if ($u->{'statusvis'} eq "S") { $title = "Suspended Account"; $body = ""; return; } # find out how much we owe them my $get_amt = sub { my $rowct = shift; my $amt = 0; if ($rowct > 10) { $amt += 0.50*10; $amt += 0.25*($rowct-10); } else { $amt += 0.50*$rowct; } $amt = 25.00 if $amt > 25.00; return $amt; }; # print dollars my $damt = sub { sprintf("\$%.02f", shift()) }; my $dbh = LJ::get_db_writer(); unless (LJ::did_post()) { # authas switcher form $body .= "
\n"; $body .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'} }) . "\n"; $body .= "
\n\n"; my $rowct = $dbh->selectrow_array("SELECT COUNT(*) FROM acctcode WHERE userid=? AND rcptid=0", undef, $u->{'userid'}); unless ($rowct > 0) { $body .= ""; return; } my $amt = $get_amt->($rowct); $body .= ""; $body .= "LiveJournal "; $body .= "Store. p?>"; $body .= "($amt) . ". p?>"; $body .= "$u->{'email'}. Please be sure this email "; $body .= "address is correct. p?>"; my $getextra = $authas ne $remote->{'user'} ? "?authas=$authas" : ''; $body .= "
"; $body .= "

"; $body .= LJ::html_submit(undef, "Generate Coupon", { 'disabled' => $amt <= 0 }); $body .= "

"; return; } my $system_id = LJ::get_userid("system") or die; my $rowct = $dbh->do("UPDATE acctcode SET rcptid=? WHERE userid=? AND rcptid=0", undef, $system_id, $u->{'userid'}); unless ($rowct > 0) { $body = ""; return; } my $amt = $get_amt->($rowct); my ($tokenid, $token) = LJ::Pay::new_coupon('dollaroffint', $amt, $u->{'userid'}, 0); return "" unless $tokenid && $token; # send the coupon to the user in an email LJ::Pay::send_coupon_email($u, $token, $amt, "int"); # log to statushistory LJ::statushistory_add($u->{'userid'}, $remote->{'userid'}, "invitecp", "generated " . $damt->($amt) . " intangible coupon ($token) for " . "$rowct invite codes"); $body = "($amt) . " in exchange for your $rowct invite codes. p?>"; return; } _code?> body=> page?>