質問編集履歴

4

質問内容削除に対する修正

2017/08/28 00:34

投稿

yuichan
yuichan

スコア13

test CHANGED
@@ -1 +1 @@
1
- ありござ
1
+ coincheckのAPIを使用して自分のECサイトで、ビットコインで決済できるよ導入した
test CHANGED
@@ -1,5 +1,141 @@
1
- ACCESS-SIGNATURE は、 ACCESS-NONCE URL リクエストのボディ を全て文字列に、連結しものを、HMAC-SHA256 hash形式でAPIキーのシークレットキーを使って署名した結果です。
1
+ ###前提・実現したいこと
2
2
 
3
3
 
4
4
 
5
- ありござます、目から鱗です◝₍ᴑ̑ДO͝₎◞
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

ありがとうございます

2017/08/28 00:34

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
 
4
4
 
5
- ありがとうございます、目から鱗です
5
+ ありがとうございます、目から鱗です◝₍ᴑ̑ДO͝₎◞

2

ありがとうございます

2017/08/27 16:41

投稿

yuichan
yuichan

スコア13

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

                         

2017/08/27 16:37

投稿

yuichan
yuichan

スコア13

test CHANGED
@@ -1 +1 @@
1
- coincheckのAPIを使用して自分のECサイトで、ビットコインで決済できるよ導入した
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
+ ありがとうござますありがうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございますありがとうございます