ITransact fixes.

This commit is contained in:
Martin Kamerbeek 2008-05-29 20:19:17 +00:00
parent 63e93221bd
commit 2c57721e20
3 changed files with 33 additions and 18 deletions

View file

@ -268,6 +268,29 @@ sub get {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 getAddress ( addressId )
Returns an instantiated WebGUI::Shop::Address object for the passed address id.
=head3 addressId
The id of the adress to instantiate.
=cut
sub getAddress {
my $self = shift;
my $addressId = shift;
if ($addressId) {
return $self->getCart->getAddressBook->getAddress( $addressId );
}
return undef;
}
#-------------------------------------------------------------------
=head2 getButton ( ) =head2 getButton ( )
Returns the form that will take the user to check out. Returns the form that will take the user to check out.

View file

@ -37,16 +37,6 @@ sub definition {
return $class->SUPER::definition($session, $definition); return $class->SUPER::definition($session, $definition);
} }
#-------------------------------------------------------------------
sub getAddress {
my ($self, $addressId) = @_;
if ($addressId) {
return $self->getCart->getAddressBook->getAddress( $addressId );
}
# No billing address selected yet so return undef.
return undef;
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub getButton { sub getButton {

View file

@ -550,8 +550,8 @@ sub processPayment {
# Process response # Process response
if ($response->is_success) { if ($response->is_success) {
# We got some XML back from iTransact, now parse it. # We got some XML back from iTransact, now parse it.
$session->errorHandler->info('Starting request'); my $transactionResult = XMLin( $response->content, SuppressEmpty => '' );
my $transactionResult = XMLin( $response->content );
#### TODO: More checking: price, address, etc #### TODO: More checking: price, address, etc
unless (defined $transactionResult->{ TransactionData }) { unless (defined $transactionResult->{ TransactionData }) {
# GatewayFailureResponse: This means the xml is invalid or has the wrong mime type # GatewayFailureResponse: This means the xml is invalid or has the wrong mime type
@ -574,7 +574,9 @@ sub processPayment {
my $gatewayCode = $transactionData->{ XID }; my $gatewayCode = $transactionData->{ XID };
my $isSuccess = $status eq 'OK'; my $isSuccess = $status eq 'OK';
return ( $isSuccess, $gatewayCode, $status, "" ); my $message = ($errorCategory) ? " $errorMessage Category: $errorCategory" : $errorMessage;
return ( $isSuccess, $gatewayCode, $status, $message );
} }
} else { } else {
# Connection Error # Connection Error
@ -597,7 +599,7 @@ sub www_getCredentials {
my $addressId = $session->form->process('addressId'); my $addressId = $session->form->process('addressId');
my $addressData = {}; my $addressData = {};
if ( $addressId ) { if ( $addressId ) {
$addressData = eval{ $self->getCart->getAddressBook->getAddress( $addressId )->get() } || {}; $addressData = eval{ $self->getAddress( $addressId )->get() } || {};
} }
my $output; my $output;
@ -690,9 +692,9 @@ sub www_getCredentials {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_pay { sub www_pay {
my $self = shift; my $self = shift;
my $session = $self->session; my $session = $self->session;
my $addressId = $session->form->process( 'addressId' ) || undef; my $address = $self->getAddress( $session->form->process( 'addressId' ) );
# Check whether the user filled in the checkout form and process those. # Check whether the user filled in the checkout form and process those.
my $credentialsErrors = $self->processCredentials; my $credentialsErrors = $self->processCredentials;
@ -701,7 +703,7 @@ sub www_pay {
return $self->www_getCredentials( $credentialsErrors ) if $credentialsErrors; return $self->www_getCredentials( $credentialsErrors ) if $credentialsErrors;
# Payment time! # Payment time!
my $transaction = $self->processTransaction( $addressId ); my $transaction = $self->processTransaction( $address );
if ($transaction->get('isSuccessful')) { if ($transaction->get('isSuccessful')) {
return $transaction->thankYou(); return $transaction->thankYou();
} }