Update Ogone driver for new Shop checkout procedures.
This commit is contained in:
parent
e7942d6d68
commit
aedda01e58
5 changed files with 56 additions and 87 deletions
|
|
@ -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
|
||||
|
||||
Tells the commerce system that this payment plugin can handle recurring payments.
|
||||
|
|
|
|||
|
|
@ -101,6 +101,13 @@ sub definition {
|
|||
hoverHelp => $i18n->get('use test mode help'),
|
||||
defaultValue => 1,
|
||||
},
|
||||
summaryTemplateId => {
|
||||
fieldType => 'template',
|
||||
label => $i18n->get('summary template'),
|
||||
hoverHelp => $i18n->get('summary template help'),
|
||||
namespace => 'Shop/Credentials',
|
||||
defaultValue => 'jysVZeUR0Bx2NfrKs5sulg',
|
||||
},
|
||||
);
|
||||
|
||||
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
|
||||
|
||||
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 $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
|
||||
my $transactionId = $session->form->process('transactionId');
|
||||
my $transaction;
|
||||
|
|
@ -307,41 +281,26 @@ sub www_getCredentials {
|
|||
|
||||
# Or generate a new one
|
||||
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
|
||||
my $proceedButton = $address
|
||||
? $self->ogoneCheckoutButton( $transaction, $address )
|
||||
: $i18n->get('please choose a billing address')
|
||||
;
|
||||
return $session->style->userStyle($addressButton.'<br />'.$billingAddressHtml.'<br />'.$proceedButton);
|
||||
my $var = {
|
||||
proceedButton => $self->ogoneCheckoutButton,
|
||||
};
|
||||
$self->appendCartVariables($var);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue