cloud_payments 0.0.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +12 -6
  3. data/Gemfile +2 -2
  4. data/README.md +88 -5
  5. data/Rakefile +1 -0
  6. data/cloud_payments.gemspec +8 -8
  7. data/config.ru +1 -0
  8. data/lib/cloud_payments.rb +6 -1
  9. data/lib/cloud_payments/client.rb +3 -2
  10. data/lib/cloud_payments/client/errors.rb +1 -0
  11. data/lib/cloud_payments/client/gateway_errors.rb +3 -1
  12. data/lib/cloud_payments/client/response.rb +2 -1
  13. data/lib/cloud_payments/client/serializer.rb +1 -0
  14. data/lib/cloud_payments/client/serializer/base.rb +9 -1
  15. data/lib/cloud_payments/client/serializer/multi_json.rb +1 -0
  16. data/lib/cloud_payments/config.rb +4 -0
  17. data/lib/cloud_payments/models.rb +8 -0
  18. data/lib/cloud_payments/models/like_subscription.rb +30 -0
  19. data/lib/cloud_payments/models/model.rb +9 -0
  20. data/lib/cloud_payments/models/on_fail.rb +31 -0
  21. data/lib/cloud_payments/models/on_kassa_receipt.rb +23 -0
  22. data/lib/cloud_payments/models/on_pay.rb +37 -0
  23. data/lib/cloud_payments/models/on_recurrent.rb +22 -0
  24. data/lib/cloud_payments/models/order.rb +14 -0
  25. data/lib/cloud_payments/models/secure3d.rb +1 -0
  26. data/lib/cloud_payments/models/subscription.rb +9 -32
  27. data/lib/cloud_payments/models/transaction.rb +13 -4
  28. data/lib/cloud_payments/namespaces.rb +12 -1
  29. data/lib/cloud_payments/namespaces/base.rb +2 -1
  30. data/lib/cloud_payments/namespaces/cards.rb +6 -0
  31. data/lib/cloud_payments/namespaces/kassa.rb +22 -0
  32. data/lib/cloud_payments/namespaces/orders.rb +15 -0
  33. data/lib/cloud_payments/namespaces/payments.rb +11 -0
  34. data/lib/cloud_payments/namespaces/subscriptions.rb +6 -0
  35. data/lib/cloud_payments/namespaces/tokens.rb +1 -0
  36. data/lib/cloud_payments/version.rb +2 -1
  37. data/lib/cloud_payments/webhooks.rb +42 -0
  38. data/spec/cloud_payments/client/response_spec.rb +3 -1
  39. data/spec/cloud_payments/client/serializer/multi_json_spec.rb +1 -0
  40. data/spec/cloud_payments/models/order_spec.rb +62 -0
  41. data/spec/cloud_payments/models/secure3d_spec.rb +1 -0
  42. data/spec/cloud_payments/models/subscription_spec.rb +1 -1
  43. data/spec/cloud_payments/models/transaction_spec.rb +25 -1
  44. data/spec/cloud_payments/namespaces/base_spec.rb +10 -3
  45. data/spec/cloud_payments/namespaces/cards_spec.rb +42 -2
  46. data/spec/cloud_payments/namespaces/kassa_spec.rb +43 -0
  47. data/spec/cloud_payments/namespaces/orders_spec.rb +57 -0
  48. data/spec/cloud_payments/namespaces/payments_spec.rb +119 -0
  49. data/spec/cloud_payments/namespaces/subscriptions_spec.rb +21 -1
  50. data/spec/cloud_payments/namespaces/tokens_spec.rb +1 -0
  51. data/spec/cloud_payments/namespaces_spec.rb +2 -1
  52. data/spec/cloud_payments/webhooks_spec.rb +272 -0
  53. data/spec/cloud_payments_spec.rb +27 -4
  54. data/spec/fixtures/apis/cards/post3ds/failed.yml +45 -0
  55. data/spec/fixtures/apis/cards/post3ds/successful.yml +48 -0
  56. data/spec/fixtures/apis/orders/cancel/failed.yml +6 -0
  57. data/spec/fixtures/apis/orders/cancel/successful.yml +6 -0
  58. data/spec/fixtures/apis/orders/create/successful.yml +20 -0
  59. data/spec/fixtures/apis/payments/find/failed.yml +45 -0
  60. data/spec/fixtures/apis/payments/find/failed_with_message.yml +6 -0
  61. data/spec/fixtures/apis/payments/find/successful.yml +48 -0
  62. data/spec/fixtures/apis/payments/get/failed.yml +46 -0
  63. data/spec/fixtures/apis/payments/get/failed_with_message.yml +6 -0
  64. data/spec/fixtures/apis/payments/get/refunded.yml +49 -0
  65. data/spec/fixtures/apis/payments/get/successful.yml +49 -0
  66. data/spec/fixtures/apis/subscriptions/find/successful.yml +4 -4
  67. data/spec/fixtures/apis/subscriptions/get/successful.yml +31 -0
  68. data/spec/spec_helper.rb +13 -24
  69. data/spec/support/examples.rb +1 -0
  70. data/spec/support/helpers.rb +3 -2
  71. metadata +62 -34
  72. data/spec/cloud_payments/client_spec.rb +0 -5
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Namespaces::Tokens do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Namespaces do
@@ -33,7 +34,7 @@ describe CloudPayments::Namespaces do
33
34
  end
