judopay 1.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rspec +2 -0
- data/.rubocop.yml +47 -0
- data/.yardopts +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +7 -0
- data/judopay.gemspec +37 -0
- data/lib/certs/rapidssl_ca.crt +64 -0
- data/lib/faraday/judo_mashify.rb +13 -0
- data/lib/faraday/raise_http_exception.rb +36 -0
- data/lib/judopay.rb +67 -0
- data/lib/judopay/api.rb +10 -0
- data/lib/judopay/connection.rb +67 -0
- data/lib/judopay/core_ext/hash.rb +29 -0
- data/lib/judopay/core_ext/string.rb +31 -0
- data/lib/judopay/error.rb +153 -0
- data/lib/judopay/mash.rb +7 -0
- data/lib/judopay/model.rb +109 -0
- data/lib/judopay/models/card_address.rb +11 -0
- data/lib/judopay/models/card_payment.rb +39 -0
- data/lib/judopay/models/card_preauth.rb +12 -0
- data/lib/judopay/models/collection.rb +16 -0
- data/lib/judopay/models/consumer_location.rb +8 -0
- data/lib/judopay/models/market/collection.rb +10 -0
- data/lib/judopay/models/market/payment.rb +10 -0
- data/lib/judopay/models/market/preauth.rb +10 -0
- data/lib/judopay/models/market/refund.rb +10 -0
- data/lib/judopay/models/market/transaction.rb +10 -0
- data/lib/judopay/models/payment.rb +8 -0
- data/lib/judopay/models/preauth.rb +8 -0
- data/lib/judopay/models/refund.rb +16 -0
- data/lib/judopay/models/token_payment.rb +30 -0
- data/lib/judopay/models/token_preauth.rb +10 -0
- data/lib/judopay/models/transaction.rb +8 -0
- data/lib/judopay/models/web_payments/payment.rb +24 -0
- data/lib/judopay/models/web_payments/preauth.rb +10 -0
- data/lib/judopay/models/web_payments/transaction.rb +19 -0
- data/lib/judopay/null_logger.rb +11 -0
- data/lib/judopay/request.rb +50 -0
- data/lib/judopay/response.rb +7 -0
- data/lib/judopay/serializer.rb +31 -0
- data/lib/judopay/version.rb +3 -0
- data/spec/factories.rb +103 -0
- data/spec/faraday/response_spec.rb +29 -0
- data/spec/fixtures/card_payments/create.json +22 -0
- data/spec/fixtures/card_payments/create_3dsecure.json +8 -0
- data/spec/fixtures/card_payments/create_bad_request.json +5 -0
- data/spec/fixtures/card_payments/create_declined.json +24 -0
- data/spec/fixtures/card_payments/validate.json +5 -0
- data/spec/fixtures/token_payments/create.json +22 -0
- data/spec/fixtures/transactions/all.json +238 -0
- data/spec/fixtures/transactions/find.json +23 -0
- data/spec/fixtures/transactions/find_not_found.json +5 -0
- data/spec/fixtures/web_payments/payments/create.json +4 -0
- data/spec/fixtures/web_payments/payments/find.json +39 -0
- data/spec/judopay/card_address_spec.rb +10 -0
- data/spec/judopay/card_payment_spec.rb +64 -0
- data/spec/judopay/card_preauth_spec.rb +35 -0
- data/spec/judopay/collection_spec.rb +26 -0
- data/spec/judopay/core_ext/hash_spec.rb +24 -0
- data/spec/judopay/core_ext/string_spec.rb +16 -0
- data/spec/judopay/error_spec.rb +49 -0
- data/spec/judopay/judopay_spec.rb +19 -0
- data/spec/judopay/market/collection_spec.rb +26 -0
- data/spec/judopay/market/payment_spec.rb +14 -0
- data/spec/judopay/market/preauth_spec.rb +14 -0
- data/spec/judopay/market/refund_spec.rb +26 -0
- data/spec/judopay/market/transaction_spec.rb +14 -0
- data/spec/judopay/payment_spec.rb +14 -0
- data/spec/judopay/preauth_spec.rb +14 -0
- data/spec/judopay/refund_spec.rb +26 -0
- data/spec/judopay/token_payment_spec.rb +22 -0
- data/spec/judopay/token_preauth_spec.rb +22 -0
- data/spec/judopay/transaction_spec.rb +51 -0
- data/spec/judopay/web_payments/payment_spec.rb +16 -0
- data/spec/judopay/web_payments/preauth_spec.rb +16 -0
- data/spec/judopay/web_payments/transaction_spec.rb +15 -0
- data/spec/spec_helper.rb +37 -0
- data/tutorials/judo_getting_started.md +74 -0
- data/tutorials/judo_making_a_payment.md +84 -0
- metadata +373 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
{
|
2
|
+
"receiptId": "61382",
|
3
|
+
"result": "Requires 3D Secure",
|
4
|
+
"message": "Issuer authentication required",
|
5
|
+
"acsUrl": "https://gw1.paymentsensegateway.com:4430/ACS/Default.aspx",
|
6
|
+
"md": "140618100412780501505009",
|
7
|
+
"paReq": "eJxVUtuO2jAQfa/Uf7DyTOJLLiTR4BXdqCpVQyllH/pobC+kIgnrJAX+vjYBtpX8MHPGczlzBp7O9QH90aar2mbm0YB4SDeyVVWzm3kvm89+6j3xjx9gszdaFz+1HIzmUOquEzuNKjXzVvO1fstCFqZhmDLicbgiHG5VuS0aMMB31yYbuRdNz0HIt0+LJacsjOJkmgK+AVBrsygeeAZ4BKARteZfB9Wio7jUuuk7BPgKgmyHpjcXnrIE8N2BwRz4vu+POcan0yn4bVNtZiDbGrCLAX6fZjU4q7O1zpXiy2LBlpt5XG5+xd+LH+fS2cXuUhYvM8DuByjRa84IjUhCU0RpTqKcWqZXHETthuCUkCCMLLXRhaPrMn/EXOhfCOyCjVXgTuTugT4f28Yy5rbBwwalO8lXwvSNNmstFyqnE/TcNqPNMpJNUNluq4Ne69dcTV+tSFHiKxkmfmQV89MtY/42zKgUdJopkc2l/NbKMT+aILdsV5UQQpMJUhe77UoWtq3JXcyydSMAft/e8xenrOytYEkc2UfDJCZO3CvmmFRWGxrTkYpzALssfLscfLsva/13d38BsjHbeQ=="
|
8
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"receiptId": "444224",
|
3
|
+
"type": "Payment",
|
4
|
+
"createdAt": "2014-06-19T16:26:15.6420+01:00",
|
5
|
+
"result": "Declined",
|
6
|
+
"message": "Card declined",
|
7
|
+
"judoId": 100016,
|
8
|
+
"merchantName": "Judo Pay test",
|
9
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
10
|
+
"originalAmount": 1.01,
|
11
|
+
"netAmount": 1.01,
|
12
|
+
"amount": 1.01,
|
13
|
+
"currency": "GBP",
|
14
|
+
"cardDetails": {
|
15
|
+
"cardLastfour": "4963",
|
16
|
+
"endDate": "1215",
|
17
|
+
"cardToken": "TRANSACTION_FAILED",
|
18
|
+
"cardType": 11
|
19
|
+
},
|
20
|
+
"consumer": {
|
21
|
+
"consumerToken": "zSfNrkH5i0LjgAN6",
|
22
|
+
"yourConsumerReference": "bjk-235452-1214"
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"receiptId": "1234",
|
3
|
+
"type": "Payment",
|
4
|
+
"createdAt": "2012-12-05T14:40:53.4529+00:00",
|
5
|
+
"result": "Success",
|
6
|
+
"message": "Payment was successful",
|
7
|
+
"judoId": "123-456",
|
8
|
+
"merchantName": "AnyMerchant Ltd",
|
9
|
+
"appearsOnStatementAs": "Judo Payments/AnyMerch",
|
10
|
+
"refunds": 0.00,
|
11
|
+
"netAmount": 12.34,
|
12
|
+
"cardDetails": {
|
13
|
+
"cardLastFour": "3436",
|
14
|
+
"endDate": "12/15",
|
15
|
+
"cardToken": "ax035fds95325df3",
|
16
|
+
"cardType": 1
|
17
|
+
},
|
18
|
+
"consumer": {
|
19
|
+
"consumerToken": "abcdefghijklABCDDEF",
|
20
|
+
"yourConsumerReference": "consumer0053252"
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,238 @@
|
|
1
|
+
{
|
2
|
+
"resultCount": 1985,
|
3
|
+
"pageSize": 10,
|
4
|
+
"offset": 0,
|
5
|
+
"results": [
|
6
|
+
{
|
7
|
+
"receiptId": "439539",
|
8
|
+
"type": "Payment",
|
9
|
+
"createdAt": "2014-06-17T14:56:49.7571+01:00",
|
10
|
+
"result": "Success",
|
11
|
+
"message": "AuthCode: 210658",
|
12
|
+
"judoId": 100016,
|
13
|
+
"merchantName": "Judo Pay test",
|
14
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
15
|
+
"netAmount": 1.01,
|
16
|
+
"amount": 1.01,
|
17
|
+
"currency": "GBP",
|
18
|
+
"cardDetails": {
|
19
|
+
"cardLastfour": "5462",
|
20
|
+
"endDate": "1215",
|
21
|
+
"cardType": 11
|
22
|
+
},
|
23
|
+
"consumer": {
|
24
|
+
"consumerToken": "HUClqv3MSdCh6g5M",
|
25
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:56:53 +01:00"
|
26
|
+
},
|
27
|
+
"yourPaymentMetaData": {}
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"receiptId": "439521",
|
31
|
+
"type": "Payment",
|
32
|
+
"createdAt": "2014-06-17T14:45:06.3913+01:00",
|
33
|
+
"result": "Success",
|
34
|
+
"message": "AuthCode: 347064",
|
35
|
+
"judoId": 100016,
|
36
|
+
"merchantName": "Judo Pay test",
|
37
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
38
|
+
"netAmount": 1.01,
|
39
|
+
"amount": 1.01,
|
40
|
+
"currency": "GBP",
|
41
|
+
"cardDetails": {
|
42
|
+
"cardLastfour": "5462",
|
43
|
+
"endDate": "1215",
|
44
|
+
"cardType": 11
|
45
|
+
},
|
46
|
+
"consumer": {
|
47
|
+
"consumerToken": "uNU14OInekdSp5GC",
|
48
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:45:07 +01:00"
|
49
|
+
},
|
50
|
+
"yourPaymentMetaData": {}
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"receiptId": "439513",
|
54
|
+
"type": "Payment",
|
55
|
+
"createdAt": "2014-06-17T14:43:05.5359+01:00",
|
56
|
+
"result": "Success",
|
57
|
+
"message": "AuthCode: 980205",
|
58
|
+
"judoId": 100016,
|
59
|
+
"merchantName": "Judo Pay test",
|
60
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
61
|
+
"netAmount": 1.01,
|
62
|
+
"amount": 1.01,
|
63
|
+
"currency": "GBP",
|
64
|
+
"cardDetails": {
|
65
|
+
"cardLastfour": "3436",
|
66
|
+
"endDate": "1215",
|
67
|
+
"cardType": 1
|
68
|
+
},
|
69
|
+
"consumer": {
|
70
|
+
"consumerToken": "PTRSlsgp41XvKIgn",
|
71
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:43:10 +01:00"
|
72
|
+
},
|
73
|
+
"yourPaymentMetaData": {}
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"receiptId": "439505",
|
77
|
+
"type": "Payment",
|
78
|
+
"createdAt": "2014-06-17T14:42:27.3257+01:00",
|
79
|
+
"result": "Declined",
|
80
|
+
"message": "Card declined",
|
81
|
+
"judoId": 100016,
|
82
|
+
"merchantName": "Judo Pay test",
|
83
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
84
|
+
"netAmount": 1.01,
|
85
|
+
"amount": 1.01,
|
86
|
+
"currency": "GBP",
|
87
|
+
"cardDetails": {
|
88
|
+
"cardLastfour": "8074",
|
89
|
+
"endDate": "1215",
|
90
|
+
"cardType": 0
|
91
|
+
},
|
92
|
+
"consumer": {
|
93
|
+
"consumerToken": "i3CVWJwicqQ7z3lR",
|
94
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:42:31 +01:00"
|
95
|
+
},
|
96
|
+
"yourPaymentMetaData": {}
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"receiptId": "439497",
|
100
|
+
"type": "Payment",
|
101
|
+
"createdAt": "2014-06-17T14:41:55.1559+01:00",
|
102
|
+
"result": "Declined",
|
103
|
+
"message": "Card declined",
|
104
|
+
"judoId": 100016,
|
105
|
+
"merchantName": "Judo Pay test",
|
106
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
107
|
+
"netAmount": 1.01,
|
108
|
+
"amount": 1.01,
|
109
|
+
"currency": "GBP",
|
110
|
+
"cardDetails": {
|
111
|
+
"cardLastfour": "4963",
|
112
|
+
"endDate": "1215",
|
113
|
+
"cardType": 11
|
114
|
+
},
|
115
|
+
"consumer": {
|
116
|
+
"consumerToken": "YTCwOjQCu3gWS3IZ",
|
117
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:41:59 +01:00"
|
118
|
+
},
|
119
|
+
"yourPaymentMetaData": {}
|
120
|
+
},
|
121
|
+
{
|
122
|
+
"receiptId": "439489",
|
123
|
+
"type": "Payment",
|
124
|
+
"createdAt": "2014-06-17T14:41:19.3158+01:00",
|
125
|
+
"result": "Success",
|
126
|
+
"message": "AuthCode: 653887",
|
127
|
+
"judoId": 100016,
|
128
|
+
"merchantName": "Judo Pay test",
|
129
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
130
|
+
"netAmount": 1.01,
|
131
|
+
"amount": 1.01,
|
132
|
+
"currency": "GBP",
|
133
|
+
"cardDetails": {
|
134
|
+
"cardLastfour": "5462",
|
135
|
+
"endDate": "1215",
|
136
|
+
"cardType": 11
|
137
|
+
},
|
138
|
+
"consumer": {
|
139
|
+
"consumerToken": "alGXJnK8K44qP8pj",
|
140
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:41:23 +01:00"
|
141
|
+
},
|
142
|
+
"yourPaymentMetaData": {}
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"receiptId": "439448",
|
146
|
+
"type": "Payment",
|
147
|
+
"createdAt": "2014-06-17T13:55:50.5212+01:00",
|
148
|
+
"result": "Success",
|
149
|
+
"message": "AuthCode: 813883",
|
150
|
+
"judoId": 100016,
|
151
|
+
"merchantName": "Judo Pay test",
|
152
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
153
|
+
"netAmount": 1.01,
|
154
|
+
"amount": 1.01,
|
155
|
+
"currency": "GBP",
|
156
|
+
"cardDetails": {
|
157
|
+
"cardLastfour": "5462",
|
158
|
+
"endDate": "1215",
|
159
|
+
"cardType": 11
|
160
|
+
},
|
161
|
+
"consumer": {
|
162
|
+
"consumerToken": "2O4OD7tERdJLfcbr",
|
163
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 13:54:11 +01:00"
|
164
|
+
},
|
165
|
+
"yourPaymentMetaData": {}
|
166
|
+
},
|
167
|
+
{
|
168
|
+
"receiptId": "439331",
|
169
|
+
"type": "Payment",
|
170
|
+
"createdAt": "2014-06-17T11:26:50.7979+01:00",
|
171
|
+
"result": "Success",
|
172
|
+
"message": "AuthCode: 231455",
|
173
|
+
"judoId": 100016,
|
174
|
+
"merchantName": "Judo Pay test",
|
175
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
176
|
+
"netAmount": 1.01,
|
177
|
+
"amount": 1.01,
|
178
|
+
"currency": "GBP",
|
179
|
+
"cardDetails": {
|
180
|
+
"cardLastfour": "5462",
|
181
|
+
"endDate": "1215",
|
182
|
+
"cardType": 11
|
183
|
+
},
|
184
|
+
"consumer": {
|
185
|
+
"consumerToken": "HcQD4V7yUfHwNQl5",
|
186
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 11:25:42 +01:00"
|
187
|
+
},
|
188
|
+
"yourPaymentMetaData": {}
|
189
|
+
},
|
190
|
+
{
|
191
|
+
"receiptId": "439323",
|
192
|
+
"type": "Payment",
|
193
|
+
"createdAt": "2014-06-17T11:23:58.4341+01:00",
|
194
|
+
"result": "Success",
|
195
|
+
"message": "AuthCode: 472047",
|
196
|
+
"judoId": 100016,
|
197
|
+
"merchantName": "Judo Pay test",
|
198
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
199
|
+
"netAmount": 1.01,
|
200
|
+
"amount": 1.01,
|
201
|
+
"currency": "GBP",
|
202
|
+
"cardDetails": {
|
203
|
+
"cardLastfour": "6204",
|
204
|
+
"endDate": "1215",
|
205
|
+
"cardType": 1
|
206
|
+
},
|
207
|
+
"consumer": {
|
208
|
+
"consumerToken": "sitr0qdIGD58oL4z",
|
209
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 11:24:00 +01:00"
|
210
|
+
},
|
211
|
+
"yourPaymentMetaData": {}
|
212
|
+
},
|
213
|
+
{
|
214
|
+
"receiptId": "439315",
|
215
|
+
"type": "Payment",
|
216
|
+
"createdAt": "2014-06-17T11:21:55.6956+01:00",
|
217
|
+
"result": "Success",
|
218
|
+
"message": "AuthCode: 295259",
|
219
|
+
"judoId": 100016,
|
220
|
+
"merchantName": "Judo Pay test",
|
221
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
222
|
+
"netAmount": 1.01,
|
223
|
+
"amount": 1.01,
|
224
|
+
"currency": "GBP",
|
225
|
+
"cardDetails": {
|
226
|
+
"cardLastfour": "5460",
|
227
|
+
"endDate": "1215",
|
228
|
+
"cardType": 2
|
229
|
+
},
|
230
|
+
"consumer": {
|
231
|
+
"consumerToken": "PLJh1QRPppvsJze9",
|
232
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 11:21:57 +01:00"
|
233
|
+
},
|
234
|
+
"yourPaymentMetaData": {}
|
235
|
+
}
|
236
|
+
],
|
237
|
+
"sort": "time-descending"
|
238
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"receiptId": "439539",
|
3
|
+
"type": "Payment",
|
4
|
+
"createdAt": "2014-06-17T14:56:49.7571+01:00",
|
5
|
+
"result": "Success",
|
6
|
+
"message": "AuthCode: 210658",
|
7
|
+
"judoId": 100016,
|
8
|
+
"merchantName": "Judo Pay test",
|
9
|
+
"appearsOnStatementAs": "JudoPay/JudoPayt",
|
10
|
+
"netAmount": 1.01,
|
11
|
+
"amount": 1.01,
|
12
|
+
"currency": "GBP",
|
13
|
+
"cardDetails": {
|
14
|
+
"cardLastfour": "5462",
|
15
|
+
"endDate": "1215",
|
16
|
+
"cardType": 11
|
17
|
+
},
|
18
|
+
"consumer": {
|
19
|
+
"consumerToken": "HUClqv3MSdCh6g5M",
|
20
|
+
"yourConsumerReference": "WebPayDemo_17/06/2014 14:56:53 +01:00"
|
21
|
+
},
|
22
|
+
"yourPaymentMetaData": {}
|
23
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ",
|
3
|
+
"status": "Open",
|
4
|
+
"transactionType": "Payment",
|
5
|
+
"judoId": "1234-4567",
|
6
|
+
"amount": 12.34,
|
7
|
+
"currency": "GBP",
|
8
|
+
"expiryDate": "2014-03-18T14:35:54.5428+00:00",
|
9
|
+
"companyName": "AnyMerchant Ltd",
|
10
|
+
"yourConsumerReference": "consumer0053252",
|
11
|
+
"yourPaymentReference": "payment12412312",
|
12
|
+
"yourPaymentMetaData": {},
|
13
|
+
"response": {
|
14
|
+
"postUrl": "http://pay.judopay-sandbox.com/",
|
15
|
+
"reference": "4gcBAAMAGAASAAAADA66kRor6ofknGqU3A6i-759FprFGPH3ecVcW5ChMQK0f3pLBQ"
|
16
|
+
},
|
17
|
+
"cardAddress": "",
|
18
|
+
"clientIpAddress": "127.0.0.1",
|
19
|
+
"clientUserAgent": "Mozilla/5.0 (Windows NT 6.2; Win64; x64)...",
|
20
|
+
"paymentSuccessUrl": "http://www.yourcompany.co.uk/success",
|
21
|
+
"paymentCancelUrl": "http://www.yourcompany.co.uk/cancel",
|
22
|
+
"receipt": {
|
23
|
+
"receiptId": "1234",
|
24
|
+
"type": "Payment",
|
25
|
+
"createdAt": "2012-12-05T14:40:53.4529+00:00",
|
26
|
+
"result": "Success",
|
27
|
+
"message": "Payment was successful",
|
28
|
+
"judoId": "123-4567",
|
29
|
+
"merchantName": "AnyMerchant Ltd",
|
30
|
+
"appearsOnStatementAs": "Judo Payments/AnyMerch",
|
31
|
+
"refunds": 0.00,
|
32
|
+
"netAmount": 12.34,
|
33
|
+
"cardDetails": {
|
34
|
+
"cardLastFour": "3436",
|
35
|
+
"endDate": "12/15",
|
36
|
+
"cardType": 1
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/judopay/models/card_address'
|
3
|
+
|
4
|
+
describe Judopay::CardAddress do
|
5
|
+
it "should not allow querying of the API if a resource path isn't set on the model" do
|
6
|
+
expect(lambda do
|
7
|
+
Judopay::CardAddress.all
|
8
|
+
end).to raise_error(Judopay::Error)
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../lib/judopay/models/card_payment'
|
3
|
+
|
4
|
+
describe Judopay::CardPayment do
|
5
|
+
it 'should create a new payment given valid card details' do
|
6
|
+
stub_post('/transactions/payments').
|
7
|
+
to_return(:status => 200,
|
8
|
+
:body => lambda { |_request| fixture('card_payments/create.json') })
|
9
|
+
|
10
|
+
payment = build(:card_payment)
|
11
|
+
response = payment.create
|
12
|
+
|
13
|
+
expect(response).to be_a(Hash)
|
14
|
+
expect(response.result).to eq('Success')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not create a new payment if the card is declined' do
|
18
|
+
stub_post('/transactions/payments').
|
19
|
+
to_return(:status => 200,
|
20
|
+
:body => lambda { |_request| fixture('card_payments/create_declined.json') })
|
21
|
+
|
22
|
+
payment = build(:card_payment)
|
23
|
+
payment.card_number = '4221690000004963' # Always declined
|
24
|
+
response = payment.create
|
25
|
+
|
26
|
+
expect(response).to be_a(Hash)
|
27
|
+
expect(response.result).to eq('Declined')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return a bad request exception if basic validation fails' do
|
31
|
+
expect(lambda do
|
32
|
+
Judopay::CardPayment.new.create
|
33
|
+
end).to raise_error(Judopay::ValidationError)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should use the configured Judo ID if one isn't provided in the payment request" do
|
37
|
+
|
38
|
+
stub_post('/transactions/payments').
|
39
|
+
to_return(:status => 200,
|
40
|
+
:body => lambda { |_request| fixture('card_payments/create.json') })
|
41
|
+
|
42
|
+
Judopay.configure do |config|
|
43
|
+
config.judo_id = '123-456'
|
44
|
+
end
|
45
|
+
|
46
|
+
payment = build(:card_payment)
|
47
|
+
payment.create
|
48
|
+
|
49
|
+
expect(payment.valid?).to eq(true)
|
50
|
+
expect(payment.judo_id).to eq('123-456')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should validate a new payment given valid card details' do
|
54
|
+
stub_post('/transactions/payments/validate').
|
55
|
+
to_return(:status => 200,
|
56
|
+
:body => lambda { |_request| fixture('card_payments/validate.json') })
|
57
|
+
|
58
|
+
payment = build(:card_payment)
|
59
|
+
response = payment.validate
|
60
|
+
|
61
|
+
expect(response).to be_a(Hash)
|
62
|
+
expect(response.error_message).to include('good to go') # API could give a more helpful response here
|
63
|
+
end
|
64
|
+
end
|