package II5117351e1a4f1d07d1c88690b7a75168::mod_paypal_wppdp; use strict; use LWP::UserAgent; use HTTP::Request; use IIa67e09caf104f2e50322b7bc59b766fb; use II535843728d21206bdd21a2a084373080; use IIedc3417b3b246250508c70cb08344002; use IIf404c8dfc046e4729558b9aff233579c; use II040d1645cc3e327e8ed2b5eb9fb581ff; use II85c65ba7e286d29307cdb0d3ce685d3c; use IIc006e1d88f66a3969ffd0192be9acb1b; our %CountriesMap = (UK => 'GB'); sub checkPGateSettings { my $class = shift; my $settings = shift; my @errors; push @errors, 'check.empty_api_credentials' unless $settings->{api_username} && $settings->{api_password} && $settings->{api_signature}; 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 = IIb39071a48a82a07eeb9256f406abebc5::IIllIIllIllIlIII($II982446f8950cc3dc59e487adba22df54::lIlIllIlIlIIlIll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIIIIIIIllIIIIIl},1010,$II982446f8950cc3dc59e487adba22df54::lIlIllIlIlIIlIll{$II720d6e18aa34327713eb014408fc9144::lIIlllIllIlIllll})->new->format('%Y'); my $cardexpmonth = qq(<select name="cardexpmonth">); $cardexpmonth .= qq(<option value="$_"> ) . II982446f8950cc3dc59e487adba22df54::IlIlllIlIIlIllll($II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIlIlIlIlIll{$II720d6e18aa34327713eb014408fc9144::IllIIlIIIIllllII},1010,$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIlIlIlIlIll{$II720d6e18aa34327713eb014408fc9144::IIllllllIIllllll})->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_url = $settings->{test_mode} ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; my $form = { VERSION => '51.0', USER => $settings->{api_username}, PWD => $settings->{api_password}, SIGNATURE => $settings->{api_signature}, AMT => $sale->{amount}, CURRENCYCODE => II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIIIIIIlllIlII($II982446f8950cc3dc59e487adba22df54::lIIIIIIIIIlIIlIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIIlIlIlIlIIIl},81,$II982446f8950cc3dc59e487adba22df54::lIIIIIIIIIlIIlIl{$II982446f8950cc3dc59e487adba22df54::lllIIlIlIIIIlIlI})->getCurrCode, DESC => $sale->{descr}, INVNUM => $sale->getUniqueInvoiceNumber, CREDITCARDTYPE => $carddata->{cardtype}, ACCT => $carddata->{cardnumber}, EXPDATE => ($carddata->{cardexpmonth} > 9 ? '' : '0') . "$carddata->{cardexpmonth}$carddata->{cardexpyear}", CVV2 => $carddata->{cardcvc}, EMAIL => $order->{user_email}, FIRSTNAME => $order->{user_fname}, LASTNAME => $order->{user_lname}, STREET => $order->{user_address}, CITY => $order->{user_city}, STATE => ($order->{user_state} =~ /^\w\w\_(\w+)/ ? $1 : ''), ZIP => $order->{user_zipcode}, COUNTRYCODE => ($CountriesMap{$order->{user_country}} || $order->{user_country}), }; if ($auth_and_void_mode) { $form->{METHOD} = 'DoDirectPayment'; $form->{PAYMENTACTION} = 'Authorization'; $form->{AMT} = II982446f8950cc3dc59e487adba22df54::lllllIllIlIllllI($II720d6e18aa34327713eb014408fc9144::lIIIlllIllIIlllI{$IIb39071a48a82a07eeb9256f406abebc5::lIlIlIllIlllIIII},81,$II720d6e18aa34327713eb014408fc9144::lIIIlllIllIIlllI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllllIIIIIlIllIl})->normalizeAmount(1); } else { $form->{METHOD} = 'DoDirectPayment'; $form->{PAYMENTACTION} = 'Sale'; } $pgate->paylog('APISALE_REQ', $sale, { map { $_ => ( $_ eq 'ACCT' ? ('*' x 12) . substr($form->{$_}, 12, 4) : $_ eq 'CVV2' ? ('*' x (length($form->{$_}))) : "$form->{$_}" ) } keys %$form }); my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $response = $ua->post($api_url, $form); unless ($response->is_success) { $pgate->paylog('APISALE_INTERR', $sale, $response->status_line); return ['go.internal_processing_error', $response->status_line]; } my $respData = II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIIIIIIlllIlII($IIb39071a48a82a07eeb9256f406abebc5::IlllIIlIllllIIIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIIIIIIIllIIIIIl},995,$IIb39071a48a82a07eeb9256f406abebc5::IlllIIlIllllIIIl{$II982446f8950cc3dc59e487adba22df54::lIIlIIIIIlIlIllI})->URLUnpack($response->content); $pgate->paylog('APISALE_RSP', $sale, $respData); unless ($respData->{ACK} eq 'Success' || $respData->{ACK} eq 'SuccessWithWarning') { return ['go.payment_failed', "$respData->{L_SEVERITYCODE0} $respData->{L_ERRORCODE0} '$respData->{L_SHORTMESSAGE0}': $respData->{L_LONGMESSAGE0}"]; } if ($auth_and_void_mode) { my $form1 = { VERSION => '51.0', USER => $settings->{api_username}, PWD => $settings->{api_password}, SIGNATURE => $settings->{api_signature}, METHOD => 'DoVoid', AUTHORIZATIONID => $respData->{TRANSACTIONID}, }; $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 = IIb39071a48a82a07eeb9256f406abebc5::lllllIlIIIIlIIlI($IIb39071a48a82a07eeb9256f406abebc5::IIIIIIIlllIlIIlI{$II982446f8950cc3dc59e487adba22df54::IIlIllllIlIIllIl},995,$IIb39071a48a82a07eeb9256f406abebc5::IIIIIIIlllIlIIlI{$II720d6e18aa34327713eb014408fc9144::IlIIllIlllllIIll})->URLUnpack($response->content); $pgate->paylog('APISALE_RSP', $sale, $respData1); } else { $pgate->paylog('APISALE_INTERR', $sale, $response->status_line); } } if ($is_recur) { my $subscr = II8dae0e141ee45f5daba6a74e4a7c3b6f::llIIlIIlIIIIlIlI($II720d6e18aa34327713eb014408fc9144::lIIIIIllIIIlllll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllIlIIllI},182,$II720d6e18aa34327713eb014408fc9144::lIIIIIllIIIlllll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIlllllIllIIlIl})->getOrCreateForSale($sale); $subscr->{refsale_next_ref_id} = $respData->{TRANSACTIONID}; $subscr->save; $sale->{subscr_id} = $subscr->{subscr_id}; $sale->{txn_code} = $respData->{TRANSACTIONID}; } else { $sale->{txn_code} = $respData->{TRANSACTIONID}; } $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_url = $settings->{test_mode} ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; my $descr = $sale->{descr} . ($sale->{subscr_descr_more} ? " ($sale->{subscr_descr_more})" : ''); substr($descr, 127) = '' if length($descr) > 127; my $invnum = $sale->getUniqueInvoiceNumber; my $form = { VERSION => '57.0', USER => $settings->{api_username}, PWD => $settings->{api_password}, SIGNATURE => $settings->{api_signature}, METHOD => 'DoReferenceTransaction', REFERENCEID => $ref_id, PAYMENTACTION => 'Sale', AMT => II720d6e18aa34327713eb014408fc9144::IIllIllIIlIIIlll($II982446f8950cc3dc59e487adba22df54::lIlllIlllIIIIllI{$IIb39071a48a82a07eeb9256f406abebc5::IllIlIIllIlIIIll},81,$II982446f8950cc3dc59e487adba22df54::lIlllIlllIIIIllI{$II982446f8950cc3dc59e487adba22df54::llIlIIIIllllIIII})->normalizeAmount($sale->{amount}), CURRENCYCODE => IIb39071a48a82a07eeb9256f406abebc5::IIlIIIlIIlIIIlIl($II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$II982446f8950cc3dc59e487adba22df54::lIIlIlIIIIIIllII},81,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$II720d6e18aa34327713eb014408fc9144::llIIIIIlllllIlIl})->getCurrCode, DESC => $descr, INVNUM => $invnum, EMAIL => $order->{user_email}, FIRSTNAME => $order->{user_fname}, LASTNAME => $order->{user_lname}, STREET => $order->{user_address}, CITY => $order->{user_city}, STATE => ($order->{user_state} =~ /^\w\w\_(\w+)/ ? $1 : ''), ZIP => $order->{user_zipcode}, COUNTRYCODE => ($CountriesMap{$order->{user_country}} || $order->{user_country}), }; $pgate->paylog('APIREFSALE_REQ', $sale, $form); my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $response = $ua->post($api_url, $form); unless ($response->is_success) { $pgate->paylog('APIREFSALE_INTERR', $sale, $response->status_line); return; } my $respData = II720d6e18aa34327713eb014408fc9144::IllIIIIlIIlllIll($IIb39071a48a82a07eeb9256f406abebc5::lllllIlIlllIllIl{$IIb39071a48a82a07eeb9256f406abebc5::lIlIlIllIlllIIII},995,$IIb39071a48a82a07eeb9256f406abebc5::lllllIlIlllIllIl{$II982446f8950cc3dc59e487adba22df54::IllIIIlIllllIlll})->URLUnpack($response->content); $pgate->paylog('APIREFSALE_RSP', $sale, $respData); my $txn_id; if ($respData->{ACK} eq 'Success' || $respData->{ACK} eq 'SuccessWithWarning') { $txn_id = $respData->{TRANSACTIONID}; } else { my $payment_error = "$respData->{L_SEVERITYCODE0} $respData->{L_ERRORCODE0} '$respData->{L_SHORTMESSAGE0}': $respData->{L_LONGMESSAGE0}"; $pgate->paylog('APIREFSALE_ERROR', $sale, $payment_error); if ($respData->{L_ERRORCODE0} eq '10001' || $respData->{L_ERRORCODE0} eq '10412') { my $verify_form = { VERSION => '57.0', USER => $settings->{api_username}, PWD => $settings->{api_password}, SIGNATURE => $settings->{api_signature}, METHOD => "TransactionSearch", STARTDATE => II982446f8950cc3dc59e487adba22df54::lllllIllIlIllllI($IIb39071a48a82a07eeb9256f406abebc5::llIIlIIlIIlIllII{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIIlIIlllIIlIlII},1010,$IIb39071a48a82a07eeb9256f406abebc5::llIIlIIlIIlIllII{$II982446f8950cc3dc59e487adba22df54::llIlIIIIllllIIII})->new($sale->{tstamp})->date . ' 00:00:00', INVNUM => $invnum, }; $pgate->paylog('APIREFSALE_VERIFY_REQ', $sale, $verify_form); my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $response = $ua->post($api_url, $verify_form); unless ($response->is_success) { $pgate->paylog('APIREFSALE_VERIFY_INTERR', $sale, $response->status_line); return; } my $verifyData = IIb39071a48a82a07eeb9256f406abebc5::IIlIIIlIIlIIIlIl($IIb39071a48a82a07eeb9256f406abebc5::lIIIIlIlIlllIIlI{$IIb39071a48a82a07eeb9256f406abebc5::lIIIlIllllIIlIll},995,$IIb39071a48a82a07eeb9256f406abebc5::lIIIIlIlIlllIIlI{$II982446f8950cc3dc59e487adba22df54::llIlIIIIllllIIII})->URLUnpack($response->content); $pgate->paylog('APIREFSALE_VERIFY_RSP', $sale, $verifyData); if ($verifyData->{L_STATUS0} eq 'Completed') { $txn_id = $verifyData->{L_TRANSACTIONID0}; } } return (undef, $payment_error) unless $txn_id; } $sale->{txn_code} = $txn_id; $sale->{paid} = 1; $sale->save; $txn_id; } sub apiRefund { my $class = shift; my ($pgate, $sale, $amount) = @_; my $settings = $pgate->getPGateSettings; my $api_url = $settings->{test_mode} ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; my $form = { METHOD => 'RefundTransaction', TRANSACTIONID => $sale->{txn_code}, REFUNDTYPE => ($amount ? 'Partial' : 'Full'), USER => $settings->{api_username}, PWD => $settings->{api_password}, SIGNATURE => $settings->{api_signature}, VERSION => '57.0', }; $form->{AMT} = II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlIlIlIIIlIIlll($II982446f8950cc3dc59e487adba22df54::lIIIIIIIIIlIIlIl{$IIb39071a48a82a07eeb9256f406abebc5::llllIIllIIIIIIIl},81,$II982446f8950cc3dc59e487adba22df54::lIIIIIIIIIlIIlIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlllIllIIIIIllIl})->normalizeAmount($amount) if $amount; $pgate->paylog('APIREFUND_REQ', $sale, $form); my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $response = $ua->post($api_url, $form); unless ($response->is_success) { my $errmsg = $response->status_line; $pgate->paylog('APIREFUND_INTERR', $sale, $errmsg); return $errmsg; } my $respData = IIb39071a48a82a07eeb9256f406abebc5::IIIIIIIllIlIIlll($II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$IIb39071a48a82a07eeb9256f406abebc5::llllIIIlllllIlII},995,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIlllIIIlIIIlIlI{$IIb39071a48a82a07eeb9256f406abebc5::llIIIIIIlIllIlIl})->URLUnpack($response->content); $pgate->paylog('APIREFUND_RSP', $sale, $respData); unless ($respData->{ACK} eq 'Success' || $respData->{ACK} eq 'SuccessWithWarning') { my $errmsg = "$respData->{L_SEVERITYCODE0} $respData->{L_ERRORCODE0} '$respData->{L_SHORTMESSAGE0}': $respData->{L_LONGMESSAGE0}"; $pgate->paylog('APIREFUND_ERROR', $sale, $errmsg); return $errmsg; } return; } sub apiPartialRefundAllowed { 1 } sub apiSubscrCCUpdate { my $class = shift; my ($pgate, $subscr, $carddata) = @_; return ['go.no_carddata'] unless $carddata->{cardnumber} && $carddata->{cardexpmonth} && $carddata->{cardexpyear}; die 'no refsale jvmsub' unless $subscr && $subscr->{refsale_next_ref_id}; my $settings = $pgate->getPGateSettings; my $user = $subscr->getUser; my $sale = $subscr->getInitSale; my $api_url = $settings->{test_mode} ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; my $form = { VERSION => '51.0', USER => $settings->{api_username}, PWD => $settings->{api_password}, SIGNATURE => $settings->{api_signature}, METHOD => 'DoDirectPayment', PAYMENTACTION => 'Authorization', AMT => 1, CURRENCYCODE => IIb39071a48a82a07eeb9256f406abebc5::lIIlIIIlllllllII($II720d6e18aa34327713eb014408fc9144::IllIllllIIIlIIlI{$IIb39071a48a82a07eeb9256f406abebc5::IIlllIIIIlIlllII},81,$II720d6e18aa34327713eb014408fc9144::IllIllllIIIlIIlI{$II982446f8950cc3dc59e487adba22df54::lIlIlllIIIlIlIll})->getCurrCode, DESC => "Credit card data update authorization", INVNUM => IIb39071a48a82a07eeb9256f406abebc5::lllllIlIIIIlIIlI($II982446f8950cc3dc59e487adba22df54::lIlllIlllIIIIllI{$II720d6e18aa34327713eb014408fc9144::lIIIIllIIllIIIlI},1020,$II982446f8950cc3dc59e487adba22df54::lIlllIlllIIIIllI{$II720d6e18aa34327713eb014408fc9144::llIlIIIIIIlIIIIl})->generate, CREDITCARDTYPE => $class->getCardtypeByCardnumber($carddata->{cardnumber}), ACCT => $carddata->{cardnumber}, EXPDATE => ($carddata->{cardexpmonth} > 9 ? '' : '0') . "$carddata->{cardexpmonth}$carddata->{cardexpyear}", CVV2 => $carddata->{cardcvc}, EMAIL => $user->{email}, FIRSTNAME => $user->{fname}, LASTNAME => $user->{lname}, STREET => $user->{address}, CITY => $user->{city}, STATE => ($user->{state} =~ /^\w\w\_(\w+)/ ? $1 : ''), ZIP => $user->{zipcode}, COUNTRYCODE => ($CountriesMap{$user->{country}} || $user->{country}), }; $pgate->paylog('APISUBSCRCCUPDATE_REQ', $sale, { map { $_ => ( $_ eq 'ACCT' ? ('*' x 12) . substr($form->{$_}, 12, 4) : $_ eq 'CVV2' ? ('*' x (length($form->{$_}))) : "$form->{$_}" ) } keys %$form }); my $ua = LWP::UserAgent->new; $ua->timeout(180); $ua->env_proxy; my $response = $ua->post($api_url, $form); unless ($response->is_success) { $pgate->paylog('APISUBSCRCCUPDATE_INTERR', $sale, $response->status_line); return ['go.internal_processing_error', $response->status_line]; } my $respData = II720d6e18aa34327713eb014408fc9144::IllIIIIlIIlllIll($II720d6e18aa34327713eb014408fc9144::llIlIIIlIlIlIlIl{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllIlIIllI},995,$II720d6e18aa34327713eb014408fc9144::llIlIIIlIlIlIlIl{$IIb39071a48a82a07eeb9256f406abebc5::IlIIllllllIIIlll})->URLUnpack($response->content); $pgate->paylog('APISUBSCRCCUPDATE_RSP', $sale, $respData); unless ($respData->{ACK} eq 'Success' || $respData->{ACK} eq 'SuccessWithWarning') { return ['go.payment_failed', "$respData->{L_SEVERITYCODE0} $respData->{L_ERRORCODE0} '$respData->{L_SHORTMESSAGE0}': $respData->{L_LONGMESSAGE0}"]; } my $form1 = { VERSION => '51.0', USER => $settings->{api_username}, PWD => $settings->{api_password}, SIGNATURE => $settings->{api_signature}, METHOD => 'DoVoid', AUTHORIZATIONID => $respData->{TRANSACTIONID}, }; $pgate->paylog('APISUBSCRCCUPDATE_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 = IIb39071a48a82a07eeb9256f406abebc5::IlIlIlllIllIlIII($II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIlIIIIIIlIIII{$II982446f8950cc3dc59e487adba22df54::IIlIllllIlIIllIl},995,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIlIIIIIIlIIII{$IIb39071a48a82a07eeb9256f406abebc5::IlIIllllllIIIlll})->URLUnpack($response->content); $pgate->paylog('APISUBSCRCCUPDATE_RSP', $sale, $respData1); } else { $pgate->paylog('APISUBSCRCCUPDATE_INTERR', $sale, $response->status_line); } $subscr->{refsale_next_ref_id} = $respData->{TRANSACTIONID}; $subscr->save; return; } sub getCardtypeByCardnumber { my $class = shift; my $cn = shift; return $cn =~ /^4/ ? 'Visa' : $cn =~ /^5[1-5]/ ? 'MasterCard' : $cn =~ /^6/ ? 'Discover' : $cn =~ /^3(4|7)/ ? 'Amex' : $cn =~ /^4/ ? 'Maestro' : $cn =~ /^(6334|6767)/ ? 'Solo' : ''; } 1; 