Welcome Guest, Not a member yet? Register   Sign In
HTTP POST from Controller, NOT from HTML Form
#11

[eluser]tkaw220[/eluser]
@markscutts:

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.
#12

[eluser]skunkbad[/eluser]
What payment gateway is this?
#13

[eluser]tkaw220[/eluser]
@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.
#14

[eluser]toopay[/eluser]
[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.
#15

[eluser]skunkbad[/eluser]
You might take a look at my cURL used with authorize.net:

https://bitbucket.org/skunkbad/community...uthnet.php

and linkpoint / First Data:

https://bitbucket.org/skunkbad/community...kpoint.php

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

Code:
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $this->xml);
#16

[eluser]Aken[/eluser]
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.
#17

[eluser]tkaw220[/eluser]
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->load->library('Curl');
$this->curl->create($PaymentRequestURL);
$this->curl->option(CURLOPT_REFERER, site_url() . '/order/review_order/');
$this->curl->option(CURLOPT_FOLLOWLOCATION, 1);
$this->curl->post($postdata);
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.




Theme © iAndrew 2016 - Forum software by © MyBB