Update Ogone driver for new Shop checkout procedures.

This commit is contained in:
Colin Kuskie 2010-04-28 14:57:47 -07:00
parent e7942d6d68
commit aedda01e58
5 changed files with 56 additions and 87 deletions

View file

@ -165,6 +165,9 @@ sub addPayDriverTemplates {
if ($gateway->isa('WebGUI::Shop::PayDriver::Cash')) { if ($gateway->isa('WebGUI::Shop::PayDriver::Cash')) {
$properties->{summaryTemplateId} = '30h5rHxzE_Q0CyI3Gg7EJw'; $properties->{summaryTemplateId} = '30h5rHxzE_Q0CyI3Gg7EJw';
} }
elsif ($gateway->isa('WebGUI::Shop::PayDriver::Ogone')) {
$properties->{summaryTemplateId} = 'jysVZeUR0Bx2NfrKs5sulg';
}
$gateway->update($properties); $gateway->update($properties);
} }
print "DONE!\n" unless $quiet; print "DONE!\n" unless $quiet;

View file

@ -469,27 +469,6 @@ sub doXmlRequest {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 getButton
Return a form to select this payment driver and to accept credentials from those
who wish to use it.
=cut
sub getButton {
my $self = shift;
my $session = $self->session;
my $payForm = WebGUI::Form::formHeader($session)
. $self->getDoFormTags('getCredentials')
. WebGUI::Form::submit($session, {value => $self->get('label') })
. WebGUI::Form::formFooter($session);
return $payForm;
}
#-------------------------------------------------------------------
=head2 handlesRecurring =head2 handlesRecurring
Tells the commerce system that this payment plugin can handle recurring payments. Tells the commerce system that this payment plugin can handle recurring payments.

View file

@ -101,6 +101,13 @@ sub definition {
hoverHelp => $i18n->get('use test mode help'), hoverHelp => $i18n->get('use test mode help'),
defaultValue => 1, defaultValue => 1,
}, },
summaryTemplateId => {
fieldType => 'template',
label => $i18n->get('summary template'),
hoverHelp => $i18n->get('summary template help'),
namespace => 'Shop/Credentials',
defaultValue => 'jysVZeUR0Bx2NfrKs5sulg',
},
); );
push @{ $definition }, { push @{ $definition }, {
@ -113,28 +120,6 @@ sub definition {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 getButton ( )
Returns the HTML for a form containing a button that, when clicked, will take the user to the checkout screen of
this plugin.
=cut
sub getButton {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new($session, 'PayDriver_Ogone');
my $payForm = WebGUI::Form::formHeader($session)
. $self->getDoFormTags('getCredentials')
. WebGUI::Form::submit($session, {value => $i18n->get('Ogone') })
. WebGUI::Form::formFooter($session);
return $payForm;
}
#-------------------------------------------------------------------
=head2 getCart =head2 getCart
Returns the cart for either the current user or the transaction passed back by Ogone. Returns the cart for either the current user or the transaction passed back by Ogone.
@ -287,17 +272,6 @@ sub www_getCredentials {
my $session = $self->session; my $session = $self->session;
my $i18n = WebGUI::International->new( $session, 'PayDriver_Ogone' ); my $i18n = WebGUI::International->new( $session, 'PayDriver_Ogone' );
# Process address from address book if passed
$addressId = $session->form->process( 'addressId' );
my $address;
if ( $addressId ) {
$address = eval{ $self->getAddress( $addressId ) };
}
else {
$address = $self->getCart->getShippingAddress;
}
my $billingAddressHtml = $address->getHtmlFormatted;
# Fetch transaction # Fetch transaction
my $transactionId = $session->form->process('transactionId'); my $transactionId = $session->form->process('transactionId');
my $transaction; my $transaction;
@ -307,41 +281,26 @@ sub www_getCredentials {
# Or generate a new one # Or generate a new one
unless ($transaction) { unless ($transaction) {
$transaction = $self->processTransaction( $address ); $transaction = $self->processTransaction( );
} }
# Set the billing address
$transaction->update( {
paymentAddress => $address,
} );
# 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 => 'getCredentials' },
{ 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 => $i18n->get('choose billing address') } )
. WebGUI::Form::formFooter( $session);
# Generate 'Proceed' button # Generate 'Proceed' button
my $proceedButton = $address my $var = {
? $self->ogoneCheckoutButton( $transaction, $address ) proceedButton => $self->ogoneCheckoutButton,
: $i18n->get('please choose a billing address') };
; $self->appendCartVariables($var);
return $session->style->userStyle($addressButton.'<br />'.$billingAddressHtml.'<br />'.$proceedButton);
my $template = WebGUI::Asset::Template->new($session, $self->get("summaryTemplateId"));
my $output;
if (defined $template) {
$template->prepare;
$output = $template->process($var);
}
else {
$output = $i18n->get('template gone', 'PayDriver_ITransact');
}
return $session->style->userStyle($output);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------

View file

@ -164,7 +164,7 @@ our $I18N = {
lastUpdated => 0, lastUpdated => 0,
context => q|Form label in the configuration form of the Cash module.| context => q|Form label in the configuration form of the Cash module.|
}, },
'summary template help' => { 'summary template help' => {
message => q|Pick a template to display the screen where the user confirms the cart summary info and agrees to pay.|, message => q|Pick a template to display the screen where the user confirms the cart summary info and agrees to pay.|,
lastUpdated => 0, lastUpdated => 0,
context => q|Hover help for the summary template field in the configuration form of the Cash module.| context => q|Hover help for the summary template field in the configuration form of the Cash module.|

View file

@ -80,6 +80,34 @@ our $I18N = {
context => q|Hover help of a setting in the ogone config screen.|, context => q|Hover help of a setting in the ogone config screen.|,
}, },
'summary template' => {
message => q|Summary Template|,
lastUpdated => 0,
context => q|Form label in the configuration form of the Cash module.|
},
'summary template help' => {
message => q|Pick a template to display the screen where the user confirms the cart summary info and agrees to pay.|,
lastUpdated => 0,
context => q|Hover help for the summary template field in the configuration form of the Cash module.|
},
'password' => {
message => q|Password|,
lastUpdated => 0,
context => q|Form label in the configuration form of the iTransact module.|
},
'password help' => {
message => q|The password for your ITransact account.|,
lastUpdated => 0,
context => q|Hover help for the password field in the configuration form of the iTransact module.|
},
'Pay' => {
message => q|Pay|,
lastUpdated => 0,
context => q|Button label|
},
};
'pay' => { 'pay' => {
message => q|Pay|, message => q|Pay|,
lastUpdated => 0, lastUpdated => 0,