34
35
 
35
36
  context 'when exception occurs while request' do
36
- before{ stub_api_request('ping/failed').to_raise(::Faraday::Error::ConnectionFailed) }
37
+ before{ stub_api_request('ping/failed').to_raise(::Faraday::ConnectionFailed) }
37
38
  specify{ expect(subject.ping).to be_falsy }
38
39
  end
39
40
 
@@ -0,0 +1,272 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # frozen_string_literal: true
4
+ require 'spec_helper'
5
+
6
+ describe CloudPayments::Webhooks do
7
+ describe 'HMAC validation' do
8
+ let(:valid_hmac) { 'tJW02TMAce4Em8eJTNqjhOax+BYRM5K2D8mX9xsmUUc=' }
9
+ let(:invalid_hmac) { '6sUXv4W0wmhfpkkDtp+3Hw/M8deAPkMRVV3OWANcqro=' }
10
+ let(:data) {
11
+ "TransactionId=666&Amount=123.00&Currency=RUB&PaymentAmount=123.00&PaymentCurrency=RUB&InvoiceId=1234567&AccountId=user%40example.com&SubscriptionId=&Name=VLADIMIR+KOCHNEV&Email=user%40example.com&DateTime=2015-11-17+14%3a51%3a20&IpAddress=127.0.0.1&IpCountry=RU&IpCity=%d0%a1%d0%b0%d0%bd%d0%ba%d1%82-%d0%9f%d0%b5%d1%82%d0%b5%d1%80%d0%b1%d1%83%d1%80%d0%b3&IpRegion=%d0%a1%d0%b0%d0%bd%d0%ba%d1%82-%d0%9f%d0%b5%d1%82%d0%b5%d1%80%d0%b1%d1%83%d1%80%d0%b3&IpDistrict=%d0%a1%d0%b5%d0%b2%d0%b5%d1%80%d0%be-%d0%97%d0%b0%d0%bf%d0%b0%d0%b4%d0%bd%d1%8b%d0%b9+%d1%84%d0%b5%d0%b4%d0%b5%d1%80%d0%b0%d0%bb%d1%8c%d0%bd%d1%8b%d0%b9+%d0%be%d0%ba%d1%80%d1%83%d0%b3&IpLatitude=59.939000&IpLongitude=30.315800&CardFirstSix=411111&CardLastFour=1111&CardType=Visa&CardExpDate=01%2f19&Issuer=&IssuerBankCountry=&Description=%d0%9e%d0%bf%d0%bb%d0%b0%d1%82%d0%b0+%d0%b2+example.com&AuthCode=DEADBEEF&Token=1234567890&TestMode=1&Status=Completed"
12
+ }
13
+
14
+ context 'with data_valid?' do
15
+ it 'returns true on valid hmac' do
16
+ expect(CloudPayments.webhooks.data_valid?(data, valid_hmac)).to be_truthy
17
+ end
18
+
19
+ it 'returns false on invalid hmac' do
20
+ expect(CloudPayments.webhooks.data_valid?(data, invalid_hmac)).to be_falsey
21
+ end
22
+ end
23
+
24
+ context 'with validate_data!' do
25
+ it 'returns true on valid hmac' do
26
+ expect(CloudPayments.webhooks.validate_data!(data, valid_hmac)).to be_truthy
27
+ end
28
+
29
+ it 'raises a HMACError on invalid hmac' do
30
+ expect {
31
+ CloudPayments.webhooks.validate_data!(data, invalid_hmac)
32
+ }.to raise_error(CloudPayments::Webhooks::HMACError)
33
+ end
34
+ end
35
+ end
36
+
37
+ describe 'on_check' do
38
+ let(:raw_data) do
39
+ {"TransactionId"=>"1701609",
40
+ "Amount"=>"123.00",
41
+ "Currency"=>"RUB",
42
+ "PaymentAmount"=>"123.00",
43
+ "PaymentCurrency"=>"RUB",
44
+ "InvoiceId"=>"1234567",
45
+ "AccountId"=>"user@example.com",
46
+ "SubscriptionId"=>"",
47
+ "Name"=>"OLEG FOMIN",
48
+ "Email"=>"user@example.com",
49
+ "DateTime"=>"2015-11-17 23:06:15",
50
+ "IpAddress"=>"127.0.0.1",
51
+ "IpCountry"=>"RU",
52
+ "IpCity"=>"Санкт-Петербург",
53
+ "IpRegion"=>"Санкт-Петербург",
54
+ "IpDistrict"=>"Северо-Западный федеральный округ",
55
+ "IpLatitude"=>"59.939000",
56
+ "IpLongitude"=>"30.315000",
57
+ "CardFirstSix"=>"411111",
58
+ "CardLastFour"=>"1111",
59
+ "CardType"=>"Visa",
60
+ "CardExpDate"=>"01/19",
61
+ "Issuer"=>"",
62
+ "IssuerBankCountry"=>"",
63
+ "Description"=>"Оплата в example.com",
64
+ "TestMode"=>"1",
65
+ "Status"=>"Completed",
66
+ "Data"=>
67
+ "{\"cloudPayments\":{\"recurrent\":{\"interval\":\"Month\",\"period\":1}}}"}
68
+ end
69
+
70
+ subject { CloudPayments.webhooks.on_check(raw_data) }
71
+ end
72
+
73
+ describe 'on_pay' do
74
+ let(:raw_data) do
75
+ {"TransactionId"=>"1701609",
76
+ "Amount"=>"123.00",
77
+ "Currency"=>"RUB",
78
+ "PaymentAmount"=>"123.00",
79
+ "PaymentCurrency"=>"RUB",
80
+ "InvoiceId"=>"1234567",
81
+ "AccountId"=>"user@example.com",
82
+ "SubscriptionId"=>"sc_b865df3d4f27c54dc8067520c071a",
83
+ "Name"=>"OLEG FOMIN",
84
+ "Email"=>"user@example.com",
85
+ "DateTime"=>"2015-11-17 23:06:17",
86
+ "IpAddress"=>"127.0.0.1",
87
+ "IpCountry"=>"RU",
88
+ "IpCity"=>"Санкт-Петербург",
89
+ "IpRegion"=>"Санкт-Петербург",
90
+ "IpDistrict"=>"Северо-Западный федеральный округ",
91
+ "IpLatitude"=>"59.939037",
92
+ "IpLongitude"=>"30.315784",
93
+ "CardFirstSix"=>"411111",
94
+ "CardLastFour"=>"1111",
95
+ "CardType"=>"Visa",
96
+ "CardExpDate"=>"01/19",
97
+ "Issuer"=>"",
98
+ "IssuerBankCountry"=>"",
99
+ "Description"=>"Оплата в example.com",
100
+ "AuthCode"=>"A1B2C3",
101
+ "Token"=>"9BBEF19476623CA56C17DA75FD57734DBF82530686043A6E491C6D71BEFE8F6E",
102
+ "TestMode"=>"1",
103
+ "Status"=>"Completed",
104
+ "Data"=>
105
+ "{\"cloudPayments\":{\"recurrent\":{\"interval\":\"Month\",\"period\":1}}}"}
106
+ end
107
+
108
+ subject { CloudPayments.webhooks.on_pay(raw_data) }
109
+
110
+ specify { expect(subject.id).to eq '1701609' }
111
+ specify { expect(subject.amount).to eq 123.00 }
112
+ specify { expect(subject.currency).to eq 'RUB' }
113
+ specify { expect(subject.invoice_id).to eq '1234567' }
114
+ specify { expect(subject.account_id).to eq 'user@example.com' }
115
+ specify { expect(subject.subscription_id).to eq 'sc_b865df3d4f27c54dc8067520c071a' }
116
+ specify { expect(subject.name).to eq 'OLEG FOMIN' }
117
+ specify { expect(subject.email).to eq 'user@example.com' }
118
+ specify { expect(subject.date_time).to eq DateTime.parse('2015-11-17 23:06:17') }
119
+ specify { expect(subject.ip_address).to eq '127.0.0.1' }
120
+ specify { expect(subject.ip_country).to eq 'RU' }
121
+ specify { expect(subject.ip_city).to eq 'Санкт-Петербург' }
122
+ specify { expect(subject.ip_region).to eq 'Санкт-Петербург' }
123
+ specify { expect(subject.ip_district).to eq 'Северо-Западный федеральный округ' }
124
+ specify { expect(subject.ip_lat).to eq '59.939037' }
125
+ specify { expect(subject.ip_lng).to eq '30.315784' }
126
+ specify { expect(subject.card_first_six).to eq '411111' }
127
+ specify { expect(subject.card_last_four).to eq '1111' }
128
+ specify { expect(subject.card_type).to eq 'Visa' }
129
+ specify { expect(subject.card_exp_date).to eq '01/19' }
130
+ specify { expect(subject.description).to eq 'Оплата в example.com' }
131
+ specify { expect(subject.auth_code).to eq 'A1B2C3' }
132
+ specify { expect(subject.token).to eq '9BBEF19476623CA56C17DA75FD57734DBF82530686043A6E491C6D71BEFE8F6E' }
133
+ specify { expect(subject.status).to eq 'Completed' }
134
+ end
135
+
136
+ describe 'on_fail' do
137
+ let(:raw_data) do
138
+ {"TransactionId"=>"1701658",
139
+ "Amount"=>"123.00",
140
+ "Currency"=>"RUB",
141
+ "PaymentAmount"=>"123.00",
142
+ "PaymentCurrency"=>"RUB",
143
+ "InvoiceId"=>"1234567",
144
+ "AccountId"=>"user@example.com",
145
+ "SubscriptionId"=>"",
146
+ "Name"=>"OLEG FOMIN",
147
+ "Email"=>"user@example.com",
148
+ "DateTime"=>"2015-11-17 23:35:09",
149
+ "IpAddress"=>"127.0.0.1",
150
+ "IpCountry"=>"RU",
151
+ "IpCity"=>"Санкт-Петербург",
152
+ "IpRegion"=>"Санкт-Петербург",
153
+ "IpDistrict"=>"Северо-Западный федеральный округ",
154
+ "IpLatitude"=>"59.939037",
155
+ "IpLongitude"=>"30.315784",
156
+ "CardFirstSix"=>"400005",
157
+ "CardLastFour"=>"5556",
158
+ "CardType"=>"Visa",
159
+ "CardExpDate"=>"01/19",
160
+ "Issuer"=>"",
161
+ "IssuerBankCountry"=>"",
162
+ "Description"=>"Оплата в example.com",
163
+ "TestMode"=>"1",
164
+ "Status"=>"Declined",
165
+ "StatusCode"=>"5",
166
+ "Reason"=>"InsufficientFunds",
167
+ "ReasonCode"=>"5051",
168
+ "Data"=>
169
+ "{\"cloudPayments\":{\"recurrent\":{\"interval\":\"Month\",\"period\":1}}}"}
170
+ end
171
+
172
+ subject { CloudPayments.webhooks.on_fail(raw_data) }
173
+
174
+ specify { expect(subject.id).to eq '1701658' }
175
+ specify { expect(subject.amount).to eq 123.00 }
176
+ specify { expect(subject.currency).to eq 'RUB' }
177
+ specify { expect(subject.invoice_id).to eq '1234567' }
178
+ specify { expect(subject.account_id).to eq 'user@example.com' }
179
+ specify { expect(subject.subscription_id).to eq '' }
180
+ specify { expect(subject.name).to eq 'OLEG FOMIN' }
181
+ specify { expect(subject.email).to eq 'user@example.com' }
182
+ specify { expect(subject.date_time).to eq DateTime.parse('2015-11-17 23:35:09') }
183
+ specify { expect(subject.ip_address).to eq '127.0.0.1' }
184
+ specify { expect(subject.ip_country).to eq 'RU' }
185
+ specify { expect(subject.ip_city).to eq 'Санкт-Петербург' }
186
+ specify { expect(subject.ip_region).to eq 'Санкт-Петербург' }
187
+ specify { expect(subject.ip_district).to eq 'Северо-Западный федеральный округ' }
188
+ specify { expect(subject.card_first_six).to eq '400005' }
189
+ specify { expect(subject.card_last_four).to eq '5556' }
190
+ specify { expect(subject.card_type).to eq 'Visa' }
191
+ specify { expect(subject.card_exp_date).to eq '01/19' }
192
+ specify { expect(subject.description).to eq 'Оплата в example.com' }
193
+ end
194
+
195
+ describe 'on_recurrent' do
196
+ let(:raw_data) do
197
+ {"Id"=>"sc_a38ca02005d40db7d32b36a0097b0",
198
+ "AccountId"=>"1234",
199
+ "Description"=>"just description",
200
+ "Email"=>"user@example.com",
201
+ "Amount"=>"2.00",
202
+ "Currency"=>"RUB",
203
+ "RequireConfirmation"=>"0",
204
+ "StartDate"=>"2015-12-17 20:22:14",
205
+ "Interval"=>"Month",
206
+ "Period"=>"1",
207
+ "Status"=>"PastDue",
208
+ "SuccessfulTransactionsNumber"=>"11",
209
+ "FailedTransactionsNumber"=>"22",
210
+ "NextTransactionDate"=>"2015-11-18 20:29:05"}
211
+ end
212
+
213
+ subject { CloudPayments.webhooks.on_recurrent(raw_data) }
214
+
215
+ specify { expect(subject.id).to eq 'sc_a38ca02005d40db7d32b36a0097b0' }
216
+ specify { expect(subject.account_id).to eq '1234' }
217
+ specify { expect(subject.description).to eq 'just description' }
218
+ specify { expect(subject.email).to eq 'user@example.com' }
219
+ specify { expect(subject.amount).to eq 2.00 }
220
+ specify { expect(subject.currency).to eq 'RUB' }
221
+ specify { expect(subject.require_confirmation).to eq false }
222
+ specify { expect(subject.started_at).to eq DateTime.parse('2015-12-17 20:22:14') }
223
+ specify { expect(subject.interval).to eq 'Month' }
224
+ specify { expect(subject.period).to eq 1 }
225
+ specify { expect(subject.status).to eq 'PastDue' }
226
+ specify { expect(subject.successful_transactions).to eq 11 }
227
+ specify { expect(subject.failed_transactions).to eq 22 }
228
+ specify { expect(subject.next_transaction_at).to eq DateTime.parse('2015-11-18 20:29:05') }
229
+ end
230
+
231
+ describe 'on_kassa_receipt' do
232
+ let(:raw_data) do
233
+ {"Id"=>"sc_a38ca02005d40db7d32b36a0097b0",
234
+ "DocumentNumber"=>"1234",
235
+ "SessionNumber"=>"12345",
236
+ "FiscalSign"=>"signsgin",
237
+ "DeviceNumber"=>"123465",
238
+ "RegNumber"=>"12345",
239
+ "Inn"=>"0",
240
+ "Type"=>"Type",
241
+ "Ofd"=>"Ofd",
242
+ "Url"=>"http://example.com/url/",
243
+ "QrCodeUrl"=>"http://example.com/url",
244
+ "Amount"=>"11.11",
245
+ "DateTime"=>"2015-11-18 20:29:05",
246
+ "Receipt"=>"{}",
247
+ "TransactionId" => "12321123",
248
+ "InvoiceId" => "123123",
249
+ "AccountId" => "3213213"}
250
+ end
251
+
252
+ subject { CloudPayments.webhooks.kassa_receipt(raw_data) }
253
+
254
+ specify { expect(subject.id).to eq "sc_a38ca02005d40db7d32b36a0097b0" }
255
+ specify { expect(subject.document_number).to eq '1234' }
256
+ specify { expect(subject.session_number).to eq '12345' }
257
+ specify { expect(subject.fiscal_sign).to eq 'signsgin' }
258
+ specify { expect(subject.device_number).to eq '123465' }
259
+ specify { expect(subject.reg_number).to eq '12345' }
260
+ specify { expect(subject.inn).to eq '0' }
261
+ specify { expect(subject.type).to eq 'Type' }
262
+ specify { expect(subject.ofd).to eq 'Ofd' }
263
+ specify { expect(subject.url).to eq 'http://example.com/url/' }
264
+ specify { expect(subject.qr_code_url).to eq 'http://example.com/url' }
265
+ specify { expect(subject.amount).to eq 11.11 }
266
+ specify { expect(subject.date_time).to eq DateTime.parse('2015-11-18 20:29:05') }
267
+ specify { expect(subject.receipt).to eq '{}' }
268
+ specify { expect(subject.transaction_id).to eq '12321123' }
269
+ specify { expect(subject.invoice_id).to eq '123123' }
270
+ specify { expect(subject.account_id).to eq '3213213' }
271
+ end
272
+ end
@@ -1,14 +1,37 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments do
4
5
  describe '#config=' do
