added recurring transaction cancellation handling
This commit is contained in:
parent
e67699e019
commit
54146e32a5
5 changed files with 91 additions and 1 deletions
|
|
@ -17,6 +17,8 @@ package WebGUI::Asset::Sku;
|
|||
use strict;
|
||||
use Tie::IxHash;
|
||||
use base 'WebGUI::Asset';
|
||||
use WebGUI::International;
|
||||
use WebGUI::Mail::Send;
|
||||
use WebGUI::Shop::Cart;
|
||||
|
||||
|
||||
|
|
@ -402,6 +404,32 @@ sub onAdjustQuantityInCart {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 onCancelRecurring ( item )
|
||||
|
||||
Called when a user or a store admin stops a recurring payment from recurring. This allows for any accounting work that needs to be accounted for happens. By default sends an email to shop managers to let them know that the recurrence has been stopped.
|
||||
|
||||
=head3 item
|
||||
|
||||
Receives a reference to the WebGUI::Shop::TransactionItem so it can determine things like itemId and quantity if it needs them for book keeping purposes.
|
||||
|
||||
=cut
|
||||
|
||||
sub onCancelRecurring {
|
||||
my ($self, $item) = @_;
|
||||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new($session, "Shop");
|
||||
my $mail = WebGUI::Mail::Send->new($session, {
|
||||
toGroup => $self->session->setting->get('groupIdAdminCommerce'),
|
||||
subject => $i18n->get('shop notice'),
|
||||
});
|
||||
my $message = sprintf $i18n->get('cancel recurring message','Asset_Sku'), $item->transaction->get('orderNumber'), $item->get('configuredTitle'), $item->transaction->get('username');
|
||||
$mail->addText($message);
|
||||
$mail->queue;
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 onCompletePurchase ( item )
|
||||
|
||||
Called just after payment has been made. It allows for privileges to be given, or bookkeeping
|
||||
|
|
@ -422,7 +450,7 @@ sub onCompletePurchase {
|
|||
|
||||
=head2 onRefund ( item )
|
||||
|
||||
Called by a transaction upon issuing a refund for this item. Extend to do extra book keeping or restocking.
|
||||
Called by a transaction upon issuing a refund for this item. Extend to do extra book keeping or restocking. If this is a recurring item, then onCancelRecurring() will also be called.
|
||||
|
||||
=head3 item
|
||||
|
||||
|
|
@ -432,6 +460,7 @@ The WebGUI::Shop::TransactionItem being refunded.
|
|||
|
||||
sub onRefund {
|
||||
my ($self, $item) = @_;
|
||||
$self->onCancelRecurring($item);
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,24 @@ sub _buildObj {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 cancelRecurringPayment ( transaction )
|
||||
|
||||
Cancels a recurring transaction. Returns an array containing ( isSuccess, gatewayStatus, gatewayError). Needs to be overridden by subclasses capable of dealing with recurring payments.
|
||||
|
||||
=head3 transaction
|
||||
|
||||
The instanciated recurring transaction object.
|
||||
|
||||
=cut
|
||||
|
||||
sub cancelRecurringPayment {
|
||||
my $self = shift;
|
||||
my $transaction = shift;
|
||||
WebGUI::Error::OverrideMe->throw();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 className ( )
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use WebGUI::Shop::Admin;
|
|||
use WebGUI::Shop::AddressBook;
|
||||
use WebGUI::Shop::Credit;
|
||||
use WebGUI::Shop::TransactionItem;
|
||||
use WebGUI::Shop::Pay;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -68,6 +69,21 @@ sub addItem {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 cancelRecurring ( )
|
||||
|
||||
Cancel a recurring transaction, and calls onCancelRecurring in whatever sku is attached to this transaction.
|
||||
|
||||
=cut
|
||||
|
||||
sub cancelRecurring {
|
||||
my ($self) = @_;
|
||||
$self->getPaymentGateway->cancelRecurringPayment($self);
|
||||
my ($item) = $self->getItems;
|
||||
$item->getSku->onCancelRecurring($item);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 completePurchase ( transactionCode, statusCode, statusMessage )
|
||||
|
||||
See also denyPurchase(). Completes a purchase by updating the transaction as a success, and calling onCompletePurchase on all the skus in the transaction.
|
||||
|
|
@ -321,6 +337,21 @@ sub getItems {
|
|||
return \@itemsObjects;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getPaymentGateway ()
|
||||
|
||||
Returns a reference to the payment gateway attached to this transaction.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPaymentGateway {
|
||||
my ($self) = @_;
|
||||
my $pay = WebGUI::Shop::Pay->new($self->session);
|
||||
return $pay->getPaymentGateway($self->get('paymentDriverId'));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( session, transactionId )
|
||||
|
|
|
|||
|
|
@ -9,6 +9,12 @@ our $I18N = {
|
|||
context => q|a help label|
|
||||
},
|
||||
|
||||
'cancel recurring message' => {
|
||||
message => q|Recurring transaction %s with an item named %s for a user named %s has been cancelled.|,
|
||||
lastUpdated => 0,
|
||||
context => q|a notification email sent to shop owners|,
|
||||
},
|
||||
|
||||
'shop' => {
|
||||
message => q|Shop|,
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@ package WebGUI::i18n::English::Shop;
|
|||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'shop notice' => {
|
||||
message => q|Shop Notice|,
|
||||
lastUpdated => 0,
|
||||
context => q|an email subject heading for generic shop notification emails|,
|
||||
},
|
||||
|
||||
'mixed items warning' => {
|
||||
message => q|You are not able to check out with both recurring and non-recurring items in your cart. You may have either one recurring item, or as many non-recurring items as you want in your cart at checkout time. If you need to purchase both, then please purchase them under separate transactions.|,
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue