Authorize.net返回多个分隔符

时间:2014-01-10 16:21:02

标签: drupal-6 authorize.net

我使用Drupal moneyscripts模块进行定期付款,一切正常,当我使用我的Authorize.net沙盒帐户时,但是当我输入我的实时API密钥登录时 模块失败了。意味着用户不是在Drupal中创建的,并且未分配角色。但问题是交易确实通过了authorize.net并获得了批准。 只有Drupal端失败(应该创建用户并分配角色),这使用authorize.net沙箱帐户100%工作,我唯一改变的是从沙箱切换到实时。

编辑:看来问题是authorize.net正在返回多个分隔符,支持似乎完全没用来修复它,它似乎绝对是从他们的结束。

我已经包含了来自两者的授权响应消息以及模块中的错误行。首先是当Drupal失败时我从真实账户获得的响应第二个是沙盒在一切正常工作时的响应。

Authorize.Net AIM: Payment for Order 66 failed.
<pre>Authnet Object ( [login:Authnet:private] => [transkey:Authnet:private] => [params:Authnet:private] => Array ( [x_delim_data] => TRUE [x_delim_char] => | [x_relay_response] => FALSE [x_url] => FALSE [x_version] => 3.1 [x_method] => CC [x_type] => AUTH_CAPTURE [x_login] => 724Vs5JQht [x_tran_key] => xxxxxxvg5dX [x_card_num] => xxxxxx46 [x_exp_date] => 07/2014 [x_amount] => 0.01 [x_po_num] => [x_tax] => [x_card_code] => 484 [x_invoice_num] => [x_description] => The Calorie Myth - Monthly Membership - $0.01 every Month [x_first_name] => Davide [x_last_name] => ededd [x_address] => teststreet [x_city] => New York [x_zip] => 10538 [x_country] => US [x_email] => test@gmail.com [x_cust_id] => 0 [x_customer_ip] => 37.55.241.139 [x_email_customer] => FALSE [x_duplicate_window] => 0 ) [results:Authnet:private] => Array ( [0] => [1] => 1 [2] => [3] => [4] => 1 [5] => [6] => [7] => 1 [8] => [9] => [10] => This transaction has been approved. [11] => [12] => [13] => 228479 [14] => [15] => [16] => Z [17] => [18] => [19] => 5841731972 [20] => [21] => [22] => [23] => [24] => [25] => The Calorie Myth - Monthly Membership - $0.01 every Month [26] => [27] => [28] => 0.01 [29] => [30] => [31] => CC [32] => [33] => [34] => auth_capture [35] => [36] => [37] => 0 [38] => [39] => [40] => Davide [41] => [42] => [43] => ededd [44] => [45] => [46] => [47] => [48] => [49] => teststreet [50] => [51] => [52] => New York [53] => [54] => [55] => [56] => [57] => [58] => 10538 [59] => [60] => [61] => US [62] => [63] => [64] => [65] => [66] => [67] => [68] => [69] => [70] => test@gmail.com [71] => [72] => [73] => [74] => [75] => [76] => [77] => [78] => [79] => [80] => [81] => [82] => [83] => [84] => [85] => [86] => [87] => [88] => [89] => [90] => [91] => [92] => [93] => [94] => [95] => [96] => [97] => [98] => [99] => [100] => [101] => [102] => [103] => [104] => [105] => [106] => [107] => [108] => [109] => [110] => [111] => [112] => EA83CEE11EEFD957C634417DE9EEA716 [113] => [114] => [115] => M [116] => [117] => [118] => [119] => [120] => [121] => [122] => [123] => [124] => [125] => [126] => [127] => [128] => [129] => [130] => [131] => [132] => [133] => [134] => [135] => [136] => [137] => [138] => [139] => [140] => [141] => [142] => [143] => [144] => [145] => [146] => [147] => [148] => [149] => [150] => [151] => XXXX6646 [152] => [153] => [154] => MasterCard [155] => [156] => [157] => [158] => [159] => [160] => [161] => [162] => [163] => [164] => [165] => [166] => [167] => [168] => [169] => [170] => [171] => [172] => [173] => [174] => [175] => [176] => [177] => [178] => [179] => [180] => [181] => [182] => [183] => [184] => [185] => [186] => [187] => [188] => [189] => [190] => [191] => [192] => [193] => [194] => [195] => [196] => [197] => [198] => [199] => [200] => [201] => [202] => [203] => [204] => [205] => FALSE [206] => ) [approved:Authnet:private] => [declined:Authnet:private] => [error:Authnet:private] => 1 [test:Authnet:private] => [fields:Authnet:private] => x_delim_data=TRUE&x_delim_char=%7C&x_relay_response=FALSE&x_url=FALSE&x_version=3.1&x_method=CC&x_type=AUTH_CAPTURE&x_login=REMOVEDt&x_tran_key=REMOVEDX&x_card_num=REMOVED&x_exp_date=07%2F2014&x_amount=0.01&x_po_num=&x_tax=&x_card_code=484&x_invoice_num=&x_description=The+Calorie+Myth+-+Monthly+Membership+-+%240.01+every+Month&x_first_name=Davide&x_last_name=ededd&x_address=teststreet&x_city=New+York&x_zip=10538&x_country=US&x_email=test%40gmail.com&x_cust_id=0&x_customer_ip=37.55.241.139&x_email_customer=FALSE&x_duplicate_window=0& [response:Authnet:private] => |1|||1|||1|||This transaction has been approved.|||228479|||Z|||5841731972||||||The Calorie Myth - Monthly Membership - $0.01 every Month|||0.01|||CC|||auth_capture|||0|||Davide|||ededd||||||teststreet|||New York||||||10538|||US|||||||||test@gmail.com||||||||||||||||||||||||||||||||||||||||||EA83CEE11EEFD957C634417DE9EEA716|||M||||||||||||||||||||||||||||||||||||XXXX6646|||MasterCard|||||||||||||||||||||||||||||||||||||||||||||||||||FALSE| [url] => https://secure.authorize.net/gateway/transact.dll ) </pre>
Logged at /srv/bindings/1ea944aacfa249279fb86d3581f0d3b7/code/sites/all/modules/ms_core/gateways/ms_authorizenet/ms_authorizenet.module line 2098

这是我在2098行输入的调试消息中的数组,问题似乎在ms_authorizenet_charge()函数内部。在$ aim-&gt; proccess。

之后
<pre>|1|||1|||1|||This transaction has been approved.|||00000|||Z|||00000||||||The Calorie Myth - Monthly Membership - $0.01 every Month|||0.01|||CC|||auth_capture|||0|||Davidee|||Dadadaee||||||teststreet|||New York||||||10538|||US|||||||||test@gmail.com||||||||||||||||||||||||||||||||||||||||||Eremoved0E2BA239F|||M||||||||||||||||||||||||||||||||||||XXXX6646|||MasterCard|||||||||||||||||||||||||||||||||||||||||||||||||||FALSE|</pre><pre>|1|||1|||1|||This transaction has been approved.|||095650|||Z|||5841959304||||||The Calorie Myth - Monthly Membership - $0.01 every Month|||0.01|||CC|||auth_capture|||0|||Davidee|||Dadadaee||||||teststreet|||New York||||||10538|||US|||||||||test@gmail.com||||||||||||||||||||||||||||||||||||||||||DD3B1A2B05FD7441BC3E972A0DC966ED|||M||||||||||||||||||||||||||||||||||||XXXX6646|||MasterCard|||||||||||||||||||||||||||||||||||||||||||||||||||FALSE|</pre><pre>|1|||1|||1|||This transaction has been approved.|||102322|||Z|||removed||||||The Calorie Myth - Monthly Membership - $0.01 every Month|||0.01|||CC|||auth_capture|||0|||Davidee|||Dadadaee||||||teststreet|||New York||||||10538|||US|||||||||test@gmail.com||||||||||||||||||||||||||||||||||||||||||removed|||M||||||||||||||||||||||||||||||||||||XXXX6646|||MasterCard|||||||||||||||||||||||||||||||||||||||||||||||||||FALSE|</pre>

当一切正常100%

时,这是沙箱的响应
Authnet Object
(
    [login:Authnet:private] => 
    [transkey:Authnet:private] => 
    [params:Authnet:private] => Array
        (
            [x_delim_data] => TRUE
            [x_delim_char] => |
            [x_relay_response] => FALSE
            [x_url] => FALSE
            [x_version] => 3.1
            [x_method] => CC
            [x_type] => AUTH_CAPTURE
            [x_login] => 8xxxxxx8
            [x_tran_key] => 4xxxxxxx
            [x_card_num] => 4111111111111111
            [x_exp_date] => 10/2014
            [x_amount] => 0.01
            [x_po_num] => 
            [x_tax] => 
            [x_card_code] => 111
            [x_invoice_num] => 
            [x_description] => The Calorie Myth - Monthly Membership - $0.01 every Month
            [x_first_name] => David
            [x_last_name] => Bacham
            [x_address] => sadds
            [x_city] => chicago
            [x_zip] => 15151
            [x_country] => US
            [x_email] => test@gmail.com
            [x_cust_id] => 0
            [x_customer_ip] => 37.55.241.139
            [x_email_customer] => FALSE
        )

    [results:Authnet:private] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 1
            [3] => This transaction has been approved.
            [4] => SRFO9I
            [5] => Y
            [6] => 2204549942
            [7] => 
            [8] => The Calorie Myth - Monthly Membership - $0.01 every Month
            [9] => 0.01
            [10] => CC
            [11] => auth_capture
            [12] => 0
            [13] => David
            [14] => Bacham
            [15] => 
            [16] => sadds
            [17] => chicago
            [18] => 
            [19] => 15151
            [20] => US
            [21] => 
            [22] => 
            [23] => test@gmail.com
            [24] => 
            [25] => 
            [26] => 
            [27] => 
            [28] => 
            [29] => 
            [30] => 
            [31] => 
            [32] => 
            [33] => 
            [34] => 
            [35] => 
            [36] => 
            [37] => C58xxxxxxxx546B37A
            [38] => P
            [39] => 2
            [40] => 
            [41] => 
            [42] => 
            [43] => 
            [44] => 
            [45] => 
            [46] => 
            [47] => 
            [48] => 
            [49] => 
            [50] => XXXX1111
            [51] => Visa
            [52] => 
            [53] => 
            [54] => 
            [55] => 
            [56] => 
            [57] => 
            [58] => 
            [59] => 
            [60] => 
            [61] => 
            [62] => 
            [63] => 
            [64] => 
            [65] => 
            [66] => 
            [67] => 
            [68] => FALSE
        )

    [approved:Authnet:private] => 1
    [declined:Authnet:private] => 
    [error:Authnet:private] => 
    [test:Authnet:private] => 1
    [fields:Authnet:private] => x_delim_data=TRUE&x_delim_char=%7C&x_relay_response=FALSE&x_url=FALSE&x_version=3.1&x_method=CC&x_type=AUTH_CAPTURE&x_login=8Cxxxx&x_tran_key=xxxxx49vP&x_card_num=4111111111111111&x_exp_date=10%2F2014&x_amount=0.01&x_po_num=&x_tax=&x_card_code=111&x_invoice_num=&x_description=The+Calorie+Myth+-+Monthly+Membership+-+%240.01+every+Month&x_first_name=David&x_last_name=Bacham&x_address=sadds&x_city=chicago&x_zip=15151&x_country=US&x_email=test%40gmail.com&x_cust_id=0&x_customer_ip=37.55.241.139&x_email_customer=FALSE&
    [response:Authnet:private] => 1|1|1|This transaction has been approved.|SRFO9I|Y|2204549942||The Calorie Myth - Monthly Membership - $0.01 every Month|0.01|CC|auth_capture|0|David|Bacham||sadds|chicago||15151|US|||test@gmail.com||||||||||||||C58104D65E4F190912F1D9CCD546B37A|P|2|||||||||||XXXX1111|Visa|||||||||||||||||FALSE
    [url] => https://test.authorize.net/gateway/transact.dll
)

