function cw_paypal_pro_payflow_request($params) { global $REMOTE_ADDR; global $pp_final_action; extract($params); $is_extcard = false; $cardtype = 8; if (cw_payment_cc_is_visa($userinfo["card_number"])) { $cardtype = 0; } elseif (cw_payment_cc_is_mc($userinfo["card_number"])) { $cardtype = 1; } elseif (cw_payment_cc_is_dc($userinfo["card_number"])) { $cardtype = 2; } elseif (cw_payment_cc_is_amex($userinfo["card_number"])) { $cardtype = 3; } elseif (cw_payment_cc_is_diners($userinfo["card_number"])) { $cardtype = 4; } elseif (cw_payment_cc_is_jcb($userinfo["card_number"])) { $cardtype = 5; } elseif (cw_payment_cc_is_solo($userinfo["card_number"])) { $is_extcard = true; $cardtype = "S"; } elseif (cw_payment_cc_is_switch($userinfo["card_number"])) { $is_extcard = true; $cardtype = 9; } $cart =& cw_session_register('cart'); $secure_oid =& cw_session_register('secure_oid'); $post = array("tender" => "C", "trxtype" => $pp_final_action == 'Sale' ? 'S' : 'A', "acct" => $userinfo["card_number"], "accttype" => $cardtype, "amt" => $cart['info']['total'], "street" => $userinfo['main_address']['address'] . ($userinfo['main_address']['address_2'] ? $userinfo['main_address']['address_2'] : ''), "city" => $userinfo['main_address']['city'], "state" => $userinfo['main_address']['state'], "country" => $userinfo['main_address']['country'], "zip" => $userinfo['main_address']['zipcode'], "buttonsource" => '', "clientip" => cw_get_valid_ip($REMOTE_ADDR), "currency" => true, "custom" => implode(',', $secure_oid), "cvv2" => $userinfo['card_cvv2'], "email" => $userinfo['email'], "expdate" => $userinfo['card_expire'], "invnum" => $doc_ids[0], "shiptostreet" => $userinfo['current_address']['address'] . ($userinfo['current_address']['address_2'] ? $userinfo['current_address']['address_2'] : ''), "shiptocity" => $userinfo['current_address']['city'], "shiptostate" => $userinfo['current_address']['state'], "shiptocountry" => $userinfo['current_address']['country'], "shiptozip" => $userinfo['current_address']['zipcode'], "firstname" => $userinfo['current_address']['firstname'], "lastname" => $userinfo['current_address']['lastname']); if ($is_extcard) { $post['cardissue'] = $userinfo['card_issue_no']; $post['cardstart'] = $userinfo["card_valid_from"]; } //cw_log_add('payflow_pro', array('post'=>$post)); $res = cw_paypal_pro_payflow_do($post); $err = cw_paypal_pro_payflow_prepare_errors($res); if ($err) { return $err; } $res = $res[2]; $res['status'] = 'success'; return $res; }
function cw_payment_paypalpro_run_processor($params, $return) { if ($params['payment_data']['processor'] == 'paypal_pro') { extract($params); global $config, $current_location; $cart =& cw_session_register('cart'); $secure_oid =& cw_session_register('secure_oid'); $pp_total = sprintf("%0.2f", $cart['info']['total']); $pp_final_action = $config['paypal_pro']['use_preauth'] == 'Y' ? 'Authorization' : 'Sale'; $pp_username = $config['paypal_pro']['api_access']; $pp_password = $config['paypal_pro']['api_password']; $pp_currency = $config['paypal_pro']['currency']; $pp_cert_file = $app_dir . '/' . $config['paypal_pro']['api_cert_path']; $pp_signature = $config['paypal_pro']['api_signature']; $notify_url = $current_location . '/payment/index.php?target=paypal_pro'; $pp_use_cert = $config['paypal_pro']['auth_type'] == 'C'; $pp_signature_txt = $pp_use_cert ? "" : "<Signature>" . $pp_signature . "</Signature>"; if ($config['paypal_pro']['test_mode'] == "N") { $pp_url = $config['paypal_pro']['auth_type'] == 'C' ? "https://api.paypal.com:443/2.0/" : "https://api-3t.paypal.com:443/2.0/"; $pp_customer_url = "https://www.paypal.com"; } else { $pp_url = $config['paypal_pro']['auth_type'] == 'C' ? "https://api.sandbox.paypal.com:443/2.0/" : "https://api-aa.sandbox.paypal.com:443/2.0/"; $pp_customer_url = "https://www.sandbox.paypal.com"; } $avs_codes = array("A" => "Address Address only (no ZIP)", "B" => "International 'A'. Address only (no ZIP)", "C" => "International 'N'", "D" => "International 'X'. Address and Postal Code", "E" => "Not allowed for MOTO (Internet/Phone) transactions", "F" => "UK-specific X Address and Postal Code", "G" => "Global Unavailable", "I" => "International Unavailable", "N" => "None", "P" => "Postal Code only (no Address)", "R" => "Retry", "S" => "Service not Supported", "U" => "Unavailable", "W" => "Nine-digit ZIP code (no Address)", "X" => "Exact match. Address and five-digit ZIP code", "Y" => "Address and five-digit ZIP", "Z" => "Five-digit ZIP code (no Address)"); $cvv_codes = array("M" => "Match", "N" => "No match", "P" => "Not Processed", "S" => "Service not Supported", "U" => "Unavailable", "X" => "No response"); if (cw_payment_cc_is_visa($userinfo["card_number"])) { $pp_cardtype = "Visa"; } if (cw_payment_cc_is_mc($userinfo["card_number"])) { $pp_cardtype = "MasterCard"; } if (cw_payment_cc_is_dc($userinfo["card_number"])) { $pp_cardtype = "Discover"; } if (cw_payment_cc_is_amex($userinfo["card_number"])) { $pp_cardtype = "Amex"; } if (empty($pp_cardtype)) { $top_message = array("content" => cw_get_langvar_by_name("txt_paypal_us_wrong_cc_type"), "type" => "E"); cw_header_location($current_location . "index.php?target=cart&mode=checkout"); } $payer = $userinfo; foreach ($userinfo as $k => $v) { if (is_array($v)) { continue; } $payer[$k] = htmlspecialchars($v); } $payer['main_address']['state'] = $payer['main_address']['country'] == 'US' || $payer['main_address']['country'] == 'CA' || $payer['main_address']['state'] != "" ? $payer['main_address']['state'] : 'Other'; $payer['current_address']['state'] = $payer['current_address']['country'] == 'US' || $payer['current_address']['country'] == 'CA' || $payer['current_address']['state'] != "" ? $payer['current_address']['state'] : 'Other'; $payer_ipaddress = cw_get_valid_ip($REMOTE_ADDR); $skey = cw_call('cw_payment_start'); $pp_exp_month = (int) substr($userinfo["card_expire"], 0, 2); $pp_exp_year = 2000 + substr($userinfo["card_expire"], 2, 2); $s_name = ""; if (!empty($payer['current_address']['firstname'])) { $s_name = $payer['current_address']['firstname']; } if (!empty($payer['current_address']['lastname'])) { $s_name .= (empty($s_name) ? "" : " ") . $payer['current_address']['lastname']; } if (!empty($s_name)) { $s_name = substr($s_name, 0, 32); } if (empty($payer['main_address']['firstname'])) { $payer['main_address']['firstname'] = "Unknown"; } if (empty($payer['main_address']['lastname'])) { $payer['main_address']['b_lastname'] = "Unknown"; } $oid = implode(',', $secure_oid); $request = <<<EOT <?xml version="1.0" encoding="{$pp_charset}"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Header> <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"> <Credentials xmlns="urn:ebay:apis:eBLBaseComponents"> <Username>{$pp_username}</Username> <ebl:Password xmlns:ebl="urn:ebay:apis:eBLBaseComponents">{$pp_password}</ebl:Password> {$pp_signature_txt} </Credentials> </RequesterCredentials> </soap:Header> <soap:Body> <DoDirectPaymentReq xmlns="urn:ebay:api:PayPalAPI"> <DoDirectPaymentRequest> <Version xmlns="urn:ebay:apis:eBLBaseComponents">1.00</Version> <DoDirectPaymentRequestDetails xmlns="urn:ebay:apis:eBLBaseComponents"> <PaymentAction>{$pp_final_action}</PaymentAction> <PaymentDetails> <OrderTotal currencyID="{$pp_currency}">{$pp_total}</OrderTotal> <ButtonSource>DP_US</ButtonSource> <NotifyURL>{$notify_url}</NotifyURL> <ShipToAddress> <Name>{$s_name}</Name> <Street1>{$payer['current_address']['adress']}</Street1> <Street2>{$payer['current_address']['address_2']}</Street2> <CityName>{$payer['current_address']['city']}</CityName> <StateOrProvince>{$payer['current_address']['state']}</StateOrProvince> <PostalCode>{$payer['current_address']['zipcode']}</PostalCode> <Country>{$payer['current_address']['country']}</Country> </ShipToAddress> <InvoiceID>{$skey}</InvoiceID> <Custom>{$oid}</Custom> </PaymentDetails> <CreditCard> <CreditCardType>{$pp_cardtype}</CreditCardType> <CreditCardNumber>{$payer['card_number']}</CreditCardNumber> <ExpMonth>{$pp_exp_month}</ExpMonth> <ExpYear>{$pp_exp_year}</ExpYear> <CardOwner> <PayerStatus>verified</PayerStatus> <Payer>{$payer['email']}</Payer> <PayerName> <FirstName>{$payer['main_address']['firstname']}</FirstName> <LastName>{$payer['main_address']['lastname']}</LastName> </PayerName> <PayerCountry>{$payer['main_address']['country']}</PayerCountry> <Address> <Street1>{$payer['main_address']['address']}</Street1> <Street2>{$payer['main_address']['address_2']}</Street2> <CityName>{$payer['main_address']['city']}</CityName> <StateOrProvince>{$payer['main_address']['state']}</StateOrProvince> <Country>{$payer['main_address']['country']}</Country> <PostalCode>{$payer['main_address']['zipcode']}</PostalCode> </Address> </CardOwner> <CVV2>{$payer['card_cvv2']}</CVV2> </CreditCard> <IPAddress>{$payer_ipaddress}</IPAddress> </DoDirectPaymentRequestDetails> </DoDirectPaymentRequest> </DoDirectPaymentReq> </soap:Body> </soap:Envelope> EOT; $result = cw_func_call('cw_paypal_express_request', array('request' => $request)); if ($result['success']) { $return['code'] = 1; $bill_message = 'Accepted'; } else { $bill_message = 'Declined'; $return['code'] = 2; } $additional_fields = array(); foreach (array('TransactionID') as $add_field) { if (isset($result[$add_field]) && strlen($result[$add_field]) > 0) { $additional_fields[] = ' ' . $add_field . ': ' . $result[$add_field]; } } if (!empty($additional_fields)) { $bill_message .= ' (' . implode(', ', $additional_fields) . ')'; } if (!empty($result['error'])) { $bill_message .= sprintf(" Error: %s (Code: %s, Severity: %s)", $result['error']['LongMessage'], $result['error']['ErrorCode'], $result['error']['Severity']); } $return["billmes"] = $bill_message; if (isset($result['AVSCode'])) { $return['avsmes'] = empty($avs_codes[$result['AVSCode']]) ? "Code: " . $result['AVSCode'] : $avs_codes[$result['AVSCode']]; } if (isset($result['CVV2Code'])) { $return['cvvmes'] = empty($cvv_codes[$result['CVV2Code']]) ? "Code: " . $result['CVV2Code'] : $cvv_codes[$result['CVV2Code']]; } if ($pp_final_action != 'Sale') { $return['is_preauth'] = true; } $return['extra_order_data'] = array("paypal_type" => "USDP", "paypal_txnid" => $result['TransactionID'], "capture_status" => $pp_final_action != 'Sale' ? 'A' : '', 'transaction_amount' => $pp_total); } return $return; }
function cw_payment_litleco_run_processor($params, $return) { global $config, $xcart_dir, $REMOTE_ADDR; if ($params['payment_data']['processor'] != litleco_addon_name) { return $return; } extract($params); $cardtype = ''; if (cw_payment_cc_is_visa($userinfo["card_number"])) { $cardtype = 'VI'; } elseif (cw_payment_cc_is_mc($userinfo["card_number"])) { $cardtype = 'MC'; } elseif (cw_payment_cc_is_dc($userinfo["card_number"])) { $cardtype = 'DC'; } elseif (cw_payment_cc_is_amex($userinfo["card_number"])) { $cardtype = 'AX'; } elseif (cw_payment_cc_is_diners($userinfo["card_number"])) { $cardtype = 'DI'; } $cart =& cw_session_register('cart'); $secure_oid =& cw_session_register('secure_oid'); $post = array('orderId' => $doc_ids[0], 'amount' => 100 * $cart['info']['total'], 'id' => $config[litleco_addon_name]['litleco_id'], 'orderSource' => 'ecommerce', 'billToAddress' => array('name' => $userinfo['main_address']['firstname'] . " " . $userinfo['main_address']['lastname'], 'addressLine1' => $userinfo['main_address']['address'], 'addressLine2' => $userinfo['main_address']['address_2'], 'city' => $userinfo['main_address']['city'], 'state' => $userinfo['main_address']['state'], 'zip' => $userinfo['main_address']['zipcode'], 'country' => $userinfo['main_address']['country'], 'email' => $userinfo['email'], 'phone' => $userinfo['main_address']['phone']), 'shipToAddress' => array('name' => $userinfo['current_address']['firstname'] . " " . $userinfo['current_address']['lastname'], 'addressLine1' => $userinfo['current_address']['address'], 'addressLine2' => $userinfo['current_address']['address_2'], 'city' => $userinfo['current_address']['city'], 'state' => $userinfo['current_address']['state'], 'zip' => $userinfo['current_address']['zipcode'], 'country' => $userinfo['current_address']['country']), 'card' => array('number' => $userinfo["card_number"], 'expDate' => $userinfo['card_expire'], 'cardValidationNum' => $userinfo['card_cvv2'], 'type' => $cardtype), 'user' => $config[litleco_addon_name]['litleco_user'], 'password' => $config[litleco_addon_name]['ptleco_assword'], 'merchantId' => $config[litleco_addon_name]['litleco_mid'], 'url' => $config[litleco_addon_name]['litleco_test'] ? 'https://www.testlitle.com/sandbox/communicator/online' : 'https://payments.litle.com/vap/communicator/online', 'tcp_ssl' => 1); //cw_log_add('payment_litleco_test', array('post'=>$post, 'doc_ids'=>$doc_ids, 'cart'=>$cart)); if (!function_exists('__autoload')) { function __autoload($class) { $class = '/' . strtr($class, array('\\' => '/')); require_once realpath(dirname(__FILE__)) . $class . '.php'; } } $initilaize = new litle\sdk\LitleOnlineRequest(); $dom = $initilaize->saleRequest($post); # saleRequest/authorizationRequest # debug # print "<pre>"; # print_r($post); # print $dom->saveXML(); /* OK: <litleOnlineResponse xmlns="http://www.litle.com/schema" version="9.00" response="0" message="Valid Format"> <authorizationResponse id="456" reportGroup="Default Report Group" customerId=""> <litleTxnId>210204889228876000</litleTxnId> <orderId>296</orderId> <response>000</response> <responseTime>2014-12-16T18:21:52</responseTime> <message>Approved</message> <authCode>41044</authCode> </authorizationResponse> </litleOnlineResponse> NOK: <litleOnlineResponse xmlns="http://www.litle.com/schema" version="9.00" response="0" message="Valid Format"> <authorizationResponse id="456" reportGroup="Default Report Group" customerId=""> <litleTxnId>421271745975805101</litleTxnId> <orderId>296</orderId> <response>101</response> <responseTime>2014-12-16T18:23:36</responseTime> <message>Issuer Unavailable</message> </authorizationResponse> </litleOnlineResponse> */ $res = array(); foreach (array('litleTxnId', 'response', 'message', 'authCode') as $k) { $res[$k] = litle\sdk\XmlParser::getNode($dom, $k); } if (!$res["litleTxnId"]) { # ERR return array('code' => 2, 'billmes' => 'Reason: Unknown error'); } if ($res["response"] == "000") { # OK return array('code' => 1, 'billmes' => $res['message'] . " (TxnId: " . $res["litleTxnId"] . "; AuthCode: " . $res["authCode"] . ")"); } # NOK return array('code' => 2, 'billmes' => "Reason: " . $res['message'] . " (TxnId: " . $res["litleTxnId"] . ")", 'hide_mess' => $res["response"]); }