Merge commit '41575d24bb' into webgui8. Some tests still failing.

Conflicts:
	docs/gotcha.txt
	lib/WebGUI.pm
	lib/WebGUI/Asset.pm
	lib/WebGUI/Asset/File/GalleryFile/Photo.pm
	lib/WebGUI/Asset/Post.pm
	lib/WebGUI/Asset/Template.pm
	lib/WebGUI/Asset/WikiPage.pm
	lib/WebGUI/Asset/Wobject/WikiMaster.pm
	lib/WebGUI/Cache.pm
	lib/WebGUI/Content/Setup.pm
	lib/WebGUI/Role/Asset/Subscribable.pm
	lib/WebGUI/Shop/Cart.pm
	lib/WebGUI/Shop/Pay.pm
	lib/WebGUI/Shop/PayDriver/ITransact.pm
	sbin/testEnvironment.pl
	t/Asset/WikiPage.t
	t/Shop/PayDriver.t
	t/Shop/PayDriver/ITransact.t
	t/Shop/PayDriver/Ogone.t
	t/Shop/TaxDriver/EU.t
	t/Shop/TaxDriver/Generic.t
	t/Workflow/Activity/RemoveOldCarts.t
	t/lib/WebGUI/Test.pm
This commit is contained in:
Colin Kuskie 2010-06-25 23:25:26 -07:00
commit 5febc0ebbc
258 changed files with 5528 additions and 2230 deletions

View file

@ -80,6 +80,33 @@ sub _buildObj {
}
#-------------------------------------------------------------------
=head2 appendCartVariables ( $var )
Append the subtotal, shipping, tax, and shop credeductions to a set of template
variables.
=cut
sub appendCartVariables {
my ($self, $var) = @_;
$var ||= {};
my $cart = $self->getCart;
$var->{shippableItemsInCart} = $cart->requiresShipping;
$var->{subtotal} = $cart->calculateSubtotal;
$var->{shipping} = $cart->calculateShipping;
$var->{taxes} = $cart->calculateTaxes;
my $totalPrice = $var->{subtotal} + $var->{shipping} + $var->{taxes};
my $session = $self->session;
my $credit = WebGUI::Shop::Credit->new($session, $cart->getPosUser->userId);
$var->{inShopCreditAvailable} = $credit->getSum;
$var->{inShopCreditDeduction} = $credit->calculateDeduction($var->{totalPrice});
$var->{totalPrice } = $cart->formatCurrency($totalPrice + $var->{inShopCreditDeduction});
return $self;
}
#-------------------------------------------------------------------
=head2 cancelRecurringPayment ( transaction )
@ -340,12 +367,13 @@ sub getAddress {
=head2 getButton ( )
Returns the form that will take the user to check out.
Used for the generic, vanilla checkout form. Must be overridden by any methods that
use the default www_getCredentials.
=cut
sub getButton {
my $self = shift;
return '';
}
#-------------------------------------------------------------------
@ -358,9 +386,7 @@ Returns the WebGUI::Shop::Cart object for the current session.
sub getCart {
my $self = shift;
my $cart = WebGUI::Shop::Cart->newBySession( $self->session );
return $cart;
}
@ -463,51 +489,6 @@ sub getName {
#-------------------------------------------------------------------
=head2 getSelectAddressButton ( returnMethod, [ buttonLabel ] )
Generates a button for selecting an address.
=head3 returnMethod
The name of the www_ method the selected addressId should be returned to. Without the 'www_' part.
=head3 buttonLabel
The label for the button, defaults to the internationalized version of 'Choose billing address'.
=cut
sub getSelectAddressButton {
my $self = shift;
my $returnMethod = shift;
my $buttonLabel = shift || 'Choose billing address';
my $session = $self->session;
# Generate the json string that defines where the address book posts the selected address
my $callbackParams = {
url => $session->url->page,
params => [
{ name => 'shop', value => 'pay' },
{ name => 'method', value => 'do' },
{ name => 'do', value => $returnMethod },
{ name => 'paymentGatewayId', value => $self->getId },
],
};
my $callbackJson = JSON::to_json( $callbackParams );
# Generate 'Choose billing address' button
my $addressButton = WebGUI::Form::formHeader( $session )
. WebGUI::Form::hidden( $session, { name => 'shop', value => 'address' } )
. WebGUI::Form::hidden( $session, { name => 'method', value => 'view' } )
. WebGUI::Form::hidden( $session, { name => 'callback', value => $callbackJson } )
. WebGUI::Form::submit( $session, { value => $buttonLabel } )
. WebGUI::Form::formFooter( $session );
return $addressButton;
}
#-------------------------------------------------------------------
=head2 handlesRecurring ()
Returns 0. Should be overridden to return 1 by any subclasses that can handle recurring payments.
@ -581,6 +562,35 @@ sub processPayment {
=head2 processPropertiesFromFormPost ( )
Updates pay driver with data from Form.
=cut
sub processTemplate {
my $self = shift;
my $session = $self->session;
my $templateId = shift;
my $var = shift;
my $i18n = WebGUI::International->new($session, 'PayDriver');
my $template = eval { WebGUI::Asset->newById($session, $templateId); };
my $output;
if (!Exception::Class->caught) {
$template->prepare;
$output = $template->process($var);
}
else {
$output = $i18n->get('template gone');
}
return $output;
}
#-------------------------------------------------------------------
=head2 processPropertiesFromFormPost ( )
Updates ship driver with data from Form.
=cut
@ -637,7 +647,6 @@ sub processTransaction {
my $transactionProperties;
$transactionProperties->{ paymentMethod } = $self;
$transactionProperties->{ cart } = $cart;
$transactionProperties->{ paymentAddress } = $paymentAddress if defined $paymentAddress;
$transactionProperties->{ isRecurring } = $cart->requiresRecurringPayment;
# Create a transaction...
@ -708,6 +717,31 @@ a GUID.
#-------------------------------------------------------------------
=head2 www_getCredentials ( )
Displays a summary of the cart, and a button to checkout. Plugins that need to get additional
information, or perform additional checks, should override this method. Uses the getButton
method to create the checkout button.
=cut
sub www_getCredentials {
my ($self) = @_;
my $session = $self->session;
# Generate 'Proceed' button
my $i18n = WebGUI::International->new($session, 'PayDriver_Cash');
my $var = {
proceedButton => $self->getButton,
};
$self->appendCartVariables($var);
my $output = $self->processTemplate($self->get("summaryTemplateId"), $var);
return $session->style->userStyle($output);
}
#-------------------------------------------------------------------
=head2 www_edit ( )
Generates an edit form.