revbank/plugins/unlisted
2022-06-11 18:51:26 +02:00

33 lines
886 B
Perl

#!perl
HELP1 "unlisted" => "Buy unlisted product (manual entry)";
sub command :Tab(unlisted,donate) ($self, $cart, $command, @) {
$command eq 'unlisted' or $command eq 'donate' or return NEXT;
$self->{command} = $command;
return "Price", \&amount;
}
sub amount($self, $cart, $arg, @) {
$self->{amount} = parse_amount($arg) or return REJECT, "Invalid amount.";
if ($self->{command} eq 'donate') {
$cart
->add(-$self->{amount}, "Donation (THANK YOU!)")
->add_contra("+donations", +$self->{amount}, "Donation by \$you");
return ACCEPT;
}
return "Please provide a short description", \&description;
}
sub description($self, $cart, $desc, @) {
$cart
->add(-$self->{amount}, "Unlisted: $desc")
->add_contra("+sales/unlisted", +$self->{amount}, "Unlisted: $desc by \$you");
return ACCEPT;
}