5
- before{ @old_config = CloudPayments.config }
6
- after{ CloudPayments.config = @old_config }
6
+ before { @old_config = CloudPayments.config }
7
+ after { CloudPayments.config = @old_config }
7
8
 
8
9
  specify{ expect{ CloudPayments.config = 'config' }.to change{ CloudPayments.config }.to('config') }
9
10
  end
10
11
 
11
- describe '#config' do
12
- specify{ expect(CloudPayments.config).to be_instance_of(CloudPayments::Config) }
12
+ it 'supports global configuration' do
13
+ CloudPayments.config.secret_key = "OLD_KEY"
14
+
15
+ CloudPayments.configure do |c|
16
+ c.secret_key = "NEW_KEY"
17
+ end
18
+
19
+ expect(CloudPayments.config.secret_key).to eq "NEW_KEY"
20
+ expect(CloudPayments.client.config.secret_key).to eq "NEW_KEY"
21
+ end
22
+
23
+ it 'supports local configuration' do
24
+ CloudPayments.config.secret_key = "OLD_KEY"
25
+
26
+ config = CloudPayments::Config.new do |c|
27
+ c.secret_key = "NEW_KEY"
28
+ end
29
+ client = CloudPayments::Client.new(config)
30
+ webhooks = CloudPayments::Webhooks.new(config)
31
+
32
+ expect(CloudPayments.config.secret_key).to eq "OLD_KEY"
33
+ expect(config.secret_key).to eq "NEW_KEY"
34
+ expect(client.config.secret_key).to eq "NEW_KEY"
35
+ expect(webhooks.config.secret_key).to eq "NEW_KEY"
13
36
  end
