package II5117351e1a4f1d07d1c88690b7a75168::mod_pagseguro; use strict; sub checkPGateSettings { my $class = shift; my $settings = shift; my $user = Zen->getRequest->getCtx->{User}->getDecorated; my @errors; push @errors, 'check.empty_settings' unless $settings->{merchant_email} && $settings->{token}; push @errors, 'check.invalid_currency' if $user->getSys->getMerchantSettings->{currency} ne 'BRL'; @errors; } sub checkProductSettings { my $class = shift; my ($product) = @_; my @errors; push @errors, 'check.invalid_currency' if $product->getSys->getMerchantSettings->{currency} ne 'BRL'; @errors; } sub go { my $class = shift; my $pgtxn = shift; my $settings = $pgtxn->getPGateSettings; my $user = $pgtxn->getOrder->getUser; my $url = "https://pagseguro.uol.com.br/security/webpagamentos/webpagto.aspx"; my $form = { email_cobranca => $settings->{merchant_email}, tipo => 'CP', moeda => $pgtxn->getCurrencyCode, item_id_1 => $pgtxn->getInvoiceNumber, item_descr_1 => $pgtxn->getDescription, item_quant_1 => 1, item_valor_1 => $pgtxn->getAmount * 100, item_frete_1 => '0', ref_transacao => $pgtxn->{id}, }; $pgtxn->logg('REQ', $form); Zen->getRequest->redirectPOST($url, $form); } sub feedbackReturnPgo { my $class = shift; my $pgate = shift; my $in = Zen->getRequest->getInput; my $settings = $pgate->getView->{SettingsUnpacked}; Zen->getRequest->redirect(II982446f8950cc3dc59e487adba22df54::lllIllIIIlllIIIl($II982446f8950cc3dc59e487adba22df54::IIlIllIIIllllIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIllIIlIllIlIIl},47,$II982446f8950cc3dc59e487adba22df54::IIlIllIIIllllIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIlIlIIIIllIIIl})->getURI . "/pgate/pagseguro/return.html?pgate_id=$pgate->{id}") unless $in->{Referencia}; my $pgtxn = $pgate->getPGTxnClass->get($in->{Referencia}); $pgtxn->checkValidForRequest; $pgtxn->logg('RET', $in); my $url = 'https://pagseguro.uol.com.br/Security/NPI/Default.aspx'; my $query = (join '&', map { "$_=" . $in->{$_} } keys %$in) .'&Comando=validar&Token=' . $settings->{token}; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new('POST', $url); $req->content_type('application/x-www-form-urlencoded'); $req->content($query); my $response = $ua->request($req); II720d6e18aa34327713eb014408fc9144::llllIlIlIIIIIIlI($IIb39071a48a82a07eeb9256f406abebc5::IlllIllIllIllIll{$II982446f8950cc3dc59e487adba22df54::IIlIllllIlIIllIl},130,$IIb39071a48a82a07eeb9256f406abebc5::IlllIllIllIllIll{$IIb39071a48a82a07eeb9256f406abebc5::llIIIllIIlIIIIIl})->true($response->is_success, "error occured when trying to verify transaction: " . $response->status_line); if ($response->content eq 'VERIFICADO') { $pgtxn->logg('VRF', 'VERIFIED'); if($in->{StatusTransacao} eq 'Completo' || $in->{StatusTransacao} eq 'Aprovado') { $pgtxn->txnPayment($in->{'TransacaoID'}); } elsif($in->{StatusTransacao} eq 'Cancelado') { $pgtxn->txnRefund; } } elsif ($response->content eq 'FALSO') { $pgtxn->logg('VRF', 'NOT VERIFIED'); } $pgtxn->redirectToReturnPage; } 1; 