Forward porting bug fixes for billing address and asset with uncommitted parent.

This commit is contained in:
Colin Kuskie 2009-01-23 15:33:30 +00:00
parent f78886e3d7
commit 310d454162
3 changed files with 84 additions and 36 deletions

View file

@ -1,10 +1,12 @@
7.6.10
- fixed #9455: fixed synopsis to pick out html paragraphs, fixed FeedPP fields to scalar when blank
- fixed: With autocommit and no comments on, making a shortcut of an asset takes you to that asset's view.
- fixed #9506: Choose billing address
- fixed #9541: assets with uncommitted parent.
- reverted #9386: Gallery: "Image resolutions" issue. This is a feature of the Galley.
7.6.9
- fixed: ukplayer example is now loaded with swfobject.js released under the
MIT licence, see gotcha's and /extras/ukplayer
- fixed: ukplayer example is now loaded with swfobject.js released under the MIT licence, see gotcha's and /extras/ukplayer
- fixed #9264: new slideShow.swf uploaded in extras/ukplayer (United Knowledge/Arjan Widlak)
- fixed #9428: added code to ASSET::get to include keywords when no property name is requested
- marked sbin scripts as executable

View file

@ -216,7 +216,14 @@ sub getBackToSiteURL {
$url = WebGUI::Asset->getDefault($self->session)->getUrl;
}
else {
$url = $self->session->asset->getContainer->getUrl;
my $container = $self->session->asset->getContainer;
##Container may be under a different version tag if this asset has been moved.
if (defined $container) {
$url = $container->getUrl;
}
else {
$url = $self->session->url->page();
}
}
} else {
$url = $self->session->url->page();

View file

@ -487,31 +487,71 @@ sub processCredentials {
push @error, $i18n->get('invalid expiration date') unless $expires =~ m{^\d{6}$};
push @error, $i18n->get('expired expiration date') unless $expires >= $now;
return \@error if scalar @error;
# Everything ok process the actual data
unless (@error) {
$self->{ _cardData } = {
acct => $form->integer( 'cardNumber' ),
expMonth => $form->integer( 'expMonth' ),
expYear => $form->integer( 'expYear' ),
cvv2 => $form->integer( 'cvv2' ),
};
$self->{ _billingAddress } = {
address1 => $form->process( 'address' ),
code => $form->zipcode( 'zipcode' ),
city => $form->process( 'city' ),
firstName => $form->process( 'firstName' ),
lastName => $form->process( 'lastName' ),
email => $form->email ( 'email' ),
state => $form->process( 'state' ),
country => $form->process( 'country' ),
phoneNumber => $form->process( 'phone' ),
};
$self->{ _cardData } = {
acct => $form->integer( 'cardNumber' ),
expMonth => $form->integer( 'expMonth' ),
expYear => $form->integer( 'expYear' ),
cvv2 => $form->integer( 'cvv2' ),
};
$self->{ _billingAddress } = {
address1 => $form->process( 'address' ),
code => $form->zipcode( 'zipcode' ),
city => $form->process( 'city' ),
firstName => $form->process( 'firstName' ),
lastName => $form->process( 'lastName' ),
email => $form->email ( 'email' ),
state => $form->process( 'state' ),
country => $form->process( 'country' ),
phoneNumber => $form->process( 'phone' ),
};
return;
}
return \@error;
return;
}
#-------------------------------------------------------------------
=head2 getBillingAddress ( $addressId )
The billing address is not handled by WebGUI::Shop::Address, it comes from
www_getCredentials. However, WebGUI::Shop::Transaction requires an
WebGUI::Shop::Address object. The billing address is seeded with information
from the shipping address. If this address info is different, then create
a new address to hand to Transaction.
=head3 $addressId
The id of a WebGUI::Shop::Address. If not present, then use the shipping
address instead.
=cut
sub getBillingAddress {
my ($self, $addressId) = @_;
my $address = $addressId
? $self->getAddress( $addressId )
: $self->getCart->getShippingAddress
;
##If the user made any changes to the default address, create a new billing address
##and use it instead
if( $address->get('firstName' ) ne $self->{_billingAddress}->{ 'firstName' }
|| $address->get('lastName' ) ne $self->{_billingAddress}->{ 'lastName' }
|| $address->get('address1' ) ne $self->{_billingAddress}->{ 'address1' }
|| $address->get('city' ) ne $self->{_billingAddress}->{ 'city' }
|| $address->get('state' ) ne $self->{_billingAddress}->{ 'state' }
|| $address->get('code' ) ne $self->{_billingAddress}->{ 'code' }
|| $address->get('country' ) ne $self->{_billingAddress}->{ 'country' }
|| $address->get('phoneNumber' ) ne $self->{_billingAddress}->{ 'phoneNumber' }
|| $address->get('email' ) ne $self->{_billingAddress}->{ 'email' }
) {
my $billingAddress = $self->getCart->getAddressBook->addAddress( $self->{_billingAddress} );
return $billingAddress;
}
return $address;
}
#-------------------------------------------------------------------
@ -637,7 +677,6 @@ sub www_getCredentials {
}
$var->{getSelectAddressButton} = $self->getSelectAddressButton( 'getCredentials' );
$self->session->log->warn("selectAddressButton: ".$var->{getSelectAddressButton});
$var->{formHeader} = WebGUI::Form::formHeader($session)
. $self->getDoFormTags('pay');
@ -647,8 +686,6 @@ sub www_getCredentials {
}
$var->{formFooter} = WebGUI::Form::formFooter();
$self->session->log->warn("formHeader: ".$var->{formHeader});
# Address data form
$var->{firstNameField} = WebGUI::Form::text($session, {
@ -714,20 +751,22 @@ sub www_getCredentials {
sub www_pay {
my $self = shift;
my $session = $self->session;
my $addressId = $session->form->process( 'addressId' );
my $address = $addressId
? $self->getAddress( $addressId )
: $self->getCart->getShippingAddress
;
# Check whether the user filled in the checkout form and process those.
my $credentialsErrors = $self->processCredentials;
# Go back to checkout form if credentials are not ok
return $self->www_getCredentials( $credentialsErrors ) if $credentialsErrors;
my $addressId = $session->form->process( 'addressId' );
my $billingAddress = $self->getBillingAddress($addressId);
# Payment time!
my $transaction = $self->processTransaction( $address );
my $transaction = $self->processTransaction( $billingAddress );
## The billing address object is temporary, just to send to the transaction.
## Delete it if we don't need it.
if ($billingAddress->getId ne $addressId) {
$billingAddress->delete;
}
if ($transaction->get('isSuccessful')) {
return $transaction->thankYou();
}