0

网上没有教程。只有文档

我要做的就是将此代码传递给模块

<!-- 
  - paymentTestForm.php
  -     Description: 

<?
    $SECURE_SECRET = "";

    if (isset($_POST['accessCode']))
    {
        ksort($_POST);
        $md5HashData = $SECURE_SECRET;

        foreach($_POST as $key => $value) 
        {

            if (strlen($value) > 0 && ($key == 'accessCode' || $key == 'merchTxnRef' || $key == 'merchant' || $key == 'orderInfo' || $key == 'amount' || $key == 'returnURL')) {
                print 'Key: '.$key.'  Value: '.$value."<br>";

                if ($appendAmp == 0) 
                {
                    $vpcURL .= urlencode($key) . '=' . urlencode($value);
                    $appendAmp = 1;
                } else {
                    $vpcURL .= '&' . urlencode($key) . "=" . urlencode($value);
                }
                $md5HashData .= $value;
            }
        }   
        $newHash .= $vpcURL."&vpc_SecureHash=" . strtoupper(md5($md5HashData));
        echo "<script>location.href='https://gw1.audicards.com/TPGWeb/payment/prepayment.action?$newHash'</script>";
        exit;

    }


?>



<table border="0" cellpadding='0' cellspacing='0' align="center">
    <tr>
        <td align="right"><strong><em>Merchant AccessCode: </em></strong></td>
        <td><input name="accessCode" value="" size="20" maxlength="8"/></td>
    </tr>
    <tr class="shade">
        <td align="right"><strong><em>Merchant Transaction Reference: </em></strong></td>
        <td><input name="merchTxnRef" value="" size="20" maxlength="40"/></td>
    </tr>
    <tr>
        <td align="right"><strong><em>MerchantID: </em></strong></td>
        <td><input name="merchant" value="" size="20" maxlength="16"/></td>
    </tr>
    <tr class="shade">
        <td align="right"><strong><em>Transaction OrderInfo: </em></strong></td>
        <td><input name="orderInfo" value="" size="20" maxlength="34"/></td>
    </tr>
    <tr>
        <td align="right"><strong><em>Purchase Amount: </em></strong></td>
        <td><input name="amount" value="500" maxlength="10"/></td>
    </tr>
    <tr class="shade">
        <td align="right"><strong><em>Receipt ReturnURL: </em></strong></td>
        <td><input name="returnURL" size="65" value="http://localhost/audiPayment/paymentTestForm.php?action=py" maxlength="250"/></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td><input type="submit" NAME="SubButL" value="Pay Now!"></td>
    </tr>  
