package II5117351e1a4f1d07d1c88690b7a75168::mod_itransact; use strict; use Digest::HMAC_SHA1; use LWP::UserAgent; use II8b55f24974af3d53369c3d9cea404f55::filters::text2xml; sub checkPGateSettings { my $class = shift; my $settings = shift; my @errors; push @errors, 'check.empty_gateway_id' unless $settings->{gateway_id}; push @errors, 'check.empty_api_username' unless $settings->{api_username}; push @errors, 'check.empty_api_key' unless $settings->{api_key}; @errors; } sub checkProductSettings { my $class = shift; my ($product) = @_; my @errors; @errors; } sub getOrderProcessFormAddon { my $class = shift; my ($config, $settings, $singleProduct) = @_; my $sysURI = Zen::ScriptSys->getURI; my $msg_cardnumber = $config->{addons}{cardnumber}; my $msg_expiration = $config->{addons}{expiration}; my $msg_verification_code = $config->{addons}{verification_code}; my $this_year = II982446f8950cc3dc59e487adba22df54::lllIllIIIlllIIIl($IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$II982446f8950cc3dc59e487adba22df54::IIlIllllIlIIllIl},1010,$IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$II982446f8950cc3dc59e487adba22df54::IlIllIlIlIIlIlll})->new->format('%Y'); my $cardexpmonth = qq(<select name="cardexpmonth">); $cardexpmonth .= qq(<option value="$_"> ) . II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlIlIlIIIlIIlll($II982446f8950cc3dc59e487adba22df54::lllllllIIlllIIIl{$II982446f8950cc3dc59e487adba22df54::llIIIllIlllIllII},1010,$II982446f8950cc3dc59e487adba22df54::lllllllIIlllIIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlllllllIlIll})->new("$this_year-" . sprintf("%02u", $_) . "-01")->format('%b') for 1..12; $cardexpmonth .= qq(</select>); my $cardexpyear = qq(<select name="cardexpyear">); $cardexpyear .= qq(<option value="$_"> $_) for map { $this_year + $_ } 0..15; $cardexpyear .= qq(</select>); my $code = <<END;
<div style="margin-bottom: 5px;">
<span style="display: table-cell; width: 130px">$msg_cardnumber</span> <span style="display: table-cell"> <input type="text" name="cardnumber" size="30"> </span>
</div>
<div style="margin-bottom: 5px;">
<span style="display: table-cell; width: 130px">$msg_expiration</span> <span style="display: table-cell"> $cardexpmonth / $cardexpyear </span>
</div>
<div style="margin-bottom: 5px;">
<span style="display: table-cell; width: 130px">$msg_verification_code</span> <span style="display: table-cell"> <input type="text" name="cardcvc" size="5"> &nbsp;<a href="#" onClick="window.open('$sysURI/help/cvn.html','','toolbar=no,location=no,directories=no,top=+30,left=+40,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=500'); return false;">[?]</a> </span>
</div>
END
$code; } sub go { my $class = shift; my $pgtxn = shift; my $in = Zen->getRequest->getInput; my $settings = $pgtxn->getPGateSettings; my $order = $pgtxn->getOrder; my $amount = $pgtxn->getAmount; return ['go.no_name'] unless $order->{user_fname} && $order->{user_lname}; return ['go.no_phone'] unless $order->{user_phone}; return ['go.no_address'] unless $order->{user_country} && $order->{user_state} && $order->{user_city} && $order->{user_zipcode} && $order->{user_address}; return ['go.no_carddata'] unless $in->{cardnumber} && $in->{cardexpmonth} && $in->{cardexpyear}; my $user_email = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_email}); my $user_address = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_address}); my $user_fname = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_fname}); my $user_lname = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_lname}); my $user_city = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_city}); my $user_state = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_state}); my $user_zipcode = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_zipcode}); my $user_country = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_country}); my $user_phone = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($order->{user_phone}); my $descr = II8b55f24974af3d53369c3d9cea404f55::filters::text2xml::text2xml($pgtxn->getDescription); my $xmlAuthTransaction = qq(<AuthTransaction> <CustomerData> <Email>$user_email</Email> <BillingAddress> <Address1>$user_address</Address1> <Address2>$user_address</Address2> <FirstName>$user_fname</FirstName> <LastName>$user_lname</LastName> <City>$user_city</City> <State>$user_state</State> <Zip>$user_zipcode</Zip> <Country>$user_country</Country> <Phone>$user_phone</Phone> </BillingAddress> </CustomerData> <Total>$amount</Total> <Description>$descr</Description> <AccountInfo> <!-- Can supply either CardAccount or CheckAccount --> <CardAccount> <!-- Supply AccountNumber, ExpirationMonth and ExpirationYear or TrackData --> <AccountNumber>$in->{cardnumber}</AccountNumber> <ExpirationMonth>$in->{cardexpmonth}</ExpirationMonth> <ExpirationYear>$in->{cardexpyear}</ExpirationYear> <!-- Optional --> <CVVNumber>$in->{cardcvc}</CVVNumber> </CardAccount> </AccountInfo> <!-- Optional --> <TransactionControl> <SendCustomerEmail>TRUE</SendCustomerEmail> <SendMerchantEmail>TRUE</SendMerchantEmail> </TransactionControl> <!-- Optional. This information will be saved on our servers and is available in the XML transaction report. This is useful if you want to save your own transaction meta-data with a transaction. -->
</AuthTransaction>);
my $hmac = Digest::HMAC_SHA1->new($settings->{api_key}); $hmac->add($xmlAuthTransaction); my $signature = $hmac->b64digest . '='; my $xmlData = <<END_XML;
<?xml version="1.0"?>
<GatewayInterface>
<APICredentials> <Username>$settings->{api_username}</Username> <PayloadSignature>$signature</PayloadSignature> <TargetGateway>$settings->{gateway_id}</TargetGateway> </APICredentials> $xmlAuthTransaction
</GatewayInterface>
END_XML
$pgtxn->logg('REQ', $xmlData); warn "PG_ITANSACT REQ:\n"; warn $xmlData; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $url = "https://secure.paymentclearing.com/cgi-bin/rc/xmltrans2.cgi"; my $response = $ua->post($url, 'Content-type' => 'text/xml', Content => $xmlData); if (! $response->is_success) { return ['go.internal_processing_error', $response->status_line]; } else { my ($status) = $response->content =~ m!\<Status\>(\w+)\<\/Status\>!si; my ($ErrorCategory) = $response->content =~ m!\<ErrorCategory\>(.+)\<\/ErrorCategory\>!si; my ($ErrorMessage) = $response->content =~ m!\<ErrorMessage\>(.+)\<\/ErrorMessage\>!si; return ['go.payment_failed', "$ErrorCategory: $ErrorMessage"] if $status ne 'ok'; my ($total) = $response->content =~ m!\<Total\>(.+)\<\/Total\>!si; my ($xid) = $response->content =~ m!\<XID\>(.+)\<\/XID\>!si; $pgtxn->txnPayment($xid); $pgtxn->logg('RSP', $response->content); warn "PG_ITANSACT RSP:\n"; warn $response->content; $pgtxn->redirectToReturnPage; } } 1; 