0
我有一個小的查詢。當我的顧客輸入額度爲他的賬戶添加資金時,全部數額都會加到他的餘額上。我其實想要減去「x%」作爲處理/支付網關費用,並將剩餘餘額添加到他的帳戶中。Subtitles x當費用添加到PHP帳戶的費用supersite resellerclub
在下面的代碼中提到了兩個選項。即銷售貨幣金額和記賬貨幣金額。 銷售將是他所輸入的金額,記賬貨幣金額是扣除「x%」後將添加到其賬戶餘額中的金額。
我試過$_SESSION['accountingcurencyamount']=$sellingCurrencyAmount - ($sellingCurrencyAmount * (3/100));
。
以下是代碼:
<?php session_start();
@session_save_path("./"); ?>
<?php
include('config.php');
require('functions.php');
include('payment.php')?>
<?php
error_reporting(0);
/*Reseller Club Fields starts*/
$paymentTypeId = $_GET["paymenttypeid"]; //payment type id
$transId = $_GET["transid"]; //This refers to a unique transaction ID which we generate for each transaction
$userId = $_GET["userid"]; //userid of the user who is trying to make the payment
$userType = $_GET["usertype"]; //This refers to the type of user perofrming this transaction. The possible values are "Customer" or "Reseller"
$transactionType = $_GET["transactiontype"]; //Type of transaction (ResellerAddFund/CustomerAddFund/ResellerPayment/CustomerPayment)
$invoiceIds = $_GET["invoiceids"]; //comma separated Invoice Ids, This will have a value only if the transactiontype is "ResellerPayment" or "CustomerPayment"
$debitNoteIds = $_GET["debitnoteids"]; //comma separated DebitNotes Ids, This will have a value only if the transactiontype is "ResellerPayment" or "CustomerPayment"
$description = $_GET["description"];
$sellingCurrencyAmount = $_GET["sellingcurrencyamount"]; //This refers to the amount of transaction in your Selling Currency
// echo "Amount: " .$sellingCurrencyAmount;
$accountingCurrencyAmount = $_GET["accountingcurrencyamount"]; //This refers to the amount of transaction in your Accounting Currency
$redirectUrl = $_GET["redirecturl"]; //This is the URL on our server, to which you need to send the user once you have finished charging him
$checksuma = $_GET["checksum"]; //checksum for validation
/*Reseller Club Fields ends*/
$order_id=$_GET["transid"];
$amount= $_GET["sellingcurrencyamount"];
$currency=$currency;
$cancel_url=$redirect_url;
$language="EN";
$billing_name=$_GET["name"];
$billing_address=$_GET["address1"] ;
$billing_city=$_GET["city"];
$billing_state=$_GET["state"];
$billing_zip=$_GET["zip"];
$billing_country=$_GET["country"];
$billing_tel=$_POST["telNoCc"] . $_GET["telNo"];
$billing_email=$_GET["emailAddr"];
$delivery_name=$billing_name;
$delivery_address=$billing_address;
$delivery_city=$billing_city;
$delivery_state=$billing_state;
$delivery_zip=$billing_zip;
$delivery_country= $billing_country;
$delivery_tel=$billing_tel;
$merchant_param1="";
$merchant_param2="";
$merchant_param3="";
$merchant_param4="";
$merchant_param5="";
$promo_code="";
$customer_Id="";
/*Reseller Club code starts*/
if(verifyChecksum1($paymentTypeId, $transId, $userId, $userType, $transactionType, $invoiceIds, $debitNoteIds, $description, $sellingCurrencyAmount, $accountingCurrencyAmount, $key, $checksuma))
{
$_SESSION['redirecturl']=$redirectUrl;
$_SESSION['transid']=$transId;
$_SESSION['sellingcurrencyamount']=$sellingCurrencyAmount;
$_SESSION['accountingcurencyamount']=$accountingCurrencyAmount;
// $_SESSION['accountingcurencyamount']=$sellingCurrencyAmount - ($sellingCurrencyAmount * (3/100));
$checksumStatus=1;
}
else
{
$checksumStatus=0;
$base_url="";
}
//echo "Check: ".$checksumStatus;
//
// echo "<br/>Pay Id: ". $paymentTypeId;
// echo "<br/>Tran Id: ". $transId;
// echo "<br/>User Id: ". $userId;
// echo "<br/>User Type: ". $userType;
// echo "<br/>Tramscation Type: ". $transactionType;
// echo "<br/>Invoice ID: ". $invoiceIds;
// echo "<br/>debit note: ". $debitNoteIds;
// echo "<br/>Description: ". $description;
// echo "<br/>Selling Currency: ". $sellingCurrencyAmount;
// echo "<br/>Account currency: ". $accountingCurrencyAmount;
// echo "<br/>Key: ". $key;
// echo "<br/>Checksum: ". $checksuma;
/*Reseller Club code ends*/
class ProcessPayment {
function __construct(){
$this->paymentConfig = new payment_config();
}
function requestMerchant(){
$payment = new payment();
$datenow = date("d/m/Y h:m:s");
$modifiedDate = str_replace(" ", "%20", $datenow);
$payment->url = $this->paymentConfig->base_url;//$this->paymentConfig->Url;
$postFields = "";
$postFields .= "&login=".$this->paymentConfig->login_id;//$this->paymentConfig->Login;
$postFields .= "&pass=".$this->paymentConfig->password;//$this->paymentConfig->Password;
$postFields .= "&ttype=NBFundTransfer";//.$_POST['TType'];
$postFields .= "&prodid=HILL";//.$_POST['product'];
$postFields .= "&amt=".$GLOBALS['sellingCurrencyAmount'];
$postFields .= "&txncurr=".$this->paymentConfig->currency;//.$this->paymentConfig->TxnCurr;
$postFields .= "&txnscamt=".$this->paymentConfig->trn_service;//$this->paymentConfig->TxnScAmt;
$postFields .= "&clientcode=".urlencode(base64_encode($GLOBALS['billing_name']));
$postFields .= "&txnid=".rand(0,999999);
$postFields .= "&date=".$modifiedDate;
$postFields .= "&ru=".$this->paymentConfig->redirect_url;
$postFields .= "&custacc=".$GLOBALS['billing_tel'];
// Not required for merchant
//$postFields .= "&bankid=".$_POST['bankid'];
$sendUrl = $payment->url."?".substr($postFields,1)."\n";
$this->writeLog($sendUrl);
$returnData = $payment->sendInfo($postFields);
$this->writeLog($returnData."\n");
$xmlObjArray = $this->xmltoarray($returnData);
$url = $xmlObjArray['url'];
$postFields = "";
$postFields .= "&ttype=NBFundTransfer";//.$_POST['TType'];
$postFields .= "&tempTxnId=".$xmlObjArray['tempTxnId'];
$postFields .= "&token=".$xmlObjArray['token'];
$postFields .= "&txnStage=1";
$url = $payment->url."?".$postFields;
$this->writeLog($url."\n");
//echo "URL ". $url;
//echo "amount: " . $GLOBALS['sellingCurrencyAmount'];
//echo "<br/>Base URL ". $this->paymentConfig->base_url;
header("Location: ".$url);
}
function writeLog($data){
$fileName = date("Y-m-d").".txt";
$fp = fopen("log/".$fileName, 'a+');
$data = date("Y-m-d H:i:s")." - ".$data;
fwrite($fp,$data);
fclose($fp);
}
function xmltoarray($data){
$parser = xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($data), $xml_values);
xml_parser_free($parser);
$returnArray = array();
$returnArray['url'] = $xml_values[3]['value'];
$returnArray['tempTxnId'] = $xml_values[5]['value'];
$returnArray['token'] = $xml_values[6]['value'];
return $returnArray;
}
}
$processPayment = new ProcessPayment();
$processPayment->requestMerchant();
?>
所以它應該這樣ryt? $ _SESSION ['accountingcurencyamount'] = $ sellingCurrencyAmount - ($ sellingCurrencyAmount * .3); –
Thaq這麼多爲您的輸入@taxicala ..我試圖乘以減法的數量。但仍然全部金額增加..:/ –
這應該工作,無論如何,你應該解釋你的問題是什麼。 – taxicala