Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b35853f
commit ddd6a2d
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
require_once('config.php'); | ||
require_once('util.php'); | ||
|
||
$orderNumber = '123456-20180101-00111801'; | ||
if($_GET[num]) { | ||
$orderNumber = $_GET[num]; | ||
} | ||
|
||
$orderNumberList = array($orderNumber); | ||
|
||
|
||
|
||
list($httpStatusCode, $response) = confirmOrder($orderNumberList); | ||
|
||
/*** | ||
* RakutenPayOrderAPI confirmOrder APIを使って、楽天ペイ注文の「注文情報の取得」を行うことができます。 | ||
* サンプルレスポンスは下記 | ||
* */ | ||
function confirmOrder($orderNumberList) { | ||
$authkey = base64_encode(RMS_SERVICE_SECRET . ':' . RMS_LICENSE_KEY); | ||
$header = array( | ||
'Content-Type: application/json; charset=utf-8', | ||
"Authorization: ESA {$authkey}", | ||
); | ||
|
||
$requestJson = json_encode([ | ||
'orderNumberList' => $orderNumberList | ||
]); | ||
|
||
$url = RMS_API_RAKUTEN_PAY_CONFIRM_ORDER; | ||
|
||
$ch = curl_init($url); | ||
|
||
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestJson); | ||
curl_setopt($ch, CURLOPT_POST, true); | ||
curl_setopt($ch, CURLOPT_TIMEOUT, 30); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //返り値を 文字列で返します | ||
|
||
$response = curl_exec($ch); | ||
if(curl_error($ch)){ | ||
$response = curl_error($ch); | ||
} | ||
|
||
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | ||
|
||
$response = json_decode( $response, true ); | ||
|
||
curl_close($ch); | ||
return array($httpStatusCode, $response); | ||
} | ||
|
||
?> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>confirmOrder | RakutenPayOrderAPI</title> | ||
<meta charset="UTF-8"> | ||
<style> | ||
pre,code { | ||
width:100%; | ||
overflow: auto; | ||
white-space: pre-wrap; | ||
word-wrap: break-word; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div style="width:100%;"> | ||
<h1>レスポンス結果</h1> | ||
<h2>HTTP Status code</h2> | ||
<pre> | ||
<?php echo $httpStatusCode; ?> | ||
</pre> | ||
<h2>生レスポンス</h2> | ||
<pre> | ||
<?php | ||
echo print_r($response, true); | ||
?> | ||
</pre> | ||
</div> | ||
</body> | ||
</html> | ||
|