From 64866dd4851e24f0fa54e7fd8825368fcd188429 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 28 Apr 2010 12:08:14 -0700 Subject: [PATCH] Update ITranasct plugin for Shop 1.5 --- ...llateral-items_itransact-credentials.wgpkg | Bin 0 -> 2951 bytes lib/WebGUI/Shop/PayDriver/ITransact.pm | 136 +----------------- 2 files changed, 3 insertions(+), 133 deletions(-) create mode 100644 docs/upgrades/packages-7.9.4/shopping-cart-collateral-items_itransact-credentials.wgpkg diff --git a/docs/upgrades/packages-7.9.4/shopping-cart-collateral-items_itransact-credentials.wgpkg b/docs/upgrades/packages-7.9.4/shopping-cart-collateral-items_itransact-credentials.wgpkg new file mode 100644 index 0000000000000000000000000000000000000000..174b1b26cd607727f2d5f208f358d96235a91393 GIT binary patch literal 2951 zcmV;23wZP&iwFP!00000|Lt0BZ`(K$&gcCVLINCGAa-mgPEscqpf8(iaNQ!eO|K{} zw}C9tHd|Q|C^|12prsZh74a{CVc^rf+XVc_hx;wjEStd z8V3a*8XWyUNA&-xicojWzx&7dy?fmLmL>5s0fi0^4`IIR=f8K-15Mh zoBwQT{@a^}{u~+}e*q`lmTa0vzGOGPlzuRovRG!@-oX3Me|M=qlZo)h%q~hrk}@GV zBSGp0dy4!_{(7G#LbC8RRmHO?qF%5%5De6WZyvC#?fvbdLTk7Pf4%ns3#oEif}2Vz z-A-r2h-VWPn$|J9`@-Wexub47rh?r|;lF2oc;%0?OF#Gytx)r6CLbc^$%mBv{ThaU zFZY5hyWT$A$tFpf@_78#7xHnG#IiN=r#yNX_=5Y<36*60Pd4cG()*JqN8Xd7JppA* zcrsLt?-(CXWG2<`M+kC>7~D;`WG6$g##kh?IBconv0yB&8Id1Jgiw*+Iq%?~ z#un|6MNG0sJ<3+ZMsm>Yz&KmeYH5n!m6@IyY!S~5vL%&Q+JFrcXs(XF8w^{cy4 z-RnBlq*`5_Gd03?HsLh&1!9_|d60jn$!!{w0$|BlpsDLQsH^o=*l05z!zvCRr@k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BjTyo1s*V8#JHHjls~eN8|Pndz8kkjzRRy- z5?F-FBK6B3GEBO{f%8RJYAR6KK3iH++T)un!DA1DhlgRE%Q^NaB8TnsUhV|uI`36_ z53pX89L~S>IUH9;OluhExQaf)WAwte1mJZpclNU6i@BzrWu=hs8P9DXI@I%@z1rHe5Ag`?t^`&L=OyRer%U(O>S!tSJXMW+fJYaC| zP1myJ9vU{aXBkSdV`}dMst3T<-xXCiKe93I5n+G;V0aLE($!QpE3=Hd$PC4p7q zzDgbD^Mq(F3vfNLR(bNn`*NH@F_etn0#e^Gj4XDazR|cgHv<1HuyqQ6LyzG z0!gmTI8eGgp~p=kKz<+ zd;M3Y3!Mc0n=|#~=Ezjhts{-6@F)*ANu8&8FW#|{Ka1o`(x18YTY&U zJi}}Y?Od**T<;S+$59oXgM+?lhU1*krQWumLIl3GpA5kpr`Z)=kgf(5-Yr1tN^Kfu zWiWVu_1lN)9P#W!g71&i+b8F36VJ3w%EPl~O4arD5B59V!{eSAreL=`1G?}oe;`#i zVUXy;-EXl*Olx@8sNO~8ucSzi^@Iv&*4;&X4l7!j(wdhT7AR(Q%7(~>_N93tQEB~q_&5rz{bQzQ6HB;kLOo){;gV$@SYkYppfuZ4w8Aw_Lm3sk!VzjDI_wOR{} z;l+)RjL6EkOw+Z%6}-0*+v*J4HC&;gicg;wS(J5|=#S!!Xt8p28$zQBI%_|pElF`* zcWmxkVl9DOJLkY=FSPh?nf*$Ctk32zuD*WTAAJ?CUdirsession; - my $paymentAddress = $self->{ _billingAddress }; + my $paymentAddress = $self->getCart->getBillingAddress->get(); my $cardData = $self->{ _cardData }; # Set up the XML. @@ -516,19 +516,6 @@ sub processCredentials { my $i18n = WebGUI::International->new($session,'PayDriver_ITransact'); my @error; - # Check address data - push @error, $i18n->get( 'invalid firstName' ) unless $form->process( 'firstName' ); - push @error, $i18n->get( 'invalid lastName' ) unless $form->process( 'lastName' ); - push @error, $i18n->get( 'invalid address' ) unless $form->process( 'address' ); - push @error, $i18n->get( 'invalid city' ) unless $form->process( 'city' ); - push @error, $i18n->get( 'invalid email' ) unless $form->email ( 'email' ); - push @error, $i18n->get( 'invalid zip' ) - if ( !$form->zipcode( 'zipcode' ) && $form->process( 'country' ) eq 'United States' ); - - # Check credit card data - push @error, $i18n->get( 'invalid card number' ) unless $form->integer('cardNumber'); - push @error, $i18n->get( 'invalid cvv2' ) if ($self->get('useCVV2') && !$form->integer('cvv2')); - # Check if expDate and expYear have sane values my ($currentYear, $currentMonth) = $self->session->datetime->localtime; my $expires = $form->integer( 'expYear' ) . sprintf '%02d', $form->integer( 'expMonth' ); @@ -546,66 +533,11 @@ sub processCredentials { 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; } #------------------------------------------------------------------- -=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; -} - -#------------------------------------------------------------------- - =head2 processPayment ($transaction) Contact ITransact and submit the payment data to them for processing. @@ -722,18 +654,7 @@ sub www_getCredentials { my $session = $self->session; my $form = $session->form; my $i18n = WebGUI::International->new($self->session, 'PayDriver_ITransact'); - my $u = WebGUI::User->new($self->session,$self->session->user->userId); - # Process address from address book if passed - my $addressId = $session->form->process( 'addressId' ); - my $addressData; - if ( $addressId ) { - $addressData = eval{ $self->getAddress( $addressId )->get() } || {}; - } - else { - $addressData = $self->getCart->getShippingAddress->get; - } - my $var = {}; # Process form errors @@ -745,55 +666,11 @@ sub www_getCredentials { } } - $var->{getSelectAddressButton} = $self->getSelectAddressButton( 'getCredentials' ); - $var->{formHeader} = WebGUI::Form::formHeader($session) . $self->getDoFormTags('pay'); - if ($var->{formHeader}) { - $var->{formHeader} .= WebGUI::Form::hidden($session, {name => 'addressId', value => $addressId}); - } - $var->{formFooter} = WebGUI::Form::formFooter(); - # Address data form - $var->{firstNameField} = WebGUI::Form::text($session, { - name => 'firstName', - value => $form->process("firstName") || $addressData->{ "firstName" } || $u->profileField('firstName'), - }); - $var->{lastNameField} = WebGUI::Form::text($session, { - name => 'lastName', - value => $form->process("lastName") || $addressData->{ "lastName" } || $u->profileField('lastName'), - }); - $var->{addressField} = WebGUI::Form::text($session, { - name => 'address', - value => $form->process("address") || $addressData->{ address1 } || $u->profileField('homeAddress'), - }); - $var->{cityField} = WebGUI::Form::text($session, { - name => 'city', - value => $form->process("city") || $addressData->{ city } || $u->profileField('homeCity'), - }); - $var->{stateField} = WebGUI::Form::text($session, { - name => 'state', - value => $form->process("state") || $addressData->{ state } || $u->profileField('homeState'), - }); - $var->{codeField} = WebGUI::Form::zipcode($session, { - name => 'zipcode', - value => $form->process("zipcode") || $addressData->{ code } || $u->profileField('homeZip'), - }); - $var->{countryField} = WebGUI::Form::country($session, { - name => 'country', - value => ($form->process("country",'country', '') || $addressData->{ country } || $u->profileField("homeCountry") || 'United States of A'), - }); - $var->{phoneField} = WebGUI::Form::phone($session, { - name => 'phone', - value => $form->process("phone",'phone') || $addressData->{ phoneNumber } || $u->profileField("homePhone"), - }); - $var->{emailField} = WebGUI::Form::email($session, { - name => 'email', - value => $form->process('email', 'email') || $addressData->{ email } || $u->profileField('email'), - }); - # Credit card information $var->{cardNumberField} = WebGUI::Form::text($session, { name => 'cardNumber', @@ -811,6 +688,7 @@ sub www_getCredentials { value => $i18n->get('checkout button', 'Shop'), extras => 'onclick="this.disabled=true;this.form.submit(); return false;"', }); + $self->appendCartVariables($var); my $template = WebGUI::Asset::Template->new($session, $self->get("credentialsTemplateId")); my $output; @@ -844,16 +722,8 @@ sub www_pay { # 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( $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; - } + my $transaction = $self->processTransaction( ); if ($transaction->get('isSuccessful')) { return $transaction->thankYou(); }