1

am trying to connect with filspay API directpay method, they request to send the parameters through GET REQUEST to their server and add our IP to their white list so we can contact the payment server.

The querystring look like https://api.filspay.com/Default.aspx?trxRefNumber=[String]&PinId=[Integer]&Amount=[Double]&Description=[String]&hashCode=[String]&MerchantId=[Integer]

Our first file code is :

 <?php
function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $randomString;
}

$amount = 1;
$amount = stripslashes($amount);
$amount = strip_tags($amount);
$amount = htmlentities($amount, ENT_QUOTES, 'UTF-8');


$hashCode = md5(md5('e643d9b6-bcfc-47').'001'.'670127'.'35422'.'35.00'.'49f25465b6c62aa15f88d5e1ae179011cb8ee70e');
$trxRefNumber = generateRandomString (20) ; 
$merchantid = '670127'; 
$pinid = '35422';


?>
<form action="filspay2.php" method="POST" name="filspay_send">
<input type="hidden" name="trxRefNumber" value="<?php echo $trxRefNumber; ?>">
PinID : <input type="text" name="PinId" value="<? echo $pinid; ?>"> <br>
<input type="hidden" name="amount" value="<?php echo $amount; ?>">
<input type="hidden" name="Description" value="sdaf adf sd">
<input type="hidden" name="hashCode" value="<?php echo $hashCode; ?>">
<input type="hidden" name="MerchantId" value="<?php echo $merchantid; ?>">

<br>

<input type="submit" name="pay" value="pay">
</form>

while second file which contact their server is

 <?php
$r = new HttpRequest('https://api.filspay.com/Default.aspx', HttpRequest::METH_POST);

$r->addPostFields(array('trxRefNumber' => $_Post['trxRefNumber']));
$r->addPostFields(array('PinId' => $_Post['PinId']));
$r->addPostFields(array('amount' => $_Post['amount']));
$r->addPostFields(array('Description' => $_Post['Description']));
$r->addPostFields(array('hashCode' => $_Post['hashCode']));
$r->addPostFields(array('MerchantId' => $_Post['MerchantId']));

try {
    echo $r->send()->getBody();
} catch (HttpException $ex) {
    echo $ex;
}

But am still getting this error : Server Error

403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.

I confirm that they add our IP address to their white list.

Dan
  • 343
  • 3
  • 9
  • 21

1 Answers1

0

HTTPS Not supporting http request. you need to use curl to get the correct response from request URL

$postfields = array('field1'=>'value1', 'field2'=>'value2');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.filspay.com/Default.aspx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
// Edit: prior variable $postFields should be $postfields;
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);

Error Handling

 error : Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in/home/bedaeaco/public_html/filspay/filspay22.php on line 7

Answer

first I think your are not configured curl in your server. So contact your hosting provider and enable curl into your server.

That error means that your PHP configuration is prohibiting you from following the location. There are a few ways you could work around the problem without installing additional libraries as suggested by @mario.

If you own the server or have root access, you could change the php.ini file to disable "safe_mode".
You could also create a .htaccess file in your document root with php_value safe_mode off in it.
You may be able to add ini_set('safe_mode', false); in your PHP file.

If none of the above works, you could also do something along these lines:

Refer this link.

Community
  • 1
  • 1
Padmanathan J
  • 4,614
  • 5
  • 37
  • 75
  • I got this error : Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in/home/bedaeaco/public_html/filspay/filspay22.php on line 7 – Dan Dec 18 '13 at 23:06
  • first I think your are not configured curl in your server. So contact your hosting provider and enable curl into your server. – Padmanathan J Dec 19 '13 at 03:43
  • check your configuration file using https://kb.mediatemple.net/questions/764/How+can+I+create+a+phpinfo.php+page%3F#gs this link – Padmanathan J Dec 19 '13 at 03:46
  • you just create this phpinfo file and upload this file into live server folder path. just run this file and its shows your php configuration. you just check the curl enable are not. if not enable contact your server provider. – Padmanathan J Dec 19 '13 at 03:47