回答編集履歴

1

追記

2017/08/28 02:21

投稿

CHERRY
CHERRY

スコア25171

test CHANGED
@@ -11,3 +11,141 @@
11
11
 
12
12
 
13
13
  API のレスポンスは、JSON なので、[json_decode](http://php.net/manual/ja/function.json-decode.php)を使うことで、PHP の変数や配列として処理できます。
14
+
15
+
16
+
17
+
18
+
19
+ ----
20
+
21
+ (コメントを受けて追記)
22
+
23
+
24
+
25
+ APIガイド と API リファレンス のサンプルを組み合わせてみました。 (エラーチェックは入れていません。)
26
+
27
+
28
+
29
+ PHP と言うことなので、
30
+
31
+
32
+
33
+ ```
34
+
35
+ require_once 'vendor/autoload.php';
36
+
37
+ \Payjp\Payjp::setApiKey("sk_test_c62fade9d045b54cd76d7036");
38
+
39
+ $ret = \Payjp\Charge::create(array(
40
+
41
+ "card" => "tok_76e202b409f3da51a0706605ac81",
42
+
43
+ "amount" => 3500,
44
+
45
+ "currency" => "jpy"
46
+
47
+ ));
48
+
49
+ echo $ret;
50
+
51
+ ```
52
+
53
+
54
+
55
+ と実行すれば、 $ret に 以下が返ってくるのではないでしょうか?
56
+
57
+
58
+
59
+ ```
60
+
61
+ {
62
+
63
+ "amount": 3500,
64
+
65
+ "amount_refunded": 0,
66
+
67
+ "captured": true,
68
+
69
+ "captured_at": 1433127983,
70
+
71
+ "card": {
72
+
73
+ "address_city": null,
74
+
75
+ "address_line1": null,
76
+
77
+ "address_line2": null,
78
+
79
+ "address_state": null,
80
+
81
+ "address_zip": null,
82
+
83
+ "address_zip_check": "unchecked",
84
+
85
+ "brand": "Visa",
86
+
87
+ "country": null,
88
+
89
+ "created": 1433127983,
90
+
91
+ "customer": null,
92
+
93
+ "cvc_check": "unchecked",
94
+
95
+ "exp_month": 2,
96
+
97
+ "exp_year": 2020,
98
+
99
+ "fingerprint": "e1d8225886e3a7211127df751c86787f",
100
+
101
+ "id": "car_d0e44730f83b0a19ba6caee04160",
102
+
103
+ "last4": "4242",
104
+
105
+ "name": null,
106
+
107
+ "object": "card"
108
+
109
+ },
110
+
111
+ "created": 1433127983,
112
+
113
+ "currency": "jpy",
114
+
115
+ "customer": null,
116
+
117
+ "description": null,
118
+
119
+ "expired_at": null,
120
+
121
+ "failure_code": null,
122
+
123
+ "failure_message": null,
124
+
125
+ "id": "ch_fa990a4c10672a93053a774730b0a",
126
+
127
+ "livemode": false,
128
+
129
+ "metadata": null,
130
+
131
+ "object": "charge",
132
+
133
+ "paid": true,
134
+
135
+ "refund_reason": null,
136
+
137
+ "refunded": false,
138
+
139
+ "subscription": null
140
+
141
+ }
142
+
143
+ ```
144
+
145
+
146
+
147
+ $ret に対して、json_decode すれば良いと思います。
148
+
149
+
150
+
151
+