package II5117351e1a4f1d07d1c88690b7a75168::mod_protx; use strict; use Digest::MD5; use LWP::UserAgent; use HTTP::Request; use IIef11385558db207cf8b1321ea6156940; sub checkPGateSettings { my $class = shift; my $settings = shift; my @errors; push @errors, 'check.empty_vendor' unless $settings->{vendor}; eval { local $SIG{__DIE__} = 'DEFAULT'; require Crypt::SSLeay; }; push @errors, ['check.no_ssl', 'Crypt::SSLeay'] if $@; @errors; } sub checkProductSettings { my $class = shift; my ($product) = @_; my @errors; @errors; } sub go { my $class = shift; my $pgtxn = shift; my $settings = $pgtxn->getPGateSettings; my $order = $pgtxn->getOrder; my $size_string = sub { my ($str, $l) = @_; $str = substr($str, 0, $l) if length($str) > $l; $str; }; my $registerData = { VPSProtocol => '2.23', TxType => 'PAYMENT', Vendor => $settings->{vendor}, VendorTxCode => $pgtxn->getInvoiceNumber, Amount => $pgtxn->getAmount, Currency => $pgtxn->getCurrencyCode, Description => &$size_string($pgtxn->getDescription, 100), NotificationURL => $pgtxn->getFeedbackURL('notify', 'txn'), BillingSurname => &$size_string($order->{user_lname}, 20), BillingFirstnames => &$size_string($order->{user_fname}, 20), BillingAddress1 => &$size_string($order->{user_address}, 100), BillingCity => &$size_string($order->{user_city}, 40), BillingPostCode => &$size_string($order->{user_zipcode}, 10), BillingState => ($order->{user_country} eq 'US' ? substr($order->{user_state}, 3, 2) : ''), BillingCountry => $order->{user_country}, }; $registerData->{"Delivery$_"} = $registerData->{"Billing$_"} for qw/Surname Firstnames Address1 City PostCode Country State/; $pgtxn->logg('REG', $registerData); my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $registerUrl = $settings->{test_mode} ? 'https://test.sagepay.com/gateway/service/vspserver-register.vsp' : 'https://live.sagepay.com/gateway/service/vspserver-register.vsp'; my $response = $ua->post($registerUrl, $registerData); II8dae0e141ee45f5daba6a74e4a7c3b6f::lllIlIIIIlIIlIll($IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$II982446f8950cc3dc59e487adba22df54::IlIllIIIlllIlIll},130,$IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$II982446f8950cc3dc59e487adba22df54::llllllIlIIIIllII})->true($response->is_success, "error occured when trying to register Protx transaction: " . $response->status_line); my $responseData = $response->content; my $registerResponse = {}; for my $pair (grep { /\S/ } split(/\r?\n/, $responseData)) { my ($k, $v) = split '=', $pair; $registerResponse->{$k} = $v; } $pgtxn->logg('REGRSP', $registerResponse); II8dae0e141ee45f5daba6a74e4a7c3b6f::lllIlIIIIlIIlIll($II982446f8950cc3dc59e487adba22df54::IllIIIlllllIIlll{$IIb39071a48a82a07eeb9256f406abebc5::lIlIlllIIlIllIII},130,$II982446f8950cc3dc59e487adba22df54::IllIIIlllllIIlll{$IIb39071a48a82a07eeb9256f406abebc5::IIlIllIIlIIIlIIl})->true(($registerResponse->{Status} =~ /^OK/ ? 1 : 0), "Failed to send the transaction request: ($registerResponse->{Status}) $registerResponse->{StatusDetail} <br>Please contact server administrator."); my ($VPSTxId) = $registerResponse->{VPSTxId}; $VPSTxId =~ s/\{(.*)\}/$1/; $pgtxn->{txn_code} = $VPSTxId . '::' . $registerResponse->{SecurityKey}; $pgtxn->save; $pgtxn->getSaleOrFirstSaleInBulk->txnWaitingInit; Zen->getRequest->redirect($registerResponse->{NextURL}); } sub feedbackReturnTxn { my $class = shift; my $pgtxn = shift; $pgtxn->logg('RET', Zen->getRequest->getInput); $pgtxn->redirectToReturnPage; } sub feedbackNotifyTxn { my $class = shift; my $pgtxn = shift; my $settings = $pgtxn->getPGateSettings; my $in = Zen->getRequest->getInput; $pgtxn->logg('NTF', $in); my ($VPSTxId, $SecurityKey) = split '::', $pgtxn->{txn_code}; my $PostMessage = $in->{VPSTxId} . $in->{VendorTxCode} . $in->{Status} . $in->{TxAuthNo} . $settings->{vendor} . $in->{AVSCV2} . $SecurityKey .	$in->{AddressResult} . $in->{PostCodeResult} . $in->{CV2Result} . $in->{GiftAid} . $in->{'3DSecureStatus'} . $in->{CAVV}; my $md5 = Digest::MD5->new; $md5->add($PostMessage); my $MySignature = uc($md5->hexdigest); $in->{VPSTxId} =~ s/\{(.*)\}/$1/; if ($MySignature eq $in->{VPSSignature} && $in->{VPSTxId} eq $VPSTxId) { $pgtxn->logg('VRF', 'VERIFIED'); $pgtxn->txnPayment($in->{VPSTxId}) if $in->{Status} eq 'OK'; } else { $pgtxn->logg('VRF', 'NOT VERIFIED'); } $pgtxn->getSaleOrFirstSaleInBulk->txnWaitingClose; print "Content-type: text/plain\r\n\r\nStatus=OK\r\nRedirectURL=" . $pgtxn->getFeedbackURL('return', 'txn'); return; } 1; 