</table>
<?
//check if this page is being redirected from payment client thus carrying the field vpc_TxnResponseCode
if (isset($_GET['vpc_TxnResponseCode']))
{
    function getResponseDescription($responseCode) 
    {
        switch ($responseCode) {
            case "0" : $result = "Transaction Successful"; break;
            case "?" : $result = "Transaction status is unknown"; break;
            case "1" : $result = "Unknown Error"; break;
            case "2" : $result = "Bank Declined Transaction"; break;
            case "3" : $result = "No Reply from Bank"; break;
            case "4" : $result = "Expired Card"; break;
            case "5" : $result = "Insufficient funds"; break;
            case "6" : $result = "Error Communicating with Bank"; break;
            case "7" : $result = "Payment Server System Error"; break;
            case "8" : $result = "Transaction Type Not Supported"; break;
            case "9" : $result = "Bank declined transaction (Do not contact Bank)"; break;
            case "A" : $result = "Transaction Aborted"; break;
            case "C" : $result = "Transaction Cancelled"; break;
            case "D" : $result = "Deferred transaction has been received and is awaiting processing"; break;
            case "E" : $result = "Invalid Credit Card"; break;
            case "F" : $result = "3D Secure Authentication failed"; break;
            case "I" : $result = "Card Security Code verification failed"; break;
            case "G" : $result = "Invalid Merchant"; break;
            case "L" : $result = "Shopping Transaction Locked (Please try the transaction again later)"; break;
            case "N" : $result = "Cardholder is not enrolled in Authentication scheme"; break;
            case "P" : $result = "Transaction has been received by the Payment Adaptor and is being processed"; break;
            case "R" : $result = "Transaction was not processed - Reached limit of retry attempts allowed"; break;
            case "S" : $result = "Duplicate SessionID (OrderInfo)"; break;
            case "T" : $result = "Address Verification Failed"; break;
            case "U" : $result = "Card Security Code Failed"; break;


            default  : $result = "Unable to be determined"; 
        }
        return $result;
    }


    function null2unknown($data) 
    {
        if ($data == "") 
            return "No Value Returned";
         else 
            return $data;
    }       

    $vpc_Txn_Secure_Hash = addslashes($_GET["vpc_SecureHash"]);
    unset($_GET["vpc_SecureHash"]); 
    ksort($_GET);

    $errorExists = false;

    if (strlen($SECURE_SECRET) > 0 && addslashes($_GET["vpc_TxnResponseCode"]) != "7" && addslashes($_GET["vpc_TxnResponseCode"]) != "No Value Returned") 
    {

        $md5HashData = $SECURE_SECRET;

        foreach($_GET as $key => $value) 
        {
            if ($key != "vpc_SecureHash" && strlen($value) > 0 && $key != 'action' ) 
            {
                $hash_value = str_replace(" ",'+',$value);
                $hash_value = str_replace("%20",'+',$hash_value);

                $md5HashData .= $hash_value;

            }
        }


        if (strtoupper($vpc_Txn_Secure_Hash) == strtoupper(md5($md5HashData))) 
        {
            $hashValidated = "<b>CORRECT</b>";
        } 
        else 
        {
            $hashValidated = "<b>INVALID HASH</b>";
            $errorExists = true;
        }
    } 
    else 
    {
        $hashValidated = "<FONT color='orange'><b>Not Calculated - No 'SECURE_SECRET' present.</b></FONT>";
    }

    $amount          = null2unknown(addslashes($_GET["vpc_Amount"])/100);
    $locale          = null2unknown(addslashes($_GET["vpc_Locale"]));
    $batchNo         = null2unknown(addslashes($_GET["vpc_BatchNo"]));
    $command         = null2unknown(addslashes($_GET["vpc_Command"]));
    $message         = null2unknown(addslashes($_GET["vpc_Message"]));
    $version         = null2unknown(addslashes($_GET["vpc_Version"]));
    $cardType        = null2unknown(addslashes($_GET["vpc_Card"]));
    $orderInfo       = null2unknown(addslashes($_GET["vpc_OrderInfo"]));
    $receiptNo       = null2unknown(addslashes($_GET["vpc_ReceiptNo"]));



    $errorTxt = "";


    if ($txnResponseCode == "7" || $txnResponseCode == "No Value Returned" || $errorExists) {
        $errorTxt = "Error ";
    }

    ?>

            <table width="85%" align="center" cellpadding="5" border="0">
                <tr>
                    <td align="right"><b>Hash Validity:</b></td>
                    <td class="errorMsg"><?=$hashValidated?></td>
                </tr>

                <tr>
                    <td align="right"><b>Merchant Transaction Reference: </b></td>
                    <td><?=$merchTxnRef?></td>
                </tr>
                <tr>
                    <td align="right"><b>Merchant ID: </b></td>
                    <td><?=$merchantID?></td>
                </tr>
                <tr>
                    <td align="right"><b>Order Information: </b></td>
                    <td><?=$orderInfo?></td>
                </tr>
                <tr>
                    <td align="right"><b>Purchase Amount: </b></td>
                    <td><?=$amount?></td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                    <hr />
                    </td>
                </tr>

                <tr>
                    <td colspan="2" align="center">
                        Fields above are the request values returned.<br>
                        Fields below are the response fields for a Standard Transaction.<br>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                    <hr />
                    </td>
                </tr>            
                <tr>
                    <td align="right"><b>VPC Transaction Response Code: </b></td>
                    <td><?=$txnResponseCode?></td>
                </tr>
                <tr>
                    <td align="right"><b>Transaction Response Code Description:</b></td>
                    <td class="errorMsg"><?=getResponseDescription($txnResponseCode)?></td>
                </tr>
                <tr>
                    <td align="right"><b>Message: </b></td>
                    <td><?=$message?></td>
                </tr>
    <?

        if ($txnResponseCode != "7" && $txnResponseCode != "No Value Returned") 
        { 
    ?>
                <tr>
                    <td align="right"><b>Receipt Number: </b></td>
                    <td><?=$receiptNo?></td>
                </tr>
                <tr>
                    <td align="right"><b>Transaction Number: </b></td>
                    <td><?=$transactionNo?></td>
                </tr>
                <tr>
                    <td align="right"><b>Acquirer Response Code: </b></td>
                    <td><?=$acqResponseCode?></td>
                </tr>
                <tr>
                    <td align="right"><b>Bank Authorization ID: </b></td>
                    <td><?=$authorizeID?></td>
                </tr>
                <tr>
                    <td align="right"><b>Batch Number: </b></td>
                    <td><?=$batchNo?></td>
                </tr>
                <tr>
                    <td align="right"><b>Card Type: </b></td>
                    <td><?=$cardType?></td>
                </tr>   
                <tr>
                    <td colspan="2"><HR /></td>
                </tr>
    <? 
    } 
    ?>    
            </table>
<?
}
?>  

它是一个类似于 paypal 的支付模块,我的 php 代码可以工作,我只想从中创建一个模块。管理员为每门课程设置价格。Paypal 的 efront 模块不是开源的,所以我看不出它是如何工作的。谁能告诉我如何创建一个模块来调用我的代码?

4

0 回答 0