14
37
  end
@@ -0,0 +1,45 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/cards/post3ds'
4
+ :body: '{"TransactionId":12345,"PaRes":"AQ=="}'
5
+ :response:
6
+ :body: >
7
+ {
8
+ "Model": {
9
+ "TransactionId": 12345,
10
+ "Amount": 10.0,
11
+ "Currency": "RUB",
12
+ "CurrencyCode": 0,
13
+ "PaymentAmount": 10.0,
14
+ "PaymentCurrency": "RUB",
15
+ "PaymentCurrencyCode": 0,
16
+ "InvoiceId": "1234567",
17
+ "AccountId": "user_x",
18
+ "Email": null,
19
+ "Description": "Payment for goods on example.com",
20
+ "JsonData": null,
21
+ "CreatedDate": "\/Date(1401718880000)\/",
22
+ "CreatedDateIso":"2014-08-09T11:49:41",
23
+ "TestMode": true,
24
+ "IpAddress": "195.91.194.13",
25
+ "IpCountry": "RU",
26
+ "IpCity": "Ufa",
27
+ "IpRegion": "Bashkortostan Republic",
28
+ "IpDistrict": "Volga Federal District",
29
+ "IpLatitude": 54.7355,
30
+ "IpLongitude": 55.991982,
31
+ "CardFirstSix": "411111",
32
+ "CardLastFour": "1111",
33
+ "CardType": "Visa",
34
+ "CardTypeCode": 0,
35
+ "IssuerBankCountry": "RU",
36
+ "Status": "Declined",
37
+ "StatusCode": 5,
38
+ "Reason": "InsufficientFunds",
39
+ "ReasonCode": 5051,
40
+ "CardHolderMessage": "Insufficient funds on account",
41
+ "Name": "CARDHOLDER NAME"
42
+ },
43
+ "Success": false,
44
+ "Message": null
45
+ }
@@ -0,0 +1,48 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/cards/post3ds'
4
+ :body: '{"TransactionId":12345,"PaRes":"AQ=="}'
5
+ :response:
6
+ :body: >
7
+ {
8
+ "Model":{
9
+ "TransactionId":12345,
10
+ "Amount":10.0,
11
+ "Currency":"RUB",
12
+ "CurrencyCode":0,
13
+ "InvoiceId":"1234567",
14
+ "AccountId":"user_x",
15
+ "Email":null,
16
+ "Description":"Payment for goods on example.com",
17
+ "JsonData":null,
18
+ "CreatedDate":"\/Date(1401718880000)\/",
19
+ "CreatedDateIso":"2014-08-09T11:49:41",
20
+ "AuthDate":"\/Date(1401733880523)\/",
21
+ "AuthDateIso":"2014-08-09T11:49:42",
22
+ "ConfirmDate":"\/Date(1401733880523)\/",
23
+ "ConfirmDateIso":"2014-08-09T11:49:42",
24
+ "AuthCode":"123456",
25
+ "TestMode":true,
26
+ "IpAddress":"195.91.194.13",
27
+ "IpCountry":"RU",
28
+ "IpCity":"Ufa",
29
+ "IpRegion":"Bashkortostan Republic",
30
+ "IpDistrict":"Volga Federal District",
31
+ "IpLatitude":54.7355,
32
+ "IpLongitude":55.991982,
33
+ "CardFirstSix":"411111",
34
+ "CardLastFour":"1111",
35
+ "CardType":"Visa",
36
+ "CardTypeCode":0,
37
+ "IssuerBankCountry":"RU",
38
+ "Status":"Completed",
39
+ "StatusCode":3,
40
+ "Reason":"Approved",
41
+ "ReasonCode":0,
42
+ "CardHolderMessage":"Payment successful",
43
+ "Name":"CARDHOLDER NAME",
44
+ "Token":"a4e67841-abb0-42de-a364-d1d8f9f4b3c0"
45
+ },
46
+ "Success":true,
47
+ "Message": null
48
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ :request:
3
+ :url: '/orders/cancel'
4
+ :body: '{"Id":"12345"}'
5
+ :response:
6
+ :body: '{"Success":false,"Message":"Error message"}'
@@ -0,0 +1,6 @@
1
+ ---
2
+ :request:
3
+ :url: '/orders/cancel'
4
+ :body: '{"Id":"12345"}'
5
+ :response:
6
+ :body: '{"Success":true,"Message":null}'
@@ -0,0 +1,20 @@
1
+ ---
2
+ :request:
3
+ :url: '/orders/create'
4
+ :body: '{"Amount":10.0,"Currency":"RUB","Description":"Оплата на сайте example.com","Email":"client@test.local","RequireConfirmation":true,"SendEmail":false,"InvoiceId":"invoice_100","AccountId":"account_200","Phone":"+7(495)765-4321","SendSms":false,"SendWhatsApp":false}'
5
+ :response:
6
+ :body: >
7
+ {
8
+ "Model":{
9
+ "Id":"f2K8LV6reGE9WBFn",
10
+ "Number":61,
11
+ "Amount":10.0,
12
+ "Currency":"RUB",
13
+ "CurrencyCode":0,
14
+ "Email":"client@test.local",
15
+ "Description":"Оплата на сайте example.com",
16
+ "RequireConfirmation":true,
17
+ "Url":"https://orders.cloudpayments.ru/d/f2K8LV6reGE9WBFn"
18
+ },
19
+ "Success":true
20
+ }