Don't refund transactionItems unless the transaction is successful, or if the item is already canceled. Also, no not call onCancelRecurring for normal Sku's unless they're really recurring. Fixes bug #12089.
This commit is contained in:
parent
8f687d8aa5
commit
8525e4b7ee
7 changed files with 173 additions and 5 deletions
|
|
@ -2588,6 +2588,21 @@ sub purgeCache {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 refused ( )
|
||||
|
||||
Returns an error message to the user, wrapped in the user's style. This is most useful for
|
||||
handling UI errors. Privilege errors should be still be sent to $session->privilege.
|
||||
|
||||
=cut
|
||||
|
||||
sub refused {
|
||||
my ($self) = @_;
|
||||
return $self->{_session};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ( )
|
||||
|
|
|
|||
|
|
@ -564,7 +564,9 @@ The WebGUI::Shop::TransactionItem being refunded.
|
|||
|
||||
sub onRefund {
|
||||
my ($self, $item) = @_;
|
||||
$self->onCancelRecurring($item);
|
||||
if ($self->isRecurring) {
|
||||
$self->onCancelRecurring($item);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1020,8 +1020,8 @@ Refunds a specific item from a transaction and then issues shop credit.
|
|||
sub www_refundItem {
|
||||
my ($class, $session) = @_;
|
||||
return $session->privilege->insufficient unless (WebGUI::Shop::Admin->new($session)->canManage);
|
||||
my $self = $class->new($session, $session->form->get("transactionId"));
|
||||
my $form = $session->form;
|
||||
my $self = $class->new($session, $form->get("transactionId"));
|
||||
my $item = eval { $self->getItem($form->get("itemId")) };
|
||||
if (WebGUI::Error->caught()) {
|
||||
$session->errorHandler->error("Can't get item ".$form->get("itemId"));
|
||||
|
|
|
|||
|
|
@ -145,15 +145,20 @@ sub getSku {
|
|||
|
||||
=head2 issueCredit ( )
|
||||
|
||||
Returns the money from this item to the user in the form of in-store credit.
|
||||
Returns the money from this item to the user in the form of in-store credit. Items marked
|
||||
cancelled cannot be refunded.
|
||||
|
||||
=cut
|
||||
|
||||
sub issueCredit {
|
||||
my $self = shift;
|
||||
return if $self->get('orderStatus') eq 'Cancelled';
|
||||
return unless $self->transaction->isSuccessful;
|
||||
my $credit = WebGUI::Shop::Credit->new($self->transaction->session, $self->transaction->get('userId'));
|
||||
$credit->adjust(($self->get('price') * $self->get('quantity')), "Issued credit on sku ".$self->get('assetId')." for transaction item ".$self->getId." on transaction ".$self->transaction->getId);
|
||||
$self->getSku->onRefund($self);
|
||||
if (my $sku = eval {$self->getSku}) {
|
||||
$sku->onRefund($self);
|
||||
}
|
||||
$self->update({orderStatus=>'Cancelled'});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue