質問編集履歴
4
質問内容削除に対する修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
coincheckのAPIを使用して自分のECサイトで、ビットコインで決済ができるよう導入したいです。
|
test
CHANGED
@@ -1,5 +1,141 @@
|
|
1
|
-
|
1
|
+
###前提・実現したいこと
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
5
|
+
coincheckのAPIを使用して自分のECサイトで、ビットコインで決済ができるよう導入したいです。
|
6
|
+
|
7
|
+
そのために 支払い用ボタンの生成 を行いたいです。
|
8
|
+
|
9
|
+
PHPを使用しています。
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
coincheck API ドキュメント
|
14
|
+
|
15
|
+
https://coincheck.com/ja/documents/payment/api/auth
|
16
|
+
|
17
|
+
https://coincheck.com/ja/documents/payment/api/payment-button
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
ご教授お願い致します。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
###発生している問題・エラーメッセージ
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
返り値を表示すると
|
36
|
+
|
37
|
+
string(50) "{"success":false,"error":"invalid authentication"}"
|
38
|
+
|
39
|
+
こうなり、認証がうまくできていないのかと思います。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
正常だとボタンを表示するhtml等が返ってくるらしいです。
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
###該当のソースコード
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
```PHP
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
$strUrl = "https://coincheck.com/api/ec/buttons";
|
60
|
+
|
61
|
+
$intNonce = time();
|
62
|
+
|
63
|
+
$strCallbackUrl = "https://www.google.co.jp/";
|
64
|
+
|
65
|
+
$arrQuery = array("button" => array(
|
66
|
+
|
67
|
+
"name" => "注文 #123",
|
68
|
+
|
69
|
+
"currency" => "JPY",
|
70
|
+
|
71
|
+
"amount" => 5000,
|
72
|
+
|
73
|
+
"callback_url" => $strCallbackUrl,
|
74
|
+
|
75
|
+
"max_times" => 1
|
76
|
+
|
77
|
+
));
|
78
|
+
|
79
|
+
$strAccessSecret = "実際には秘密鍵が入ります";
|
80
|
+
|
81
|
+
$strMessage = $intNonce . $strUrl . http_build_query($arrQuery);
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
# hmacで署名
|
86
|
+
|
87
|
+
$strSignature = hash_hmac("sha256", $strMessage, $strAccessSecret);
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
$headers = array(
|
92
|
+
|
93
|
+
"ACCESS-KEY:実際にはAPIキーが入ります",
|
94
|
+
|
95
|
+
"ACCESS-SIGNATURE:" . $strSignature,
|
96
|
+
|
97
|
+
"ACCESS-NONCE:" . $intNonce
|
98
|
+
|
99
|
+
);
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
$url = "https://coincheck.com/api/ec/buttons";
|
104
|
+
|
105
|
+
$ch = curl_init();
|
106
|
+
|
107
|
+
curl_setopt($ch, CURLOPT_URL, $url);
|
108
|
+
|
109
|
+
curl_setopt($ch,CURLOPT_POST, true);
|
110
|
+
|
111
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
// ヘッダー追加
|
118
|
+
|
119
|
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
// postdata追加
|
124
|
+
|
125
|
+
$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);
|
126
|
+
|
127
|
+
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
$html = curl_exec($ch);
|
134
|
+
|
135
|
+
var_dump($html);
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
curl_close($ch);
|
140
|
+
|
141
|
+
```
|
3
ありがとうございます
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
ありがとうございます、目から鱗です
|
5
|
+
ありがとうございます、目から鱗です◝₍ᴑ̑ДO͝₎◞
|
2
ありがとうございます
test
CHANGED
File without changes
|
test
CHANGED
@@ -1 +1,5 @@
|
|
1
|
-
|
1
|
+
ACCESS-SIGNATURE は、 ACCESS-NONCE URL リクエストのボディ を全て文字列にし、連結したものを、HMAC-SHA256 hash形式でAPIキーのシークレットキーを使って署名した結果です。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
ありがとうございます、目から鱗です
|
1
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ありがとうございます
|
test
CHANGED
@@ -1,141 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
coincheckのAPIを使用して自分のECサイトで、ビットコインで決済ができるよう導入したいです。
|
6
|
-
|
7
|
-
そのために 支払い用ボタンの生成 を行いたいです。
|
8
|
-
|
9
|
-
PHPを使用しています。
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
coincheck API ドキュメント
|
14
|
-
|
15
|
-
https://coincheck.com/ja/documents/payment/api/auth
|
16
|
-
|
17
|
-
https://coincheck.com/ja/documents/payment/api/payment-button
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
ご教授お願い致します。
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
###発生している問題・エラーメッセージ
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
返り値を表示すると
|
36
|
-
|
37
|
-
string(50) "{"success":false,"error":"invalid authentication"}"
|
38
|
-
|
39
|
-
こうなり、認証がうまくできていないのかと思います。
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
正常だとボタンを表示するhtml等が返ってくるらしいです。
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
###該当のソースコード
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
```PHP
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
$strUrl = "https://coincheck.com/api/ec/buttons";
|
60
|
-
|
61
|
-
$intNonce = time();
|
62
|
-
|
63
|
-
$strCallbackUrl = "https://www.google.co.jp/";
|
64
|
-
|
65
|
-
$arrQuery = array("button" => array(
|
66
|
-
|
67
|
-
"name" => "注文 #123",
|
68
|
-
|
69
|
-
"currency" => "JPY",
|
70
|
-
|
71
|
-
"amount" => 5000,
|
72
|
-
|
73
|
-
"callback_url" => $strCallbackUrl,
|
74
|
-
|
75
|
-
"max_times" => 1
|
76
|
-
|
77
|
-
));
|
78
|
-
|
79
|
-
$strAccessSecret = "実際には秘密鍵が入ります";
|
80
|
-
|
81
|
-
$strMessage = $intNonce . $strUrl . http_build_query($arrQuery);
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
# hmacで署名
|
86
|
-
|
87
|
-
$strSignature = hash_hmac("sha256", $strMessage, $strAccessSecret);
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
$headers = array(
|
92
|
-
|
93
|
-
"ACCESS-KEY:実際にはAPIキーが入ります",
|
94
|
-
|
95
|
-
"ACCESS-SIGNATURE:" . $strSignature,
|
96
|
-
|
97
|
-
"ACCESS-NONCE:" . $intNonce
|
98
|
-
|
99
|
-
);
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
$url = "https://coincheck.com/api/ec/buttons";
|
104
|
-
|
105
|
-
$ch = curl_init();
|
106
|
-
|
107
|
-
curl_setopt($ch, CURLOPT_URL, $url);
|
108
|
-
|
109
|
-
curl_setopt($ch,CURLOPT_POST, true);
|
110
|
-
|
111
|
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
// ヘッダー追加
|
118
|
-
|
119
|
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
// postdata追加
|
124
|
-
|
125
|
-
$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);
|
126
|
-
|
127
|
-
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
$html = curl_exec($ch);
|
134
|
-
|
135
|
-
var_dump($html);
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
curl_close($ch);
|
140
|
-
|
141
|
-
```
|
1
|
+
ありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございます
|