回答編集履歴
1
追記
answer
CHANGED
@@ -4,4 +4,72 @@
|
|
4
4
|
|
5
5
|
API の詳細な内容については、 [APIリファレンス](https://pay.jp/docs/api/) を参照してください。
|
6
6
|
|
7
|
-
API のレスポンスは、JSON なので、[json_decode](http://php.net/manual/ja/function.json-decode.php)を使うことで、PHP の変数や配列として処理できます。
|
7
|
+
API のレスポンスは、JSON なので、[json_decode](http://php.net/manual/ja/function.json-decode.php)を使うことで、PHP の変数や配列として処理できます。
|
8
|
+
|
9
|
+
|
10
|
+
----
|
11
|
+
(コメントを受けて追記)
|
12
|
+
|
13
|
+
APIガイド と API リファレンス のサンプルを組み合わせてみました。 (エラーチェックは入れていません。)
|
14
|
+
|
15
|
+
PHP と言うことなので、
|
16
|
+
|
17
|
+
```
|
18
|
+
require_once 'vendor/autoload.php';
|
19
|
+
\Payjp\Payjp::setApiKey("sk_test_c62fade9d045b54cd76d7036");
|
20
|
+
$ret = \Payjp\Charge::create(array(
|
21
|
+
"card" => "tok_76e202b409f3da51a0706605ac81",
|
22
|
+
"amount" => 3500,
|
23
|
+
"currency" => "jpy"
|
24
|
+
));
|
25
|
+
echo $ret;
|
26
|
+
```
|
27
|
+
|
28
|
+
と実行すれば、 $ret に 以下が返ってくるのではないでしょうか?
|
29
|
+
|
30
|
+
```
|
31
|
+
{
|
32
|
+
"amount": 3500,
|
33
|
+
"amount_refunded": 0,
|
34
|
+
"captured": true,
|
35
|
+
"captured_at": 1433127983,
|
36
|
+
"card": {
|
37
|
+
"address_city": null,
|
38
|
+
"address_line1": null,
|
39
|
+
"address_line2": null,
|
40
|
+
"address_state": null,
|
41
|
+
"address_zip": null,
|
42
|
+
"address_zip_check": "unchecked",
|
43
|
+
"brand": "Visa",
|
44
|
+
"country": null,
|
45
|
+
"created": 1433127983,
|
46
|
+
"customer": null,
|
47
|
+
"cvc_check": "unchecked",
|
48
|
+
"exp_month": 2,
|
49
|
+
"exp_year": 2020,
|
50
|
+
"fingerprint": "e1d8225886e3a7211127df751c86787f",
|
51
|
+
"id": "car_d0e44730f83b0a19ba6caee04160",
|
52
|
+
"last4": "4242",
|
53
|
+
"name": null,
|
54
|
+
"object": "card"
|
55
|
+
},
|
56
|
+
"created": 1433127983,
|
57
|
+
"currency": "jpy",
|
58
|
+
"customer": null,
|
59
|
+
"description": null,
|
60
|
+
"expired_at": null,
|
61
|
+
"failure_code": null,
|
62
|
+
"failure_message": null,
|
63
|
+
"id": "ch_fa990a4c10672a93053a774730b0a",
|
64
|
+
"livemode": false,
|
65
|
+
"metadata": null,
|
66
|
+
"object": "charge",
|
67
|
+
"paid": true,
|
68
|
+
"refund_reason": null,
|
69
|
+
"refunded": false,
|
70
|
+
"subscription": null
|
71
|
+
}
|
72
|
+
```
|
73
|
+
|
74
|
+
$ret に対して、json_decode すれば良いと思います。
|
75
|
+
|