package II5117351e1a4f1d07d1c88690b7a75168::mod_digiwallet_ideal; use strict; use JSON::PP; use LWP::UserAgent; use HTTP::Request; use MIME::Base64 qw/encode_base64/; use IIa67e09caf104f2e50322b7bc59b766fb; use II535843728d21206bdd21a2a084373080; use IIedc3417b3b246250508c70cb08344002; use IIf404c8dfc046e4729558b9aff233579c; use II040d1645cc3e327e8ed2b5eb9fb581ff; use II85c65ba7e286d29307cdb0d3ce685d3c; use IIc006e1d88f66a3969ffd0192be9acb1b; use Data::Dumper; sub checkPGateSettings { my $class = shift; my $settings = shift; my @errors; push @errors, 'check.empty_api_credentials' unless $settings->{shop_id}; eval { local $SIG{__DIE__} = 'DEFAULT'; require Crypt::SSLeay; }; push @errors, ['check.no_mod', 'Crypt::SSLeay'] if $@ && $ENV{HTTP_HOST} ne 'localhost'; @errors; } sub checkProductSettings { my $class = shift; my ($product) = @_; return; } sub go { my $class = shift; my $pgtxn = shift; my $settings = $pgtxn->getPGateSettings; my $url = "https://transaction.digiwallet.nl/ideal/start"; my $order = $pgtxn->getOrder; my $amount = int($pgtxn->getAmount*100); my $form = { ver => 4, rtlo => $settings->{shop_id}, amount => $amount, description => substr( $pgtxn->getDescription, 0, 32 ), test => $settings->{test} ? 1 : 0, returnurl => $pgtxn->getFeedbackURL('return', 'txn'), }; $pgtxn->logg('REQ', $form); my $resp = _send_request($form, 'start'); _debug_log("response var: " . $resp); my @url = split '\|', $resp; Zen->getRequest->redirect($url[1]) if $url[1]; } sub feedbackReturnTxn { my $class = shift; my $pgtxn = shift; my $in = Zen->getRequest->getInput; _debug_log("feedbackReturnTxn: " . Dumper($in)); my $settings = $pgtxn->getPGateSettings; my $form = { ver => 4, rtlo => $settings->{shop_id}, trxid => $in->{trxid}, once => 1 }; my $resp = _send_request($form, 'check'); $pgtxn->txnPayment("DW-IDEAL-" . $in->{trxid}) if $resp  =~ /OK/; $pgtxn->logg('RET', $in); $pgtxn->redirectToReturnPage; } sub feedbackNotifyTxn { my ($class, $pgtxn) = @_; my $in = Zen->getRequest->getInput; my $settings = $pgtxn->getPGateSettings; _debug_log("feedbackNotifyTxn: " . Dumper($in)); $pgtxn->logg('RET', $in); print "Content-type: text/plain\n\n"; if ($in->{eventType} eq 'mandateCreated') { $pgtxn->txnPayment("DW-MRID-" . $in->{mandateRequestID}, "DW-MID-" . $in->{mandateID}) unless $pgtxn->{processed}; _debug_log("feedbackNotifyTxn - txnPayment: " . $in->{eventType} . " - DW-MR-ID: " . $in->{mandateRequestID} . " - DW-M-ID: " . $in->{mandateID}); } elsif ($in->{eventType} eq 'mandateTerminated') { $pgtxn->getSaleOrFirstSaleInBulk->doSubscrCancel; _debug_log("feedbackNotifyTxn - doSubscrCancel: " . $in->{eventType} . " - DW-MR-ID: " . $in->{mandateRequestID} . " - DW-M-ID: " . $in->{mandateID}); } return; } sub _send_request { my ($form, $command) = @_; my $url = "https://transaction.digiwallet.nl/ideal/" . $command; my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $req = HTTP::Request->new('GET', $url . '?' . IIb39071a48a82a07eeb9256f406abebc5::IlIlIlllIllIlIII($II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllllIIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIIIlIIlIIIIIIIl},995,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllllIIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlllllllIlIll})->URLPack($form)); $req->content_type('application/x-www-form-urlencoded'); my $res = $ua->request($req); _debug_log('RES: ' . Dumper($res)); if ($res->code == 200) { return $res->content; } return; } sub _debug_log { my $orig_data = shift; my $dt = II982446f8950cc3dc59e487adba22df54::IlIlllIlIIlIllll($II8dae0e141ee45f5daba6a74e4a7c3b6f::IIllllIllllllIll{$IIb39071a48a82a07eeb9256f406abebc5::llllIIllIIIIIIIl},1010,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIllllIllllllIll{$II720d6e18aa34327713eb014408fc9144::IIIIIIllIIlllIIl})->new; if (open F, '>>' . Zen->getSitebox . 'mod_dw_ideal' . $dt->format('%Y-%m-%d') . '.log') { print F "[" . scalar(localtime) . "]\n"; print F "$orig_data\n"; close F; } } 1; 