package II5117351e1a4f1d07d1c88690b7a75168::mod_paypal_payflow; use strict; use LWP::UserAgent; use HTTP::Request; use IIa67e09caf104f2e50322b7bc59b766fb; use II535843728d21206bdd21a2a084373080; use IIedc3417b3b246250508c70cb08344002; use IIf404c8dfc046e4729558b9aff233579c; use II040d1645cc3e327e8ed2b5eb9fb581ff; use IIe27820f4c94bc1b5d7f300a1ecc438c8; use II85c65ba7e286d29307cdb0d3ce685d3c; use II744b50efb3a376e05cd7c2d9214a0432; use IIc006e1d88f66a3969ffd0192be9acb1b; our %CountriesMap = (UK => 'GB'); sub checkPGateSettings { my $class = shift; my $settings = shift; my @errors; push @errors, 'check.empty_payflow_credentials' unless $settings->{payflow_vendor} && $settings->{payflow_pwd}; 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) = @_; my @errors; @errors; } sub getOrderProcessFormAddon { my $class = shift; my ($config, $settings, $singleProduct) = @_; my $sysURI = Zen::ScriptSys->getURI; my $msg_cardtype = $config->{addons}{cardtype}; my $msg_cardnumber = $config->{addons}{cardnumber}; my $msg_expiration = $config->{addons}{expiration}; my $msg_verification_code = $config->{addons}{verification_code}; my $cardtype = qq(<select name="cardtype">); while (my ($v, $l) = each %{$config->{credit_card_types}}) { $cardtype .= qq(<option value="$v"> $l); } $cardtype .= qq(</select>); my $this_year = II720d6e18aa34327713eb014408fc9144::llllllIlIIIIllll($IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIIlIlIlIlIIIl},1010,$IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$II982446f8950cc3dc59e487adba22df54::IlIllIlIlIIlIlll})->new->format('%Y'); my $cardexpmonth = qq(<select name="cardexpmonth">); $cardexpmonth .= qq(<option value="$_"> ) . II982446f8950cc3dc59e487adba22df54::lllIllIIIlllIIIl($II720d6e18aa34327713eb014408fc9144::IllIllllIIIlIIlI{$II720d6e18aa34327713eb014408fc9144::IlllllIlIIIIlIll},1010,$II720d6e18aa34327713eb014408fc9144::IllIllllIIIlIIlI{$II982446f8950cc3dc59e487adba22df54::lIIlllIlIllllIIl})->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_cardtype</span> <span style="display: table-cell">$cardtype</span>
</div>
<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 $request = Zen->getRequest; my $in = $request->getInput; return ['go.no_bulk_payment'] unless $pgtxn->{sale_id}; my $pgate = $pgtxn->getPGate; my $sale = $pgtxn->getSale; if (my $error = $pgate->apiSale($sale, $in, [$sale->getProduct, $sale->getOrder->getPackage])) { return ['', $error]; } $pgtxn->{successful} = 1; $pgtxn->{processed} = 1; $pgtxn->{txn_code} ||= $sale->{txn_code}; $pgtxn->save; $pgtxn->redirectToReturnPage; } sub apiSale { my $class = shift; my ($pgate, $sale, $carddata) = @_; return ['go.no_carddata'] unless $carddata->{cardnumber} && $carddata->{cardexpmonth} && $carddata->{cardexpyear} && $carddata->{cardtype}; my $settings = $pgate->getPGateSettings; my $order = $sale->getOrder; my $prod = $sale->getProduct; my $is_recur = $prod->isRecur; my $auth_and_void_mode = $is_recur && $sale->{amount} == 0; my $api_host = $settings->{test_mode} ? 'pilot-payflowpro.paypal.com' : 'payflowpro.paypal.com'; my $api_url = "https://$api_host"; my $form = { USER => ($settings->{payflow_user} || $settings->{payflow_vendor}), VENDOR => $settings->{payflow_vendor}, PARTNER => ($settings->{payflow_partner} || 'PayPal'), PWD => $settings->{payflow_pwd}, TRXTYPE => 'S', TENDER => 'C', ACCT => $carddata->{cardnumber}, EXPDATE => ($carddata->{cardexpmonth} > 9 ? '' : '0') . "$carddata->{cardexpmonth}$carddata->{cardexpyear}", AMT => $sale->{amount}, COMMENT1 => $prod->{title}, CVV2 => $carddata->{cardcvc}, EMAIL => $order->{user_email}, FIRSTNAME => $order->{user_fname}, LASTNAME => $order->{user_lname}, STREET => $order->{user_address}, ZIP => $order->{user_zipcode}, CITY => $order->{user_city}, STATE => ($order->{user_state} =~ /^\w\w\_(\w+)/ ? $1 : ''), BILLTOCOUNTRY => ($CountriesMap{$order->{user_country}} || $order->{user_country}), CURRENCY => II982446f8950cc3dc59e487adba22df54::IIIlIIlIllIIIlIl($II982446f8950cc3dc59e487adba22df54::lIlllIlllIIIIllI{$IIb39071a48a82a07eeb9256f406abebc5::IIlllIIIIlIlllII},81,$II982446f8950cc3dc59e487adba22df54::lIlllIlllIIIIllI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIlIlIIIIllIIIl})->getCurrCode, VERBOSITY => 'MEDIUM', }; if ($auth_and_void_mode) { $form->{TRXTYPE} = 'A'; $form->{AMT} => IIb39071a48a82a07eeb9256f406abebc5::IIIIllIllIlIIIlI($II982446f8950cc3dc59e487adba22df54::IlllIlIlllIIllIl{$II982446f8950cc3dc59e487adba22df54::lIIlIlIlllIIllIl},81,$II982446f8950cc3dc59e487adba22df54::IlllIlIlllIIllIl{$II982446f8950cc3dc59e487adba22df54::llIlIIIIllllIIII})->normalizeAmount(1); } $pgate->paylog('APISALE_REQ', $sale, { map { $_ => ( $_ eq 'ACCT' ? ('*' x 12) . substr($form->{$_}, 12, 4) : $_ eq 'CVV2' ? ('*' x (length($form->{$_}))) : "$form->{$_}" ) } keys %$form }); my $parmlist = join '&', map { my $v = $form->{$_}; $v =~ s/\"//g; $_.'['.length($v).']='.$v } keys %$form; my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $request = HTTP::Request->new(POST => $api_url); $request->header('Content-Length' => length($parmlist)); $request->header('Content-Type' => 'text/namevalue'); $request->header('Host' => $api_host); $request->header('X-VPS-REQUEST-ID' => IIb39071a48a82a07eeb9256f406abebc5::IlIlIlllIllIlIII($IIb39071a48a82a07eeb9256f406abebc5::IlllIIlIllllIIIl{$II720d6e18aa34327713eb014408fc9144::IllIIlIIIIllllII},1020,$IIb39071a48a82a07eeb9256f406abebc5::IlllIIlIllllIIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllllIIIIIlIllIl})->generate); $request->header('X-VPS-CLIENT-TIMEOUT' => 45); $request->header('X-VPS-VIT-INTEGRATION-PRODUCT' => 'Delavo'); my (undef, $delavo_version) = II8dae0e141ee45f5daba6a74e4a7c3b6f::lllIlIIIIlIIlIll($II720d6e18aa34327713eb014408fc9144::lIIIlIlIlllIIIll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIIlIlIlIlIIIl},15,$II720d6e18aa34327713eb014408fc9144::lIIIlIlIlllIIIll{$II720d6e18aa34327713eb014408fc9144::IllIllIIlIIIIlIl})->versions; $request->header('X-VPS-VIT-INTEGRATION-VERSION' => $delavo_version); $request->content($parmlist); my $response = $ua->request($request); unless ($response->is_success) { $pgate->paylog('APISALE_INTERR', $sale, $response->status_line); return ['go.internal_processing_error', $response->status_line]; } my $respData = II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlIlIlIIIlIIlll($IIb39071a48a82a07eeb9256f406abebc5::lllllIlIlllIllIl{$II720d6e18aa34327713eb014408fc9144::llIlIIIIlIllIIll},995,$IIb39071a48a82a07eeb9256f406abebc5::lllllIlIlllIllIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlllIllIIIIIllIl})->URLUnpack($response->content); $pgate->paylog('APISALE_RSP', $sale, $respData); unless ($respData->{RESULT} eq '0') { return ['go.payment_failed', "RESULT($respData->{RESULT}) $respData->{RESPMSG}"]; } if ($auth_and_void_mode) { my $form1 = { USER => ($settings->{payflow_user} || $settings->{payflow_vendor}), VENDOR => $settings->{payflow_vendor}, PARTNER => ($settings->{payflow_partner} || 'PayPal'), PWD => $settings->{payflow_pwd}, TRXTYPE => 'V', TENDER => 'C', ORIGID => $respData->{RPREF}, }; $pgate->paylog('APISALE_REQ', $sale, $form1); my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $response = $ua->post($api_url, $form1); if ($response->is_success) { my $respData1 = II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIllIIllIlIIll($II720d6e18aa34327713eb014408fc9144::lIlIIIIlIllllIIl{$IIb39071a48a82a07eeb9256f406abebc5::lIlIlllIIlIllIII},995,$II720d6e18aa34327713eb014408fc9144::lIlIIIIlIllllIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllllIIIIIlIllIl})->URLUnpack($response->content); $pgate->paylog('APISALE_RSP', $sale, $respData1); } else { $pgate->paylog('APISALE_INTERR', $sale, $response->status_line); } } if ($is_recur) { my $subscr = II720d6e18aa34327713eb014408fc9144::llllllIlIIIIllll($II982446f8950cc3dc59e487adba22df54::IIlIllIIIllllIIl{$II982446f8950cc3dc59e487adba22df54::IIlIllllIlIIllIl},182,$II982446f8950cc3dc59e487adba22df54::IIlIllIIIllllIIl{$II982446f8950cc3dc59e487adba22df54::IllIIIlIllllIlll})->getOrCreateForSale($sale); $subscr->{refsale_next_ref_id} = $respData->{PNREF}; $subscr->save; $sale->{subscr_id} = $subscr->{subscr_id}; $sale->{txn_code} = $respData->{PNREF}; } else { $sale->{txn_code} = $respData->{PNREF}; } $sale->{ccs_id} = $carddata->{ccs_id} if $carddata->{ccs_id}; $sale->{paid} = 1; $sale->save; return; } sub apiReferenceSale { my $class = shift; my ($pgate, $sale, $ref_id) = @_; my $settings = $pgate->getPGateSettings; my $order = $sale->getOrder; my $api_host = $settings->{test_mode} ? 'pilot-payflowpro.paypal.com' : 'payflowpro.paypal.com'; my $api_url = "https://$api_host"; my $form = { USER => ($settings->{payflow_user} || $settings->{payflow_vendor}), VENDOR => $settings->{payflow_vendor}, PARTNER => ($settings->{payflow_partner} || 'PayPal'), PWD => $settings->{payflow_pwd}, TRXTYPE => 'S', TENDER => 'C', ORIGID => $ref_id, AMT => II720d6e18aa34327713eb014408fc9144::IlIlIlIIIIllIlII($II982446f8950cc3dc59e487adba22df54::IIlIllIIIllllIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIIIIIIIllIIIIIl},81,$II982446f8950cc3dc59e487adba22df54::IIlIllIIIllllIIl{$II982446f8950cc3dc59e487adba22df54::llllllIlIIIIllII})->normalizeAmount($sale->{amount}), EMAIL => $order->{user_email}, FIRSTNAME => $order->{user_fname}, LASTNAME => $order->{user_lname}, STREET => $order->{user_address}, ZIP => $order->{user_zipcode}, CITY => $order->{user_city}, STATE => ($order->{user_state} =~ /^\w\w\_(\w+)/ ? $1 : ''), BILLTOCOUNTRY => ($CountriesMap{$order->{user_country}} || $order->{user_country}), }; $pgate->paylog('APIREFSALE_REQ', $sale, $form); my $parmlist = join '&', map { my $v = $form->{$_}; $v =~ s/\"//g; $_.'['.length($v).']='.$v } keys %$form; my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $request = HTTP::Request->new(POST => $api_url); $request->header('Content-Length' => length($parmlist)); $request->header('Content-Type' => 'text/namevalue'); $request->header('Host' => $api_host); $request->header('X-VPS-REQUEST-ID' => II982446f8950cc3dc59e487adba22df54::IIllIIllIIIlllll($II982446f8950cc3dc59e487adba22df54::IIllllIlIIIIIlll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIIlIIlllIIlIlII},1020,$II982446f8950cc3dc59e487adba22df54::IIllllIlIIIIIlll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIlIlIIIIllIIIl})->generate); $request->header('X-VPS-CLIENT-TIMEOUT' => 45); $request->header('X-VPS-VIT-INTEGRATION-PRODUCT' => 'Delavo'); my (undef, $delavo_version) = IIb39071a48a82a07eeb9256f406abebc5::IIIIllIllIlIIIlI($II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIlIlIlIlIll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIllIIlIllIlIIl},15,$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIlIlIlIlIll{$II982446f8950cc3dc59e487adba22df54::IlIllIlIlIIlIlll})->versions; $request->header('X-VPS-VIT-INTEGRATION-VERSION' => $delavo_version); $request->content($parmlist); my $response = $ua->request($request); unless ($response->is_success) { $pgate->paylog('APIREFSALE_INTERR', $sale, $response->status_line); return; } my $respData = II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIllIIllIlIIll($II720d6e18aa34327713eb014408fc9144::IIlllIIllllIlIll{$IIb39071a48a82a07eeb9256f406abebc5::lIlIlllIIlIllIII},995,$II720d6e18aa34327713eb014408fc9144::IIlllIIllllIlIll{$II982446f8950cc3dc59e487adba22df54::llllllIlIIIIllII})->URLUnpack($response->content); $pgate->paylog('APIREFSALE_RSP', $sale, $respData); unless ($respData->{RESULT} eq '0') { my $payment_error = "RESULT($respData->{RESULT}) $respData->{RESPMSG}"; $pgate->paylog('APIREFSALE_ERROR', $sale, $payment_error); return (undef, $payment_error); } $sale->{txn_code} = $respData->{PNREF}; $sale->{paid} = 1; $sale->save; $sale->{txn_code}; } sub apiRefund { my $class = shift; my ($pgate, $sale, $amount) = @_; my $settings = $pgate->getPGateSettings; my $api_host = $settings->{test_mode} ? 'pilot-payflowpro.paypal.com' : 'payflowpro.paypal.com'; my $api_url = "https://$api_host"; my $form = { USER => ($settings->{payflow_user} || $settings->{payflow_vendor}), VENDOR => $settings->{payflow_vendor}, PARTNER => ($settings->{payflow_partner} || 'PayPal'), PWD => $settings->{payflow_pwd}, TRXTYPE => 'C', TENDER => 'C', ORIGID => $sale->{txn_code}, AMT => IIb39071a48a82a07eeb9256f406abebc5::lllllIlIIIIlIIlI($IIb39071a48a82a07eeb9256f406abebc5::IlllIllIllIllIll{$IIb39071a48a82a07eeb9256f406abebc5::IlIlIIIIlllIIIlI},81,$IIb39071a48a82a07eeb9256f406abebc5::IlllIllIllIllIll{$II982446f8950cc3dc59e487adba22df54::lIIlIIIIIlIlIllI})->normalizeAmount($amount || $sale->{amount}), }; $pgate->paylog('APIREFUND_REQ', $sale, $form); my $parmlist = join '&', map { my $v = $form->{$_}; $v =~ s/\"//g; $_.'['.length($v).']='.$v } keys %$form; my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $request = HTTP::Request->new(POST => $api_url); $request->header('Content-Length' => length($parmlist)); $request->header('Content-Type' => 'text/namevalue'); $request->header('Host' => $api_host); $request->header('X-VPS-REQUEST-ID' => II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlIlIlIIIlIIlll($II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIIIlIlIlIII{$IIb39071a48a82a07eeb9256f406abebc5::lIIlIlIlIlllIIII},1020,$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIIIlIlIlIII{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllllIIIIIlIllIl})->generate); $request->header('X-VPS-CLIENT-TIMEOUT' => 45); $request->header('X-VPS-VIT-INTEGRATION-PRODUCT' => 'Delavo'); my (undef, $delavo_version) = II720d6e18aa34327713eb014408fc9144::lIIlIIlIIIIlIIIl($II720d6e18aa34327713eb014408fc9144::lIIllIIIlIlIlIIl{$IIb39071a48a82a07eeb9256f406abebc5::llllIIllIIIIIIIl},15,$II720d6e18aa34327713eb014408fc9144::lIIllIIIlIlIlIIl{$II982446f8950cc3dc59e487adba22df54::IlIllIlIlIIlIlll})->versions; $request->header('X-VPS-VIT-INTEGRATION-VERSION' => $delavo_version); $request->content($parmlist); my $response = $ua->request($request); unless ($response->is_success) { my $errmsg = $response->status_line; $pgate->paylog('APIREFUND_INTERR', $sale, $errmsg); return $errmsg; } my $respData = II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlIlIlIIIlIIlll($IIb39071a48a82a07eeb9256f406abebc5::IIIIIIIlllIlIIlI{$II720d6e18aa34327713eb014408fc9144::lIIIIIlIIIlIIIII},995,$IIb39071a48a82a07eeb9256f406abebc5::IIIIIIIlllIlIIlI{$II982446f8950cc3dc59e487adba22df54::IllIIllIIIIlIIll})->URLUnpack($response->content); $pgate->paylog('APIREFUND_RSP', $sale, $respData); unless ($respData->{RESULT} eq '0') { my $errmsg = "RESULT($respData->{RESULT}) $respData->{RESPMSG}"; $pgate->paylog('APIREFUND_ERROR', $sale, $errmsg); return $errmsg; } return; } sub apiPartialRefundAllowed { 1 } 1; 