質問編集履歴
4
質問内容削除に対する修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
coincheckのAPIを使用して自分のECサイトで、ビットコインで決済ができるよう導入したいです。
|
body
CHANGED
@@ -1,3 +1,71 @@
|
|
1
|
-
|
1
|
+
###前提・実現したいこと
|
2
2
|
|
3
|
-
|
3
|
+
coincheckのAPIを使用して自分のECサイトで、ビットコインで決済ができるよう導入したいです。
|
4
|
+
そのために 支払い用ボタンの生成 を行いたいです。
|
5
|
+
PHPを使用しています。
|
6
|
+
|
7
|
+
coincheck API ドキュメント
|
8
|
+
https://coincheck.com/ja/documents/payment/api/auth
|
9
|
+
https://coincheck.com/ja/documents/payment/api/payment-button
|
10
|
+
|
11
|
+
ご教授お願い致します。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
###発生している問題・エラーメッセージ
|
16
|
+
|
17
|
+
|
18
|
+
返り値を表示すると
|
19
|
+
string(50) "{"success":false,"error":"invalid authentication"}"
|
20
|
+
こうなり、認証がうまくできていないのかと思います。
|
21
|
+
|
22
|
+
正常だとボタンを表示するhtml等が返ってくるらしいです。
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
###該当のソースコード
|
27
|
+
|
28
|
+
```PHP
|
29
|
+
|
30
|
+
$strUrl = "https://coincheck.com/api/ec/buttons";
|
31
|
+
$intNonce = time();
|
32
|
+
$strCallbackUrl = "https://www.google.co.jp/";
|
33
|
+
$arrQuery = array("button" => array(
|
34
|
+
"name" => "注文 #123",
|
35
|
+
"currency" => "JPY",
|
36
|
+
"amount" => 5000,
|
37
|
+
"callback_url" => $strCallbackUrl,
|
38
|
+
"max_times" => 1
|
39
|
+
));
|
40
|
+
$strAccessSecret = "実際には秘密鍵が入ります";
|
41
|
+
$strMessage = $intNonce . $strUrl . http_build_query($arrQuery);
|
42
|
+
|
43
|
+
# hmacで署名
|
44
|
+
$strSignature = hash_hmac("sha256", $strMessage, $strAccessSecret);
|
45
|
+
|
46
|
+
$headers = array(
|
47
|
+
"ACCESS-KEY:実際にはAPIキーが入ります",
|
48
|
+
"ACCESS-SIGNATURE:" . $strSignature,
|
49
|
+
"ACCESS-NONCE:" . $intNonce
|
50
|
+
);
|
51
|
+
|
52
|
+
$url = "https://coincheck.com/api/ec/buttons";
|
53
|
+
$ch = curl_init();
|
54
|
+
curl_setopt($ch, CURLOPT_URL, $url);
|
55
|
+
curl_setopt($ch,CURLOPT_POST, true);
|
56
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
57
|
+
|
58
|
+
|
59
|
+
// ヘッダー追加
|
60
|
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
61
|
+
|
62
|
+
// postdata追加
|
63
|
+
$post_data = array('button[name]' => "注文 #123" ,'button[currency]'=> "JPY" ,"button[display_currency]"=>"JPY",'button[amount]' => 5000,'button[callback_url]'=> "http://www.example.com/coincheck/callback" ,"button[success_url]"=>"http://google.co.jp/" ,"button[max_times]"=>1 ,"button[include_name]"=>true ,"button[include_email]"=>true,"button[include_address]"=>false,"button[custom]"=>"123","button[notify_mispayment]"=>true);
|
64
|
+
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
|
65
|
+
|
66
|
+
|
67
|
+
$html = curl_exec($ch);
|
68
|
+
var_dump($html);
|
69
|
+
|
70
|
+
curl_close($ch);
|
71
|
+
```
|
3
ありがとうございます
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
ACCESS-SIGNATURE は、 ACCESS-NONCE URL リクエストのボディ を全て文字列にし、連結したものを、HMAC-SHA256 hash形式でAPIキーのシークレットキーを使って署名した結果です。
|
2
2
|
|
3
|
-
ありがとうございます、目から鱗です
|
3
|
+
ありがとうございます、目から鱗です◝₍ᴑ̑ДO͝₎◞
|
2
ありがとうございます
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,1 +1,3 @@
|
|
1
|
-
|
1
|
+
ACCESS-SIGNATURE は、 ACCESS-NONCE URL リクエストのボディ を全て文字列にし、連結したものを、HMAC-SHA256 hash形式でAPIキーのシークレットキーを使って署名した結果です。
|
2
|
+
|
3
|
+
ありがとうございます、目から鱗です
|
1
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
ありがとうございます
|
body
CHANGED
@@ -1,71 +1,1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
coincheckのAPIを使用して自分のECサイトで、ビットコインで決済ができるよう導入したいです。
|
4
|
-
そのために 支払い用ボタンの生成 を行いたいです。
|
5
|
-
PHPを使用しています。
|
6
|
-
|
7
|
-
coincheck API ドキュメント
|
8
|
-
https://coincheck.com/ja/documents/payment/api/auth
|
9
|
-
https://coincheck.com/ja/documents/payment/api/payment-button
|
10
|
-
|
11
|
-
ご教授お願い致します。
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
###発生している問題・エラーメッセージ
|
16
|
-
|
17
|
-
|
18
|
-
返り値を表示すると
|
19
|
-
string(50) "{"success":false,"error":"invalid authentication"}"
|
20
|
-
こうなり、認証がうまくできていないのかと思います。
|
21
|
-
|
22
|
-
正常だとボタンを表示するhtml等が返ってくるらしいです。
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
###該当のソースコード
|
27
|
-
|
28
|
-
```PHP
|
29
|
-
|
30
|
-
$strUrl = "https://coincheck.com/api/ec/buttons";
|
31
|
-
$intNonce = time();
|
32
|
-
$strCallbackUrl = "https://www.google.co.jp/";
|
33
|
-
$arrQuery = array("button" => array(
|
34
|
-
"name" => "注文 #123",
|
35
|
-
"currency" => "JPY",
|
36
|
-
"amount" => 5000,
|
37
|
-
"callback_url" => $strCallbackUrl,
|
38
|
-
"max_times" => 1
|
39
|
-
));
|
40
|
-
$strAccessSecret = "実際には秘密鍵が入ります";
|
41
|
-
$strMessage = $intNonce . $strUrl . http_build_query($arrQuery);
|
42
|
-
|
43
|
-
# hmacで署名
|
44
|
-
$strSignature = hash_hmac("sha256", $strMessage, $strAccessSecret);
|
45
|
-
|
46
|
-
$headers = array(
|
47
|
-
"ACCESS-KEY:実際にはAPIキーが入ります",
|
48
|
-
"ACCESS-SIGNATURE:" . $strSignature,
|
49
|
-
"ACCESS-NONCE:" . $intNonce
|
50
|
-
);
|
51
|
-
|
52
|
-
$url = "https://coincheck.com/api/ec/buttons";
|
53
|
-
$ch = curl_init();
|
54
|
-
curl_setopt($ch, CURLOPT_URL, $url);
|
55
|
-
curl_setopt($ch,CURLOPT_POST, true);
|
56
|
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
57
|
-
|
58
|
-
|
59
|
-
// ヘッダー追加
|
60
|
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
61
|
-
|
62
|
-
// postdata追加
|
63
|
-
$post_data = array('button[name]' => "注文 #123" ,'button[currency]'=> "JPY" ,"button[display_currency]"=>"JPY",'button[amount]' => 5000,'button[callback_url]'=> "http://www.example.com/coincheck/callback" ,"button[success_url]"=>"http://google.co.jp/" ,"button[max_times]"=>1 ,"button[include_name]"=>true ,"button[include_email]"=>true,"button[include_address]"=>false,"button[custom]"=>"123","button[notify_mispayment]"=>true);
|
64
|
-
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
|
65
|
-
|
66
|
-
|
67
|
-
$html = curl_exec($ch);
|
68
|
-
var_dump($html);
|
69
|
-
|
70
|
-
curl_close($ch);
|
71
|
-
```
|
1
|
+
ありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございます
|