2012-06-29 19 views
1

我已經註冊了Authorize.net和成功:Authorize.net SIM卡接收數據,並更新數據庫

  1. 將我的購物車成發送到Authorize.net和處理它的數據。
  2. 使用中繼響應,發送用戶到我的感謝頁面。

我不能讓我的腦袋纏住一旦交易完成後如何實際更新我的數據庫。我要搜索什麼條款來解決這個問題?幾乎所有的文檔都顯示瞭解決方案的一部分,但實際上並沒有指示放在哪裏以及如何接收它。

在我的購物車頁面上,我有一個由Authorize.net提供的隱藏輸入字段列表。我插入了我的美元數量,描述等。我假設我把另一個隱藏的字段叫做「x_po_num」,並且在數據庫中的值是我的動態PO#。

是不是有辦法在Thank You頁面上實際檢索它,所以我交叉引用數據庫並簡單地添加「確認」或其他值?

如何檢索發送到Authorize.net的值?

回答

2

您得到的數據只是在$_POST數組中,您可以使用var_dump()來查看它包含的值。

下面是一個示例響應接力腳本PHP:

<?php 

// Retrieving and defining Form Data from Post command body from Authorize.Net 
$ResponseCode  = trim($_POST["x_response_code"]); 
$ResponseReasonText = trim($_POST["x_response_reason_text"]); 
$ResponseReasonCode = trim($_POST["x_response_reason_code"]); 
$AVS    = trim($_POST["x_avs_code"]); 
$TransID   = trim($_POST["x_trans_id"]); 
$AuthCode   = trim($_POST["x_auth_code"]); 
$Amount    = trim($_POST["x_amount"]); 

?> 

    <html> 
    <head> 
    <title>Transaction Receipt Page</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> 
    <body bgcolor="#FFFFFF"> 

<?php 
    // Test to see if this is a test transaction. 
    if ($TransID === 0 && $ResponseCode === 1) 
    { 
     // If so, print it to the screen, so we know that the transaction will not be processed. 
?> 

    <table align="center"> 
     <tr> 
      <th><font size="5" color="red" face="arial">TEST MODE</font></th> 
     <tr> 
      <th valign="top"><font size="1" color="black" face="arial">This transaction will <u>NOT</u> be processed because your account is in Test Mode.</font></th> 
     </tr> 
    </table> 

<?php 
    } 
?> 

    <br> 
    <br> 

<?php 
    // Test to see if the transaction resulted in Approvavl, Decline or Error 
    if ($ResponseCode === 1) 
    { 
?> 

    <table align="center"> 
     <tr> 
      <th><font size="3" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">This transaction has been approved.</font></th> 
     </tr> 
    </table> 

<?php 
    } 
    else if ($ResponseCode === 2) 
    { 
?> 

    <table align="center"> 
    <tr> 
     <th width="312"><font size="3" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">This transaction has been declined.</font></th> 
    </tr> 
    </table> 

<?php 
    } 
    else if ($ResponseCode === 3) 
    { 
?> 

    <table align="center"> 
    <tr> 
     <th colspan="2"><font size="3" color="Red" face="Verdana, Arial, Helvetica, sans-serif">There was an error processing this transaction.</font></th> 
    </tr> 
    </table> 

<?php 
    } 
?> 

    <br> 
    <br> 
    <table align="center" width="60%"> 
    <tr> 
     <td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Amount:</b></font></td> 
     <td align="left"><font size="2" color="black" face="arial">$<?php echo $Amount; ?></td> 
    </tr> 

    <tr> 
     <td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Transaction ID:</b></font></td><td align="left"><font size="2" color="black" face="arial"> 

<?php 
    if ($TransID === 0) 
    { 
     echo 'Not Applicable.'; 
    } 
    else 
    { 
     echo $TransID; 
    } 
?> 

    </td></tr> 

    <tr> 
     <td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Authorization Code:</b></font></td><td align="left"><font size="2" color="black" face="arial"> 

<?php 
    if ($AuthCode === "000000") 
    { 
     echo 'Not Applicable.'; 
    } 
    else 
    { 
     echo $AuthCode; 
    } 
?> 

     </td></tr> 
    <tr> 
     <td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Response Reason:</b></font></td><td align="left"><font size="2" color="black" face="arial">(<?php echo $ResponseReasonCode; ?>)&nbsp;<?php echo $ResponseReasonText; ?></font><font size="1" color="black" face="arial"></td></tr> 
    <tr> 

     <td align="right" width=175 valign=top><font size="2" color="black" face="arial"><b>Address Verification:</b></font></td><td align="left"><font size="2" color="black" face="arial"> 

<?php 
    // Turn the AVS code into the corresponding text string. 
    switch ($AVS) 
    { 
     case "A": 
      echo "Address (Street) matches, ZIP does not."; 
      break; 
     case "B": 
      echo "Address Information Not Provided for AVS Check."; 
      break; 
     case "C": 
      echo "Street address and Postal Code not verified for international transaction due to incompatible formats. (Acquirer sent both street address and Postal Code.)"; 
      break; 
     case "D": 
      echo "International Transaction: Street address and Postal Code match."; 
      break; 
     case "E": 
      echo "AVS Error."; 
      break; 
     case "G": 
      echo "Non U.S. Card Issuing Bank."; 
      break; 
     case "N": 
      echo "No Match on Address (Street) or ZIP."; 
      break; 
     case "P": 
      echo "AVS not applicable for this transaction."; 
      break; 
     case "R": 
      echo "Retry. System unavailable or timed out."; 
      break; 
     case "S": 
      echo "Service not supported by issuer."; 
      break; 
     case "U": 
      echo "Address information is unavailable."; 
      break; 
     case "W": 
      echo "9 digit ZIP matches, Address (Street) does not."; 
      break; 
     case "X": 
      echo "Address (Street) and 9 digit ZIP match."; 
      break; 
     case "Y": 
      echo "Address (Street) and 5 digit ZIP match."; 
      break; 
     case "Z": 
      echo "5 digit ZIP matches, Address (Street) does not."; 
      break; 
     default: 
      echo "The address verification system returned an unknown value."; 
      break; 
     } 
?> 

     </td> 
    </tr> 
    </table> 
    </body> 
</html> 

您還可以使用Silent Post。這裏是一個PHP tutorial,展示瞭如何使用它。