$config['payment']['secpay']['title'] ? $config['payment']['secpay']['title'] : _PLUG_PAY_SECPAY_TITLE, 'description' => $config['payment']['secpay']['description'] ? $config['payment']['secpay']['description'] : _PLUG_PAY_SECPAY_DESC, 'code' => 2, 'name_f' => 2, 'currency' => array('USD' => 'USD', 'EUR' => 'EUR', 'GBP' =>'GBP'), 'start_date' => 2, 'issue_number' => 2, 'type_options' => array('Visa' => 'Visa', 'Master Card' => 'Master Card', 'Switch / UK Maestro'=>'Switch / UK Maestro', 'Maestro'=>'Maestro', 'Solo'=>'Solo', 'Delta'=>'Delta', 'JCB'=>'JCB') ); } function run_transaction($vars, $method='validateCardFull'){ $client = new soapclient($u = 'https://www.secpay.com/java-bin/services/SECCardService?wsdl', true); // print $u; $err = $client->getError(); if ($err) { return array('message' => sprintf(_PLUG_PAY_SECPAY_ERROR, $err)); } $result = $client->call($method, $vars, "http://www.secpay.com"); // print $client->debug_str; // print "method = $method vars = ".var_dump($vars); // Check for a fault if ($client->fault) { if ($err) { return array('message' => _PLUG_PAY_SECPAY_ERROR2 . join(' - ', array_values($result)) ); } } else { // Check for errors $err = $client->getError(); if ($err) { return array('message' => sprintf(_PLUG_PAY_SECPAY_ERROR3, $err) ); } else { if ($result[0] == '?') $result = substr($result, 1); parse_str($result, $ret); return $ret; } } } function void_transaction($trans_id, $amount, &$log){ $vars = array( 'mid' => $this->config['id'], // Test MerchantId 'vpn_pass' => $this->config['pass'], // VPN password 'remote_pswd' => $this->config['remote_pass'], 'trans_id' => $trans_id, // merchants transaction id 'new_trans_id' => "{$trans_id}_RFND", 'amount' => $amount, // Amount ); $vars_l = $vars; $log[] = $vars_l; $res = $this->run_transaction($vars, 'refundCardFull'); $log[] = $res; return $res; } /************************************************************* cc_bill - do real cc bill ***************************************************************/ function cc_bill($cc_info, $member, $amount, $currency, $product_description, $charge_type, $invoice, $payment){ global $config; $log = array(); //////////////////////// cc_bill ///////////////////////// require_once($config['root_dir']."/plugins/payment/secpay/lib/nusoap.php"); srand(time()); if ($charge_type == CC_CHARGE_TYPE_TEST) $amount = "1.00"; if ($cc_info['cc_name_f'] == ''){ $cc_info['cc_name_f'] = $member['name_f']; $cc_info['cc_name_l'] = $member['name_l']; } $vars = array( 'mid' => $this->config['id'], // Test MerchantId 'vpn_pswd' => $this->config['pass'], // VPN password 'trans_id' => "AMEMBER$invoice", // merchants transaction id 'ip' => $member['remote_addr'] ? $member['remote_addr'] : $_SERVER['REMOTE_ADDR'], // The ip of the original caller 'name' => $cc_info['cc_name_f'] . ' ' . $cc_info['cc_name_l'], // Card Holders Name 'card_number' => $cc_info['cc_number'], // Card number 'amount' => $amount, // Amount 'expiry_date' => $cc_info['cc-expire'], // Expiry Date 'issue_number' => $cc_info['issue_number'], // Issue (Switch/Solo only) 'start_date' => $cc_info['cc-start_date'], // Start Date 'order' => $product_description, // Order Item String 'shipping' => "", // Shipping Address // 'billing' => $cc_info['cc_street'], 'billing' => "name=".$cc_info['cc_name_f']."+".$cc_info['cc_name_l'].",addr_1=".urlencode($cc_info['cc_street']).",city=".urlencode($cc_info['cc_city']).",state=".urlencode($cc_info['cc_state']).",post_code=".urlencode($cc_info['cc_zip']).",email=".$member['email']."", 'options' => "dups=false", // Options String ); // print_r($vars); $vars[options] .= ",currency=".($currency ? $currency : 'USD'); switch ($this->config['testing']){ case 1: $vars['options'] .= ",test_status=true"; break; case 2: $vars['options'] .= ",test_status=false"; break; } if ($cc_info['cc_code']) $vars['options'] .= ",card_cv2=$cc_info[cc_code],req_cv2=true"; if ($cc_info['cc_type']){ $vars['options'] .= ",card_type=$cc_info[cc_type]"; } if($cc_info['cc_start_date']){ $vars[start_date] = $cc_info['cc-start-date']; } // prepare log record $vars_l = $vars; $vars_l['card_number'] = $cc_info['cc']; $log[] = $vars_l; ///// $res = $this->run_transaction($vars); $log[] = $res; if ($res['valid'] == 'true' ){ if ($charge_type == CC_CHARGE_TYPE_TEST) $this->void_transaction($res['trans_id'], $res['amount'], $log); return array(CC_RESULT_SUCCESS, "", $res['auth_code'], $log); } elseif ($res['valid'] == 'false') { return array(CC_RESULT_DECLINE_PERM, $res['message'], "", $log); } else { return array(CC_RESULT_INTERNAL_ERROR, $res['message'], "", $log); } } } function secpay_get_member_links($user){ return cc_core_get_member_links('secpay', $user); } function secpay_rebill(){ return cc_core_rebill('secpay'); } cc_core_init('secpay'); ?>