webpay 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/webpay.rb +1 -0
- data/lib/webpay/fee.rb +13 -0
- data/lib/webpay/response_converter.rb +5 -0
- data/lib/webpay/version.rb +1 -1
- data/spec/resources/charges/all.txt +78 -41
- data/spec/resources/charges/capture.txt +29 -21
- data/spec/resources/charges/create_with_card.txt +26 -18
- data/spec/resources/charges/create_with_customer.txt +29 -21
- data/spec/resources/charges/refund.txt +39 -23
- data/spec/resources/charges/retrieve.txt +30 -20
- data/spec/resources/charges/retrieve_not_captured.txt +22 -19
- data/spec/webpay/charge_spec.rb +45 -17
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c927ca24f603b3b182f7001148cb32839dbda14e
|
4
|
+
data.tar.gz: 063d18639d6a65db61d86d4e70fbb09b746d580c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16cc7aaed7e03c44ea73b601c034609d7736e03b2b6688310cef13176211d319cd443a249130b6ac9e6bfc7f9048c8c6623a1af6e6a256d302844049e09002ba
|
7
|
+
data.tar.gz: a9d269f913a2ddd4082ce5538234aa0852b4bc23818979494ec57d251d8e2af89cba558d347dbd1cff895f05de98ec0797f9e6375e70ee2528840b165d0dc11b
|
data/.travis.yml
CHANGED
data/lib/webpay.rb
CHANGED
@@ -19,6 +19,7 @@ module WebPay
|
|
19
19
|
autoload(:Charge, 'webpay/charge')
|
20
20
|
autoload(:Customer, 'webpay/customer')
|
21
21
|
autoload(:Event, 'webpay/event')
|
22
|
+
autoload(:Fee, 'webpay/fee')
|
22
23
|
autoload(:Token, 'webpay/token')
|
23
24
|
autoload(:Shop, 'webpay/shop')
|
24
25
|
autoload(:ResponseConverter, 'webpay/response_converter')
|
data/lib/webpay/fee.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module WebPay
|
2
|
+
|
3
|
+
# Object for API response hash object with <code>hash['object'] = fee</code>.
|
4
|
+
# Fee is not accessible as an API endpoint
|
5
|
+
class Fee < Entity
|
6
|
+
|
7
|
+
# Check equality with rhs
|
8
|
+
# @return [Boolean] true only if rhs is the same object
|
9
|
+
def ==(other)
|
10
|
+
self.equal?(other)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -11,10 +11,15 @@ module WebPay
|
|
11
11
|
case attributes['object']
|
12
12
|
when 'card'
|
13
13
|
Card.new(attributes)
|
14
|
+
when 'fee'
|
15
|
+
Fee.new(attributes)
|
14
16
|
when 'charge'
|
15
17
|
if attributes['card']
|
16
18
|
attributes['card'] = convert(attributes['card'])
|
17
19
|
end
|
20
|
+
if attributes['fees']
|
21
|
+
attributes['fees'] = attributes['fees'].map { |fee| convert(fee) }
|
22
|
+
end
|
18
23
|
Charge.new(attributes)
|
19
24
|
when 'customer'
|
20
25
|
if attributes['active_card']
|
data/lib/webpay/version.rb
CHANGED
@@ -1,39 +1,37 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
X-Rack-Cache: miss
|
14
|
-
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "d62affbd4db0c10ce2244cc7d5a05249"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: c53aade07e31b8c4cc03c18bfe5ee086
|
7
|
+
X-Runtime: 0.013481
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Mon, 14 Apr 2014 02:43:46 GMT
|
10
|
+
Content-Length: 3067
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
15
13
|
{
|
16
14
|
"object": "list",
|
17
15
|
"url": "/v1/charges",
|
18
|
-
"count":
|
16
|
+
"count": 4,
|
19
17
|
"data": [
|
20
18
|
{
|
21
|
-
"id": "
|
19
|
+
"id": "ch_511apkasx749bfE",
|
22
20
|
"object": "charge",
|
23
21
|
"livemode": false,
|
24
22
|
"currency": "jpy",
|
25
|
-
"description": "Test Charge
|
23
|
+
"description": "Test Charge",
|
26
24
|
"amount": 1000,
|
27
25
|
"amount_refunded": 0,
|
28
|
-
"customer": "
|
29
|
-
"created":
|
30
|
-
"paid":
|
26
|
+
"customer": "cus_5119ShaAgbLyfwS",
|
27
|
+
"created": 1397443228,
|
28
|
+
"paid": false,
|
31
29
|
"refunded": false,
|
32
30
|
"failure_message": null,
|
33
31
|
"card": {
|
34
32
|
"object": "card",
|
35
|
-
"exp_year":
|
36
|
-
"exp_month":
|
33
|
+
"exp_year": 2016,
|
34
|
+
"exp_month": 9,
|
37
35
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
38
36
|
"name": "KEI KUBO",
|
39
37
|
"country": "JP",
|
@@ -41,62 +39,101 @@ X-Rack-Cache: miss
|
|
41
39
|
"cvc_check": "pass",
|
42
40
|
"last4": "4242"
|
43
41
|
},
|
44
|
-
"captured":
|
45
|
-
"expire_time":
|
42
|
+
"captured": false,
|
43
|
+
"expire_time": 1398048028,
|
44
|
+
"fees": [
|
45
|
+
|
46
|
+
]
|
46
47
|
},
|
47
48
|
{
|
48
|
-
"id": "
|
49
|
+
"id": "ch_5119xE4mH4zA9p9",
|
49
50
|
"object": "charge",
|
50
51
|
"livemode": false,
|
51
52
|
"currency": "jpy",
|
52
|
-
"description": "Test Charge
|
53
|
+
"description": "Test Charge",
|
53
54
|
"amount": 1000,
|
54
55
|
"amount_refunded": 0,
|
55
|
-
"customer":
|
56
|
-
"created":
|
56
|
+
"customer": "cus_5119ShaAgbLyfwS",
|
57
|
+
"created": 1397443215,
|
57
58
|
"paid": true,
|
58
59
|
"refunded": false,
|
59
60
|
"failure_message": null,
|
60
61
|
"card": {
|
61
62
|
"object": "card",
|
62
|
-
"exp_year":
|
63
|
-
"exp_month":
|
63
|
+
"exp_year": 2016,
|
64
|
+
"exp_month": 9,
|
64
65
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
65
|
-
"name": "
|
66
|
+
"name": "KEI KUBO",
|
66
67
|
"country": "JP",
|
67
68
|
"type": "Visa",
|
68
69
|
"cvc_check": "pass",
|
69
70
|
"last4": "4242"
|
70
71
|
},
|
71
72
|
"captured": true,
|
72
|
-
"expire_time": null
|
73
|
+
"expire_time": null,
|
74
|
+
"fees": [
|
75
|
+
{
|
76
|
+
"object": "fee",
|
77
|
+
"transaction_type": "payment",
|
78
|
+
"transaction_fee": 0,
|
79
|
+
"rate": 35.0,
|
80
|
+
"amount": 350,
|
81
|
+
"created": 1397443216
|
82
|
+
}
|
83
|
+
]
|
73
84
|
},
|
74
85
|
{
|
75
|
-
"id": "
|
86
|
+
"id": "ch_5112dr0Mu5Kyd2I",
|
76
87
|
"object": "charge",
|
77
88
|
"livemode": false,
|
78
89
|
"currency": "jpy",
|
79
|
-
"description": "Test Charge
|
90
|
+
"description": "Test Charge",
|
80
91
|
"amount": 1000,
|
81
|
-
"amount_refunded":
|
82
|
-
"customer":
|
83
|
-
"created":
|
92
|
+
"amount_refunded": 400,
|
93
|
+
"customer": null,
|
94
|
+
"created": 1397442849,
|
84
95
|
"paid": true,
|
85
96
|
"refunded": false,
|
86
97
|
"failure_message": null,
|
87
98
|
"card": {
|
88
99
|
"object": "card",
|
89
|
-
"exp_year":
|
90
|
-
"exp_month":
|
100
|
+
"exp_year": 2015,
|
101
|
+
"exp_month": 12,
|
91
102
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
92
|
-
"name": "
|
103
|
+
"name": "YUUKO SHIONJI",
|
93
104
|
"country": "JP",
|
94
105
|
"type": "Visa",
|
95
106
|
"cvc_check": "pass",
|
96
107
|
"last4": "4242"
|
97
108
|
},
|
98
109
|
"captured": true,
|
99
|
-
"expire_time": null
|
110
|
+
"expire_time": null,
|
111
|
+
"fees": [
|
112
|
+
{
|
113
|
+
"object": "fee",
|
114
|
+
"transaction_type": "payment",
|
115
|
+
"transaction_fee": 0,
|
116
|
+
"rate": 35.0,
|
117
|
+
"amount": 350,
|
118
|
+
"created": 1397442849
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"object": "fee",
|
122
|
+
"transaction_type": "refund",
|
123
|
+
"transaction_fee": 0,
|
124
|
+
"rate": 35.0,
|
125
|
+
"amount": -350,
|
126
|
+
"created": 1397443154
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"object": "fee",
|
130
|
+
"transaction_type": "payment",
|
131
|
+
"transaction_fee": 0,
|
132
|
+
"rate": 35.0,
|
133
|
+
"amount": 210,
|
134
|
+
"created": 1397443154
|
135
|
+
}
|
136
|
+
]
|
100
137
|
}
|
101
138
|
]
|
102
139
|
}
|
@@ -1,34 +1,32 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
X-Rack-Cache: invalidate, pass
|
14
|
-
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "55751ab0623ce3649f648ce9161a340e"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: e57b763f56b9212d2aac3d5204303b59
|
7
|
+
X-Runtime: 0.471463
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Mon, 14 Apr 2014 02:58:16 GMT
|
10
|
+
Content-Length: 785
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
15
13
|
{
|
16
|
-
"id": "
|
14
|
+
"id": "ch_5113hA4L51yj8TF",
|
17
15
|
"object": "charge",
|
18
16
|
"livemode": false,
|
19
17
|
"currency": "jpy",
|
20
|
-
"description": "Test Charge
|
18
|
+
"description": "Test Charge",
|
21
19
|
"amount": 1000,
|
22
20
|
"amount_refunded": 0,
|
23
|
-
"customer": "
|
24
|
-
"created":
|
21
|
+
"customer": "cus_5119ShaAgbLyfwS",
|
22
|
+
"created": 1397444145,
|
25
23
|
"paid": true,
|
26
24
|
"refunded": false,
|
27
25
|
"failure_message": null,
|
28
26
|
"card": {
|
29
27
|
"object": "card",
|
30
|
-
"exp_year":
|
31
|
-
"exp_month":
|
28
|
+
"exp_year": 2016,
|
29
|
+
"exp_month": 9,
|
32
30
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
33
31
|
"name": "KEI KUBO",
|
34
32
|
"country": "JP",
|
@@ -37,5 +35,15 @@ X-Rack-Cache: invalidate, pass
|
|
37
35
|
"last4": "4242"
|
38
36
|
},
|
39
37
|
"captured": true,
|
40
|
-
"expire_time":
|
38
|
+
"expire_time": 1398048945,
|
39
|
+
"fees": [
|
40
|
+
{
|
41
|
+
"object": "fee",
|
42
|
+
"transaction_type": "payment",
|
43
|
+
"transaction_fee": 0,
|
44
|
+
"rate": 3.25,
|
45
|
+
"amount": 33,
|
46
|
+
"created": 1397444296
|
47
|
+
}
|
48
|
+
]
|
41
49
|
}
|
@@ -1,27 +1,25 @@
|
|
1
|
-
HTTP/1.1 201 Created
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
X-Rack-Cache: invalidate, pass
|
14
|
-
|
1
|
+
HTTP/1.1 201 Created
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "52660afa817770efa680c8d997b48917"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: ddf1900c75deac499d2ca9f3cccf59ff
|
7
|
+
X-Runtime: 0.982683
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Mon, 14 Apr 2014 02:55:29 GMT
|
10
|
+
Content-Length: 768
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
15
13
|
{
|
16
|
-
"id": "
|
14
|
+
"id": "ch_5112dw9eYekJc2s",
|
17
15
|
"object": "charge",
|
18
16
|
"livemode": false,
|
19
17
|
"currency": "jpy",
|
20
|
-
"description": "Test Charge
|
18
|
+
"description": "Test Charge",
|
21
19
|
"amount": 1000,
|
22
20
|
"amount_refunded": 0,
|
23
21
|
"customer": null,
|
24
|
-
"created":
|
22
|
+
"created": 1397444129,
|
25
23
|
"paid": true,
|
26
24
|
"refunded": false,
|
27
25
|
"failure_message": null,
|
@@ -37,5 +35,15 @@ X-Rack-Cache: invalidate, pass
|
|
37
35
|
"last4": "4242"
|
38
36
|
},
|
39
37
|
"captured": true,
|
40
|
-
"expire_time": null
|
38
|
+
"expire_time": null,
|
39
|
+
"fees": [
|
40
|
+
{
|
41
|
+
"object": "fee",
|
42
|
+
"transaction_type": "payment",
|
43
|
+
"transaction_fee": 0,
|
44
|
+
"rate": 3.25,
|
45
|
+
"amount": 33,
|
46
|
+
"created": 1397444129
|
47
|
+
}
|
48
|
+
]
|
41
49
|
}
|
@@ -1,34 +1,32 @@
|
|
1
|
-
HTTP/1.1 201 Created
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
X-Rack-Cache: invalidate, pass
|
14
|
-
|
1
|
+
HTTP/1.1 201 Created
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "97bd4ad52cf1430cc212a9f6140a4b27"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: b323af770f1e1a78cd752ef0ae740e63
|
7
|
+
X-Runtime: 0.520140
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Mon, 14 Apr 2014 02:55:38 GMT
|
10
|
+
Content-Length: 779
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
15
13
|
{
|
16
|
-
"id": "
|
14
|
+
"id": "ch_5112KydVn9zId7h",
|
17
15
|
"object": "charge",
|
18
16
|
"livemode": false,
|
19
17
|
"currency": "jpy",
|
20
|
-
"description": "Test Charge
|
18
|
+
"description": "Test Charge",
|
21
19
|
"amount": 1000,
|
22
20
|
"amount_refunded": 0,
|
23
|
-
"customer": "
|
24
|
-
"created":
|
21
|
+
"customer": "cus_5119ShaAgbLyfwS",
|
22
|
+
"created": 1397444137,
|
25
23
|
"paid": true,
|
26
24
|
"refunded": false,
|
27
25
|
"failure_message": null,
|
28
26
|
"card": {
|
29
27
|
"object": "card",
|
30
|
-
"exp_year":
|
31
|
-
"exp_month":
|
28
|
+
"exp_year": 2016,
|
29
|
+
"exp_month": 9,
|
32
30
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
33
31
|
"name": "KEI KUBO",
|
34
32
|
"country": "JP",
|
@@ -37,5 +35,15 @@ X-Rack-Cache: invalidate, pass
|
|
37
35
|
"last4": "4242"
|
38
36
|
},
|
39
37
|
"captured": true,
|
40
|
-
"expire_time": null
|
38
|
+
"expire_time": null,
|
39
|
+
"fees": [
|
40
|
+
{
|
41
|
+
"object": "fee",
|
42
|
+
"transaction_type": "payment",
|
43
|
+
"transaction_fee": 0,
|
44
|
+
"rate": 3.25,
|
45
|
+
"amount": 33,
|
46
|
+
"created": 1397444138
|
47
|
+
}
|
48
|
+
]
|
41
49
|
}
|
@@ -1,41 +1,57 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
X-Rack-Cache: invalidate, pass
|
14
|
-
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "e262bc8c1785cab71c0e09f7024ce701"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: 9f963b799441465fd3ea03be0316807e
|
7
|
+
X-Runtime: 0.398660
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Mon, 14 Apr 2014 03:02:07 GMT
|
10
|
+
Content-Length: 939
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
15
13
|
{
|
16
|
-
"id": "
|
14
|
+
"id": "ch_5112dw9eYekJc2s",
|
17
15
|
"object": "charge",
|
18
16
|
"livemode": false,
|
19
17
|
"currency": "jpy",
|
20
|
-
"description": "
|
21
|
-
"amount":
|
22
|
-
"amount_refunded":
|
18
|
+
"description": "Test Charge",
|
19
|
+
"amount": 1000,
|
20
|
+
"amount_refunded": 1000,
|
23
21
|
"customer": null,
|
24
|
-
"created":
|
22
|
+
"created": 1397444129,
|
25
23
|
"paid": true,
|
26
24
|
"refunded": true,
|
27
25
|
"failure_message": null,
|
28
26
|
"card": {
|
29
27
|
"object": "card",
|
30
|
-
"exp_year":
|
31
|
-
"exp_month":
|
28
|
+
"exp_year": 2015,
|
29
|
+
"exp_month": 12,
|
32
30
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
33
|
-
"name": "
|
31
|
+
"name": "YUUKO SHIONJI",
|
34
32
|
"country": "JP",
|
35
33
|
"type": "Visa",
|
36
34
|
"cvc_check": "pass",
|
37
35
|
"last4": "4242"
|
38
36
|
},
|
39
37
|
"captured": true,
|
40
|
-
"expire_time": null
|
38
|
+
"expire_time": null,
|
39
|
+
"fees": [
|
40
|
+
{
|
41
|
+
"object": "fee",
|
42
|
+
"transaction_type": "payment",
|
43
|
+
"transaction_fee": 0,
|
44
|
+
"rate": 3.25,
|
45
|
+
"amount": 33,
|
46
|
+
"created": 1397444129
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"object": "fee",
|
50
|
+
"transaction_type": "refund",
|
51
|
+
"transaction_fee": 0,
|
52
|
+
"rate": 3.25,
|
53
|
+
"amount": -33,
|
54
|
+
"created": 1397444526
|
55
|
+
}
|
56
|
+
]
|
41
57
|
}
|
@@ -1,39 +1,49 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "52660afa817770efa680c8d997b48917"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: 6e1d1e5bdb97b2ac07444e19d1c9e925
|
7
|
+
X-Runtime: 0.008128
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Mon, 14 Apr 2014 02:56:31 GMT
|
10
|
+
Content-Length: 768
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
13
13
|
{
|
14
|
-
"id": "
|
14
|
+
"id": "ch_5112dw9eYekJc2s",
|
15
15
|
"object": "charge",
|
16
16
|
"livemode": false,
|
17
17
|
"currency": "jpy",
|
18
|
-
"description": "
|
19
|
-
"amount":
|
18
|
+
"description": "Test Charge",
|
19
|
+
"amount": 1000,
|
20
20
|
"amount_refunded": 0,
|
21
21
|
"customer": null,
|
22
|
-
"created":
|
22
|
+
"created": 1397444129,
|
23
23
|
"paid": true,
|
24
24
|
"refunded": false,
|
25
25
|
"failure_message": null,
|
26
26
|
"card": {
|
27
27
|
"object": "card",
|
28
|
-
"exp_year":
|
29
|
-
"exp_month":
|
28
|
+
"exp_year": 2015,
|
29
|
+
"exp_month": 12,
|
30
30
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
31
|
-
"name": "
|
31
|
+
"name": "YUUKO SHIONJI",
|
32
32
|
"country": "JP",
|
33
33
|
"type": "Visa",
|
34
34
|
"cvc_check": "pass",
|
35
35
|
"last4": "4242"
|
36
36
|
},
|
37
37
|
"captured": true,
|
38
|
-
"expire_time": null
|
38
|
+
"expire_time": null,
|
39
|
+
"fees": [
|
40
|
+
{
|
41
|
+
"object": "fee",
|
42
|
+
"transaction_type": "payment",
|
43
|
+
"transaction_fee": 0,
|
44
|
+
"rate": 3.25,
|
45
|
+
"amount": 33,
|
46
|
+
"created": 1397444129
|
47
|
+
}
|
48
|
+
]
|
39
49
|
}
|
@@ -1,32 +1,32 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: application/json; charset=utf-8
|
3
|
+
X-Ua-Compatible: IE=Edge
|
4
|
+
Etag: "d286a0c9eaed0e25df2731346066053f"
|
5
|
+
Cache-Control: max-age=0, private, must-revalidate
|
6
|
+
X-Request-Id: ebb723c852a35579c8f44cc6c91b8a86
|
7
|
+
X-Runtime: 0.009551
|
8
|
+
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
+
Date: Mon, 14 Apr 2014 02:56:09 GMT
|
10
|
+
Content-Length: 620
|
11
|
+
Connection: Keep-Alive
|
12
|
+
|
13
13
|
{
|
14
|
-
"id": "
|
14
|
+
"id": "ch_5113hA4L51yj8TF",
|
15
15
|
"object": "charge",
|
16
16
|
"livemode": false,
|
17
17
|
"currency": "jpy",
|
18
|
-
"description": "Test Charge
|
18
|
+
"description": "Test Charge",
|
19
19
|
"amount": 1000,
|
20
20
|
"amount_refunded": 0,
|
21
|
-
"customer": "
|
22
|
-
"created":
|
21
|
+
"customer": "cus_5119ShaAgbLyfwS",
|
22
|
+
"created": 1397444145,
|
23
23
|
"paid": false,
|
24
24
|
"refunded": false,
|
25
25
|
"failure_message": null,
|
26
26
|
"card": {
|
27
27
|
"object": "card",
|
28
|
-
"exp_year":
|
29
|
-
"exp_month":
|
28
|
+
"exp_year": 2016,
|
29
|
+
"exp_month": 9,
|
30
30
|
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
31
31
|
"name": "KEI KUBO",
|
32
32
|
"country": "JP",
|
@@ -35,5 +35,8 @@ X-Request-Id: 8ea33d9a3dc18348206d68f2408c7866
|
|
35
35
|
"last4": "4242"
|
36
36
|
},
|
37
37
|
"captured": false,
|
38
|
-
"expire_time":
|
38
|
+
"expire_time": 1398048945,
|
39
|
+
"fees": [
|
40
|
+
|
41
|
+
]
|
39
42
|
}
|
data/spec/webpay/charge_spec.rb
CHANGED
@@ -13,31 +13,41 @@ describe WebPay::Charge do
|
|
13
13
|
:exp_year=>'2015',
|
14
14
|
:cvc=>'123',
|
15
15
|
:name=>'YUUKO SHIONJI'},
|
16
|
-
:description=>'Test Charge
|
16
|
+
:description=>'Test Charge'
|
17
17
|
}}
|
18
18
|
before do
|
19
19
|
stub_post_request('/charges', 'charges/create_with_card', params)
|
20
20
|
end
|
21
21
|
|
22
|
-
its(:id) { should eq '
|
23
|
-
its(:description) { should eq "Test Charge
|
22
|
+
its(:id) { should eq 'ch_5112dw9eYekJc2s' }
|
23
|
+
its(:description) { should eq "Test Charge" }
|
24
24
|
it 'card.name' do
|
25
25
|
expect(charge.card.name).to eq 'YUUKO SHIONJI'
|
26
26
|
end
|
27
|
+
|
28
|
+
it 'fees' do
|
29
|
+
expect(charge.fees.length).to eq 1
|
30
|
+
fee = charge.fees[0]
|
31
|
+
expect(fee.transaction_type).to eq 'payment'
|
32
|
+
expect(fee.transaction_fee).to eq 0
|
33
|
+
expect(fee.rate).to eq 3.25
|
34
|
+
expect(fee.amount).to eq 33
|
35
|
+
expect(fee.created).to eq 1397444129
|
36
|
+
end
|
27
37
|
end
|
28
38
|
|
29
39
|
describe 'with customer' do
|
30
40
|
let(:params) {{
|
31
41
|
:amount=>'1000',
|
32
42
|
:currency=>'jpy',
|
33
|
-
:customer => '
|
34
|
-
:description=>'Test Charge
|
43
|
+
:customer => 'cus_5119ShaAgbLyfwS',
|
44
|
+
:description=>'Test Charge'
|
35
45
|
}}
|
36
46
|
before do
|
37
47
|
stub_post_request('/charges', 'charges/create_with_customer', params)
|
38
48
|
end
|
39
49
|
|
40
|
-
its(:id) { should eq '
|
50
|
+
its(:id) { should eq 'ch_5112KydVn9zId7h' }
|
41
51
|
it 'card.name' do
|
42
52
|
expect(charge.card.name).to eq 'KEI KUBO'
|
43
53
|
end
|
@@ -45,7 +55,7 @@ describe WebPay::Charge do
|
|
45
55
|
end
|
46
56
|
|
47
57
|
describe '.retrieve' do
|
48
|
-
let(:id) { '
|
58
|
+
let(:id) { 'ch_5112dw9eYekJc2s' }
|
49
59
|
before do
|
50
60
|
stub_get_request("/charges/#{id}", 'charges/retrieve')
|
51
61
|
end
|
@@ -60,46 +70,62 @@ describe WebPay::Charge do
|
|
60
70
|
describe '.all' do
|
61
71
|
context 'with craeted[gt]' do
|
62
72
|
before do
|
63
|
-
stub_get_request("/charges?count=3&offset=0&created[gt]=
|
73
|
+
stub_get_request("/charges?count=3&offset=0&created[gt]=1397401200", 'charges/all')
|
64
74
|
end
|
65
75
|
|
66
|
-
subject(:list) { described_class.all(count: 3, offset: 0, created: { gt:
|
76
|
+
subject(:list) { described_class.all(count: 3, offset: 0, created: { gt: 1397401200 }) }
|
67
77
|
its(:url) { should eq '/v1/charges' }
|
68
|
-
its(:count) { should eq
|
78
|
+
its(:count) { should eq 4 }
|
69
79
|
it 'data.first.description' do
|
70
|
-
expect(list.data.first.description).to eq 'Test Charge
|
80
|
+
expect(list.data.first.description).to eq 'Test Charge'
|
71
81
|
end
|
72
82
|
end
|
73
83
|
|
74
84
|
context 'with customer' do
|
75
85
|
before do
|
76
|
-
stub_get_request("/charges?customer=
|
86
|
+
stub_get_request("/charges?customer=cus_5119ShaAgbLyfwS", 'charges/all')
|
77
87
|
end
|
78
88
|
|
79
89
|
it 'should respond the list' do
|
80
|
-
list = described_class.all(customer: '
|
90
|
+
list = described_class.all(customer: 'cus_5119ShaAgbLyfwS')
|
81
91
|
expect(list.url).to eq '/v1/charges'
|
82
92
|
end
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
86
96
|
describe '#refund' do
|
87
|
-
let(:id) { '
|
97
|
+
let(:id) { 'ch_5112dw9eYekJc2s' }
|
98
|
+
|
88
99
|
before do
|
89
100
|
stub_get_request("/charges/#{id}", 'charges/retrieve')
|
90
|
-
stub_post_request("/charges/#{id}/refund", 'charges/refund', amount: '
|
101
|
+
stub_post_request("/charges/#{id}/refund", 'charges/refund', amount: '1000')
|
91
102
|
end
|
92
103
|
|
93
104
|
it 'should refund the retrieved charge' do
|
94
105
|
charge = described_class.retrieve(id)
|
95
106
|
expect(charge.refunded).to eq false
|
96
|
-
charge.refund(amount:
|
107
|
+
charge.refund(amount: 1000)
|
97
108
|
expect(charge.refunded).to eq true
|
109
|
+
expect(charge.amount_refunded).to eq 1000
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should add refund fees' do
|
113
|
+
charge = described_class.retrieve(id)
|
114
|
+
expect(charge.refunded).to eq false
|
115
|
+
charge.refund(amount: 1000)
|
116
|
+
|
117
|
+
expect(charge.fees.length).to eq 2
|
118
|
+
fee = charge.fees[1]
|
119
|
+
expect(fee.transaction_type).to eq 'refund'
|
120
|
+
expect(fee.transaction_fee).to eq 0
|
121
|
+
expect(fee.rate).to eq 3.25
|
122
|
+
expect(fee.amount).to eq -33
|
123
|
+
expect(fee.created).to eq 1397444526
|
98
124
|
end
|
99
125
|
end
|
100
126
|
|
101
127
|
describe '#capture' do
|
102
|
-
let(:id) { '
|
128
|
+
let(:id) { 'ch_5113hA4L51yj8TF' }
|
103
129
|
before do
|
104
130
|
stub_get_request("/charges/#{id}", 'charges/retrieve_not_captured')
|
105
131
|
stub_post_request("/charges/#{id}/capture", 'charges/capture', amount: '1000')
|
@@ -108,8 +134,10 @@ describe WebPay::Charge do
|
|
108
134
|
it 'should capture the retrieved charge' do
|
109
135
|
charge = described_class.retrieve(id)
|
110
136
|
expect(charge.captured).to eq false
|
137
|
+
expect(charge.fees.length).to eq 0
|
111
138
|
charge.capture(amount: 1000)
|
112
139
|
expect(charge.captured).to eq true
|
140
|
+
expect(charge.fees.length).to eq 1
|
113
141
|
end
|
114
142
|
end
|
115
143
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- webpay
|
@@ -9,104 +9,104 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0.8'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0.8'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.3'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1.3'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: yard
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - ~>
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 0.8.6.2
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - ~>
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 0.8.6.2
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: redcarpet
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 3.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 3.0.0
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rspec
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - ~>
|
88
|
+
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 2.14.0
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - ~>
|
95
|
+
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: 2.14.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: webmock
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - ~>
|
102
|
+
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: 1.13.0
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - ~>
|
109
|
+
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: 1.13.0
|
112
112
|
description: WebPay is payment gateway service in Japan. see also https://webpay.jp/
|
@@ -117,9 +117,9 @@ executables: []
|
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
|
-
- .gitignore
|
121
|
-
- .rspec
|
122
|
-
- .travis.yml
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".travis.yml"
|
123
123
|
- Gemfile
|
124
124
|
- LICENSE.txt
|
125
125
|
- README.md
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/webpay/entity.rb
|
137
137
|
- lib/webpay/entity_list.rb
|
138
138
|
- lib/webpay/event.rb
|
139
|
+
- lib/webpay/fee.rb
|
139
140
|
- lib/webpay/operations.rb
|
140
141
|
- lib/webpay/response_converter.rb
|
141
142
|
- lib/webpay/shop.rb
|
@@ -192,17 +193,17 @@ require_paths:
|
|
192
193
|
- lib
|
193
194
|
required_ruby_version: !ruby/object:Gem::Requirement
|
194
195
|
requirements:
|
195
|
-
- -
|
196
|
+
- - ">="
|
196
197
|
- !ruby/object:Gem::Version
|
197
198
|
version: '0'
|
198
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
200
|
requirements:
|
200
|
-
- -
|
201
|
+
- - ">="
|
201
202
|
- !ruby/object:Gem::Version
|
202
203
|
version: '0'
|
203
204
|
requirements: []
|
204
205
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.0
|
206
|
+
rubygems_version: 2.2.0
|
206
207
|
signing_key:
|
207
208
|
specification_version: 4
|
208
209
|
summary: Ruby bindings of WebPay API
|
@@ -246,3 +247,4 @@ test_files:
|
|
246
247
|
- spec/webpay/token_spec.rb
|
247
248
|
- spec/webpay/webpay_error_spec.rb
|
248
249
|
- spec/webpay_spec.rb
|
250
|
+
has_rdoc:
|