以下是抛出错误的模块中的代码,我留在看门狗调试语句中,这样你就可以看到2098行了。

  if ($response['approved'] == TRUE) {
    // Insert the Payment to the database for the Free Trial
    $payment = ms_core_new_payment($order->oid, 'ms_authorizenet_cim', 'rec_signup');
    $payment->transaction = $response['data']['txn_id'];
    $payment->currency = 'USD';
    $payment->data = $payment_profile;
    $payment->recurring_schedule = $order->recurring_schedule;

    // Update the address
    $payment->billing_address = array(
      'street' => trim($v['billing_address1']) .'\n'. trim($v['billing_address2']),
      'city' => trim($v['billing_city']),
      'state' => trim($v['billing_state']),
      'zip' => trim($v['billing_zip']),
      'country' => trim($v['billing_country']),
      'phone' => trim($v['billing_phone']),
      );
    $payment->shipping_address = $payment->billing_address;

    // Update the contact details
    $payment->first_name = trim($v['cc_first_name']);
    $payment->last_name = trim($v['cc_last_name']);
    $payment->recurring_id = $order->oid;

    // Add the Payment to the Order
    ms_core_enter_payment($payment, FALSE);

    // Save the CIM profiles
    if (variable_get('ms_authorizenet_cim_profile', FALSE)) {
      $order = ms_core_order_load($order->oid);
      // Create the profile without validating since the AIM is valid
      $cim_result = ms_authorizenet_create_cim_profiles_from_order($order, $v, FALSE);
      if ($cim_result['success']) {
        // Add the payment to the order
        $form_state['values']['ms_oid'] = $order->oid;
        $form_state['values']['ms_order_charged'] = TRUE;
      }
      else {
        form_set_error('ccnumber', t('Error') . ': ' . $cim_result['error']);
      }
    }
    else {
      form_set_error('ccnumber', t('Error: There was a configuration error in the settings.'));
    }
  }
  else { // The Credit Card was not approved, set an error on the form
    form_set_error('ccnumber', t('Error') .': '. $response['message']);
  }
}
else {
  // Check if there is a trial
  $amount = ($order->recurring_schedule['trial_length']) ? $order->recurring_schedule['trial_amount'] : $order->recurring_schedule['main_amount'];

  //my debug message line 2098
    watchdog('ms', '2-V<pre>' . print_r($v , 1) . '</pre>', array(), WATCHDOG_WARNING);
    $response = ms_authorizenet_charge($order, $amount, $v);
     watchdog('ms', '2-ORDER<pre>' . print_r($response , 1) . '</pre>', array(), WATCHDOG_WARNING);



  // Use AIM for the first charge

  if ($response['approved'] == TRUE) {
    // Insert the Payment to the database for the Free Trial
    $payment = ms_core_new_payment($order->oid, 'ms_authorizenet_cim', 'rec_signup');
    $payment->transaction = $response['data']['txn_id'];
    $payment->currency = 'USD';
    $payment->data = $payment_profile;
    $payment->recurring_schedule = $order->recurring_schedule;

    // Update the address
    $payment->billing_address = array(
      'street' => trim($v['billing_address1']) .'\n'. trim($v['billing_address2']),
      'city' => trim($v['billing_city']),
      'state' => trim($v['billing_state']),
      'zip' => trim($v['billing_zip']),
      'country' => trim($v['billing_country']),
      'phone' => trim($v['billing_phone']),
      );
    $payment->shipping_address = $payment->billing_address;
    $payment->recurring_id = $order->oid;

    // Update the contact details
    $payment->first_name = trim($v['cc_first_name']);
    $payment->last_name = trim($v['cc_last_name']);

    // Add the Payment to the Order
    ms_core_enter_payment($payment, FALSE);

    // Save the CIM profiles
    if (variable_get('ms_authorizenet_cim_profile', FALSE)) {
      $order = ms_core_order_load($order->oid);
      // Create the profile without validating since the AIM is valid
      $cim_result = ms_authorizenet_create_cim_profiles_from_order($order, $v, FALSE);
      if ($cim_result['success']) {
        // Add the rec_payment payment to the order
        $payment->type = 'rec_payment';
        $payment->amount = $amount;
        ms_core_enter_payment($payment, FALSE);

        // Add the payment to the order
        $form_state['values']['ms_oid'] = $order->oid;
        $form_state['values']['ms_order_charged'] = TRUE;
      }
      else {
        form_set_error('ccnumber', t('Error') . ': ' . $cim_result['error']);
      }
    }
    else {
      form_set_error('ccnumber', t('Error: There was a configuration error in the settings.'));
    }
  }
  else { // The Credit Card was not approved, set an error on the form


      form_set_error('ccnumber', t('Error') .': '. $response['message']);
      }


}

1 个答案:

答案 0 :(得分:1)

来自Live和Sandbox请求的结果数组的格式不同。

批准应该是结果[0],如果批准则应该等于'1'。这就是Sandbox中的一个,但Live one的结果为空值[0]。此外,在Sandbox one中,文本“此交易已被批准”在结果[3]中,但实际的文本在结果[10]中有。

对于Sandbox和Live发送的内容,似乎存在某种API版本不匹配。

编辑:此外,看起来可能应该责备delim字符。它被设置为|但你得到的结果有多个|值之间的字符。这可能是导致结果在数组中错误位置的问题。

EDIT2:看起来个别数据项被包含在|中然后由|分隔。那么应该将data1 | data2 | data3作为| data1 |返回| | DATA2 | | | DATA3 | (添加空格以显示封闭和分隔|'s)