- Fixed recurring payment cancelation and added error handling
- Made transactions with recurring items recurring - Fixed some bugs in the email receipt code - Added email receipt template to migrated plugins
This commit is contained in:
parent
2c57721e20
commit
b4a45c6ada
4 changed files with 36 additions and 15 deletions
|
|
@ -72,17 +72,28 @@ sub addItem {
|
|||
|
||||
=head2 cancelRecurring ( )
|
||||
|
||||
Cancel a recurring transaction, and calls onCancelRecurring in whatever sku is attached to this transaction.
|
||||
Cancel a recurring transaction, and calls onCancelRecurring in whatever sku is attached to this transaction. If the
|
||||
cancelation fails, returns an error message.
|
||||
|
||||
=cut
|
||||
|
||||
sub cancelRecurring {
|
||||
my ($self) = @_;
|
||||
$self->getPaymentGateway->cancelRecurringPayment($self);
|
||||
my ($item) = $self->getItems;
|
||||
my ($success, $message) = $self->getPaymentGateway->cancelRecurringPayment($self);
|
||||
|
||||
# Handle failed cancelation.
|
||||
unless ($success) {
|
||||
return
|
||||
"Canceling recurring transaction failed. The following response was received from the payment gateway:<br/>"
|
||||
. $message;
|
||||
}
|
||||
|
||||
my ($item) = @{ $self->getItems };
|
||||
$item->getSku->onCancelRecurring($item);
|
||||
my $recurringId = ($self->get('originatingTransactionId') || $self->getId);
|
||||
$self->session->db->write("update transaction set isRecurring=0 where transactionId=? or originatingTransactionId=?",[$recurringId,$recurringId]);
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -606,7 +617,11 @@ sub www_cancelRecurring {
|
|||
my ($class, $session) = @_;
|
||||
my $self = $class->new($session, $session->form->get("transactionId"));
|
||||
return $session->privilege->insufficient unless (WebGUI::Shop::Admin->new($session)->canManage || $session->user->userId eq $self->get('userId'));
|
||||
$self->cancelRecurring;
|
||||
my $error = $self->cancelRecurring;
|
||||
|
||||
# TODO: Needs to be templated or included in www_view.
|
||||
return $error if $error;
|
||||
|
||||
return $class->www_view($session);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue