4

Recently i started working on the Payment Gateway( further spelled as 'PG') process for my site. The process involves sending the Post data by form to PG server by redirecting to their page, and receiving a response from the PG about the Transaction via POST data sent by redirecting the URL to our server page.

The problem arises here, as my server unable to retrieve the POST Data sent from PG server.

As I am coding in PHP, I tried to print all the response coming from PG with print_r($_POST); and even tried with print_r($_REQUEST);. I didn't find any data printing except the PHPSESSID and some other data array.

As for the confirmation I checked whether they were sending the Data or not with the IE addon known as "TamperIE". It is showing all the POST data sending to their server. But it is not at all coming to our server. I tried this process on another Server: there I was able to get the POST response, but not with currently working server.

Can you suggest what might be the problem?

4

4 に答える 4

0

この問題が発生している理由を見つけました。

.htaccessファイルに、リダイレクトの行を書きました。

RewriteRule ^ http://mysite.com{REQUEST_URI} [R=301,L]

上記の行をファイルから削除すると、PGサーバーからPOSTフィールドを受信できますが、 PGに進む前に保存されているセッションデータが失われ、予約情報が含まれています。サーバーが応答ページからまったく新しいセッションを生成しているため、これらのセッションは応答ページに表示できません。

この問題の代替ソリューションを1つ見つけました。

私は、セッションを必要とするすべてのページで次のコードを使用しています。

$lifetime=60*30;
session_set_cookie_params ( $lifetime , '/', '.mysite.com');

上記のコードを前に追加した後session_start();

これで、 PGからPOSTデータを取得することも、SESSION値を保持することもできます。

ただし、これはこの問題の理想的な解決策ではないと思います。誰かがURLリダイレクトのサーバー構成を提案し、リダイレクト後にSESSION値を維持できるとしたら、それは素晴らしいことです。皆さん、ありがとうございました :-)

于 2012-10-19T07:43:59.587 に答える
0

curl を使用して他のサーバーからのリクエストをシミュレートし、次の内容の test.php を作成します。

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/path/to/form");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$data = array(
    'foo' => 'foo foo foo',
    'bar' => 'bar bar bar',
    'baz' => 'baz baz baz'
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);

curl_close($ch);

cli を使用して実行し、デバッグ情報を取得して何が問題なのかを確認します。もちろん、サーバーから返されるはずの変数と正確なURLを入れることを忘れないでください

于 2012-10-16T12:22:22.200 に答える
0

可能であれば、PG 要求で販売/購入注文の一意のコード (注文 ID) を送信してください。PG はその一意のコードを POST データで送り返し、その一意のコードを使用してその注文 ID を追跡できると確信しています。注文のステータスを更新します。

このアプローチを使用すると、セッションについて心配する必要がなくなります。

于 2012-10-22T10:57:57.540 に答える
0

これには、安全で信頼できる CURl を使用してください。

于 2012-11-06T12:21:11.057 に答える