• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTTP POST from Controller, NOT from HTML Form


How do I see my own user agent string from my browser?

When looking at the report from my payment gateway, those requests submitted via cURL comes from my hosting server located in US, and the IP is the IP of that server. If I submit the request using direct HTML form, the location would be my country, and the IP is my PC's IP. Is there anyway to submit my own PC's location and IP to the payment gateway by using cURL? Which CURLOPT to use?

Many thanks.

What payment gateway is this?

@skunkbad: It is a solution provider in Singapore.

By the way, when conducting cURL, how do I make sure that my HTTP Request method is POST instead of GET? I take a look at the output, I realized this line: [REQUEST_METHOD] => GET. I suspect this caused the problem.

[quote author="tkaw220" date="1303732352"]how do I make sure that my HTTP Request method is POST instead of GET? [/quote]

on your curl_setopt(_array) set CURLOPT_POST option with 'TRUE' value.

You might take a look at my cURL used with authorize.net:


and linkpoint / First Data:


The linkpoint script shows how to make cURL do a post:

curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $this->xml);

You should also find any developer documentation provided by your payment gateway, and/or contact some sort of customer service there and ask. As others said, it would make no sense for a payment gateway with an API to prevent an HTTP post from a customer's server.

Dear all,

After days of trial and research, I found that my problem comes from cURL redirect. Below I enclosed my codes:

$postdata = array(
'MerchantCode' => $MerchantCode,
'PaymentId' => $this->session->userdata('payment_method'),
'RefNo' => $RefNo,
'Amount' => $Amount,
'Currency' => $Currency,
'UserName' => $this->session->userdata('billing_first_name'),
'UserEmail' => $this->session->userdata('email'),
'UserContact' => $this->session->userdata('billing_mobile'),
'Lang' => 'UTF-8',
'Signature' => $Signature,
'ResponseURL' => site_url() . '/order/payment_response'

$this->curl->option(CURLOPT_REFERER, site_url() . '/order/review_order/');
$this->curl->option(CURLOPT_FOLLOWLOCATION, 1);
echo $this->curl->execute();

I used the cURL library for CI written by Philip Sturgeon. The above codes POST to payment request page sucessfully, it accepts all the parameters, but when I take a look at the browser URL, the page stuck at my Controller, and does not redirected to payment gateway page completely. This resulting missing images and validation scripts (Firebug shown the browser tries to load all the assets from my site, in fact those assets should come from payment gateway server).

I searched for cURL redirect problem and found this link, http://www.phpbuilder.com/board/showthre...t=10299554. The user and I is having the same problem.

How do I fix the code so it redirected to payment request page completely?

Many thanks.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.