我需要为我的magento网站集成Authorize.net(Echeck.net)付款方式。我用google搜索但我没有发现请建议是否有付款方式的任何扩展,否则我们可以通过编码实现这一点。我使用的是magento 1.7.0.2。
提前致谢!
答案 0 :(得分:1)
authorize.net的官方测试版可在Magento市场(Magento Connect)上获得。此模块仅在沙箱中进行测试,目前处于Beta状态,可能与1.4和1.6兼容。尚未尝试1.7。如果有效,你可以试试。请在以下链接中找到该模块
http://www.magentocommerce.com/magento-connect/echeck-payment-method-authorize-net.html
如果您需要自定义延伸,请随时联系contact@sgssandhu.com或http://oxosolutions.com/ 感谢
答案 1 :(得分:0)
嗨,这里是通过卷曲请求&的ECHECK的工作示例使用分隔符解析Response:
public function curlProcessECHECK(){
$query = "";
// Login Information
$query .= "x_login=" . urlencode($this->credentials->username) . "&";
$query .= "x_tran_key=" . urlencode($this->credentials->password) . "&";
$query .= "x_version=" . "3.1" . "&";
$query .= "x_delim_data=" . "TRUE" . "&";
$query .= "x_delim_char=" . "|" . "&";
$query .= "x_relay_response=" . "FALSE" . "&";
$query .= "x_amount=" . urlencode(number_format($data['orderTotalAmt'], 2, ".", "")) . "&";
// ECHECk payments..... code to check ECHECK request
switch ($data['bank_acct_type'])
{
case 'checking':
$echecktype = 'PPD';
break;
case 'businessChecking':
$echecktype = 'CCD';
break;
case 'savings':
$echecktype = 'PPD';
break;
default:
$echecktype = 'PPD';
break;
}
$query .= "x_method=ECHECK&";
$query .= "x_bank_name=" . urlencode($data['bank_name']) . "&";
$query .= "x_echeck_type=" . urlencode($echecktype) . "&"; //CCD, PPD, TEL ---[ARC, BOC]- bank_check_number ll be required, [WEB] recurring_billing ll be required.
$query .= "x_bank_acct_type=" . urlencode($data['bank_acct_type']) . "&";
$query .= "x_bank_acct_num=" . urlencode($data['bank_acct_num']) . "&";
$query .= "x_bank_aba_code=" . urlencode($data['bank_aba_code']) . "&"; // aba code should be valid get from google US based banks
$query .= "x_bank_acct_name=" . urlencode($data['bank_acct_name']) . "&";
$query .= "x_description=" . (isset($data['orderDescription']) ? urlencode($data['orderDescription']) : "") . "&";
$query .= "x_first_name=" . (isset($data['billingFirstName']) ? urlencode($data['billingFirstName']) : $data['firstName']) . "&";
$query .= "x_last_name=" . (isset($data['billingLastName']) ? urlencode($data['billingLastName']) : $data['lastName']) . "&";
$query .= "x_address=" . (isset($data['billingAddress1']) ? urlencode($data['billingAddress1']) : "") . "&";
$query .= "x_state=" . (isset($data['billingState']) ? urlencode($data['billingState']) : "") . "&";
$query .= "x_zip=" . (isset($data['billingZip']) ? urlencode($data['billingZip']) : "") . "&";
if($this->env == 1) {
$query .= "x_test_request=TRUE&";
}
$query .= "x_type=AUTH_CAPTURE";
$output = array();
$url = 'https://test.authorize.net/gateway/transact.dll';// TestMode
$ch_response = null;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
$ch_response = curl_exec($ch);
// Check that a connection was made
if (curl_error($ch)) {
// If it wasn't...
$output['status'] = "Failure";
$output['response']['code'] = '-1';
$output['data'] = null;
$output['response']['responseMsg'] = curl_error($ch);
$output['response']['gateway_response_code'] ='000';
$output['response']['responsetext']= " No response from gateway";
$output['response']['transactionid'] = '';
$output['response']['init'] ="no";
$output['response']['response_code']='000';
} else {
$output['status'] = 'Success';
$output['data'] = $ch_response;
$output = $this->processResponse($output);
}
echo '<pre>';print_r($output);die;
}
现在解析结果
public function processResponse($output){
$response_array=$output;
if ($response_array) {
// Split Array
$encap_char = "|";
$response_array = explode($encap_char, $response_array['data']);
//echo"<pre>";print_r($response_array);die;
/**
* If AuthorizeNet doesn't return a delimited response.
*/
if (count($response_array) < 10) {
$approved = false;
$error = true;
$error_message = "Unrecognized response from AuthorizeNet: ";
return;
}
// Set all fields
$response_code = $response_array[0];
$response_subcode = $response_array[1];
$response_reason_code = $response_array[2];
$response_reason_text = $response_array[3];
$authorization_code = $response_array[4];
$avs_response = $response_array[5];
$transaction_id = $response_array[6];
$invoice_number = $response_array[7];
$description = $response_array[8];
$amount = $response_array[9];
$method = $response_array[10];
$transaction_type = $response_array[11];
$customer_id = $response_array[12];
$first_name = $response_array[13];
$last_name = $response_array[14];
$company = $response_array[15];
$address = $response_array[16];
$city = $response_array[17];
$state = $response_array[18];
$zip_code = $response_array[19];
$country = $response_array[20];
$phone = $response_array[21];
$fax = $response_array[22];
$email_address = $response_array[23];
$ship_to_first_name = $response_array[24];
$ship_to_last_name = $response_array[25];
$ship_to_company = $response_array[26];
$ship_to_address = $response_array[27];
$ship_to_city = $response_array[28];
$ship_to_state = $response_array[29];
$ship_to_zip_code = $response_array[30];
$ship_to_country = $response_array[31];
$tax = $response_array[32];
$duty = $response_array[33];
$freight = $response_array[34];
$tax_exempt = $response_array[35];
$purchase_order_number = $response_array[36];
$md5_hash = $response_array[37];
$card_code_response = $response_array[38];
$cavv_response = $response_array[39];
$account_number = $response_array[50];
$card_type = $response_array[51];
$split_tender_id = $response_array[52];
$requested_amount = $response_array[53];
$balance_on_card = $response_array[54];
// $approved = ($response_code == self::APPROVED);
// $declined = ($response_code == self::DECLINED);
// $error = ($response_code == self::ERROR);
// $held = ($response_code == self::HELD);
$approved = "";
$declined = "";
$error = "";
$held = "";
if ($response_code == 1) {
$result['response']['response_code'] = 100;
$result['response']['gateway_response_code'] = 100;
$result['response']['responsetext'] = "Success";
$result['status'] = 'success';
} elseif ($response_code == 2) {
$result['response']['response_code'] = 800;
$result['response']['gateway_response_code'] = 800;
$result['response']['responsetext'] = "Declined";
$result['status'] = $response_reason_text;
} else {
$result['response']['response_code'] = $response_code;
$result['response']['gateway_response_code'] = $response_code;
$result['response']['responsetext'] = $response_reason_text;
$result['status'] = $response_reason_text;
}
$result['method'] = $method;
$result['md5_hash'] = $md5_hash;
$result['card_type'] = $card_type;
$result['account_number'] = $account_number;
$result['response']['transactionid'] = $transaction_id;
$result['response']['processor_id'] = "";
$result['response']['cvvresponse'] = $cavv_response;
$result['response']['avsresponse'] = $avs_response;
$result['response']['authcode'] = $authorization_code;
$result['response']['type'] = "Sale";
$result['response']['init'] = "no";
return $result;
}
}