- Updated WebGUI::Shop::PayDriver::processTransaction() to accept a

transaction as a param.
This commit is contained in:
JT Smith 2008-10-07 18:05:04 +00:00
parent 2a66f149e8
commit c9153bc80e

View file

@ -606,30 +606,42 @@ sub processPropertiesFromFormPost {
#-------------------------------------------------------------------
=head2 processTransaction ( [ paymentAddress ] )
=head2 processTransaction ( [ object ] )
This method is responsible for handling success or failure from the payment processor, completing or denying the transaction, and sending out notification and receipt emails. Returns a WebGUI::Shop::Transaction object.
=head3 paymentAddress
=head3 object
A reference to a WebGUI::Shop::Address object that should be attached as payment information. Not required.
Can be undef, in which case a WebGUI::Shop::Transaction object will be generated using the cart. Can also be a reference to a WebGUI::Shop::Address object that should be attached as payment information to the autogenerated WebGUI::Shop::Transaction. Or can be a WebGUI::Shop::Transaction that you've already constructed and then no transaction will be generated, but rather just updated.
=cut
sub processTransaction {
my ($self, $paymentAddress) = @_;
my ($self, $object) = @_;
my $cart = $self->getCart;
# determine object type
my $transaction;
my $paymentAddress;
if ($object->isa('WebGUI::Shop::Transaction')) {
$transaction = $object;
}
elsif ($object->isa('WebGUI::Shop::Address')) {
$paymentAddress = $object;
}
# Setup tranasction properties
my $transactionProperties;
$transactionProperties->{ paymentMethod } = $self;
$transactionProperties->{ cart } = $cart;
$transactionProperties->{ paymentAddress } = $paymentAddress if defined $paymentAddress;
$transactionProperties->{ isRecurring } = $cart->requiresRecurringPayment;
# Create a transaction...
my $transaction = WebGUI::Shop::Transaction->create( $self->session, $transactionProperties );
# Setup dynamic transaction
unless (defined $transaction) {
my $transactionProperties;
$transactionProperties->{ paymentMethod } = $self;
$transactionProperties->{ cart } = $cart;
$transactionProperties->{ paymentAddress } = $paymentAddress if defined $paymentAddress;
$transactionProperties->{ isRecurring } = $cart->requiresRecurringPayment;
# Create a transaction...
$transaction = WebGUI::Shop::Transaction->create( $self->session, $transactionProperties );
}
# And handle the payment for it
my ($success, $transactionCode, $statusCode, $statusMessage) = $self->processPayment( $transaction );