PHPにおける決済サーバとの接続について
// POSTフォームの構成
$context =
'http' => array(
'method' => 'POST',
'header' => implode("\r\n", array(
'Content-Type: application/x-www-form-urlencoded',
)),
//パラメータ(決済情報に送るデータの設定
'content' => http_build_query(array(
'SETL_CLASS' => XXXX, // 取引種別
・・・・・
))));
// 決済サーバのURL
$url = NNNN; //httpsでも可能
// 決済
if (($ret_raw = file_get_contents($url, false, $context)) === FALSE) {
if (is_null($http_response_header)) {
die("サーバまたはクライアントエラー");
}
$list = split(' ', $http_response_header[0]);
echo ("サーバエラーコード:") . $list[1]; //ステータスコード出力
} else {
//正常系
//ダンプ出力
//var_dump($http_response_header) . "
";
//応答電文の分解
$raw = split("\r\n", $ret_raw);
//ダンプ出力
//var_dump($raw) . "
";
for ($i = 0; $i < count($raw); $i++) {
$temp = split("=", $raw[$i]);
//echo $temp[0] . " = " . $temp[1]. "
";
$result[$temp[0]] = $temp[1];
}
}
?>