Add "donate" command

This commit is contained in:
Juerd Waalboer 2019-01-02 17:36:22 +01:00
parent 9ef84285a4
commit 3e49346bc5

View file

@ -2,15 +2,23 @@
HELP "unlisted" => "Buy unlisted product (manual entry)";
sub command :Tab(unlisted) {
sub command :Tab(unlisted,donate) {
my ($self, $cart, $command) = @_;
$command eq 'unlisted' or return NEXT;
$command eq 'unlisted' or $command eq 'donate' or return NEXT;
$self->{command} = $command;
return "Amount to deduct from your account", \&amount;
}
sub amount {
my ($self, $cart, $arg) = @_;
$self->{amount} = parse_amount($arg) or return REJECT, "Invalid amount.";
if ($self->{command} eq 'donate') {
$cart->add(undef, -$self->{amount}, "Donation (THANK YOU!)");
return ACCEPT;
}
return "Please provide a short description", \&description;
}