2017-10-20 232 views
-1

我正試圖將我們的新付款系統與我們的網站進行整合。但是我打了一堵牆。 基本上,我的客戶將通過我的網站支付託兒費用。然而,每月的金額會有所變化,並且每個人都會依賴孩子們將要參加的活動。 我使用網關公司提供的代碼,但輸入的金額與通過哈希發送的金額不匹配。因此不允許我在他們的網站上完成交易。 我試圖回顯電荷值並將其稱爲變量中的哈希,但它不喜歡這一點。儘管他們似乎沒有能力,但我已經要求公司尋求幫助。付款集成

下面是代碼。如果有人能提供幫助,我將不勝感激。 在我們的網站

<? include("ipg-util.php"); ?> 
<html> 
    <?php 

    ob_start(); 
echo $chargetotal; 
$total = ob_get_contents($chargetotal); 
ob_end_clean(); 

    ?> 

<head><title>IPG Connect Sample for PHP</title></head> 
<body> 
<p><h1>Order Form</h1> 
<form method="post" action="https://www.ipg-online.com/connect/gateway/processing"> 
<input type="hidden" name="txntype" value="sale"> 
<input type="hidden" name="timezone" value="Europe/London"/> 
<input type="hidden" name="txndatetime" value="<?php echo 
getDateTime() ?>"/> 
<input type=」hidden」 name=」hash_algorithm」 value=」SHA256」/> 
<input type="hidden" name="hash" value="<?php echo createHash(
$total,"826") ?>"/> 
<input type="hidden" name="storename" value="Hidden"/> 
<input type="hidden" name="mode" value="payonly"/> 
<input type="hidden" name="paymentMethod" value="M"/> 
<input type="text" name="chargetotal" value=""/> 
<input type="hidden" name="currency" value="826"/> 
<input type="hidden" name="responseSuccessURL" value="http://yourdomain.com/Thanks" /> 
    <input type="hidden" name="responseFailURL" value="http://yourdomain.com/PaymentFailure" /> 
<input type="submit" value="Submit"> 
</form> 
</body> 
</html> 

付款頁面與包括頁面

<?php 







    $dateTime = date("Y:m:d-H:i:s"); 



    function getDateTime() { 

     global $dateTime; 

     return $dateTime; 

    } 


    function createHash($chargetotal, $currency) { 

     $storename ="Hidden"; 

    $sharedSecret = "Hidden"; 



     $stringToHash = $storename . getDateTime() . $chargetotal . $currency . $sharedSecret; 



     $ascii = bin2hex($stringToHash); 



     return sha1($ascii); 

    } 



?> 

我也包括錯誤網頁 結果頁面

基本上在散量和充電量需要對其進行正確生成相同。

如果我輸入15在chargetotal的量,我把15的數量,在哈希像這樣

<input type="hidden" name="hash" value="<?php echo createHash(
    "15","826") ?>"/> . 

它將允許完成交易,但我們不知道量來計算每個人會付錢。

感謝您看

+0

修復HTML中的引號,你有一些引號應該是直引號。 – Barmar

+1

檢查預期貨幣格式,一些API需要美分,而不是美元和美分 – rtfm

回答

0

你發送一個空白的費用總額爲以下代碼:

<input type="text" name="chargetotal" value=""/> 

我不熟悉您使用的API,但是我想你應該做類似的事情:

<input type="text" name="chargetotal" value="<?php echo $chargetotal; ?>"/>