cloud_payments 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -2
  3. data/Gemfile +1 -1
  4. data/README.md +0 -2
  5. data/Rakefile +1 -0
  6. data/cloud_payments.gemspec +1 -0
  7. data/config.ru +1 -0
  8. data/lib/cloud_payments.rb +1 -0
  9. data/lib/cloud_payments/client.rb +1 -0
  10. data/lib/cloud_payments/client/errors.rb +1 -0
  11. data/lib/cloud_payments/client/gateway_errors.rb +1 -0
  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 +1 -0
  15. data/lib/cloud_payments/client/serializer/multi_json.rb +1 -0
  16. data/lib/cloud_payments/config.rb +1 -0
  17. data/lib/cloud_payments/models.rb +1 -0
  18. data/lib/cloud_payments/models/like_subscription.rb +1 -0
  19. data/lib/cloud_payments/models/model.rb +1 -0
  20. data/lib/cloud_payments/models/on_fail.rb +1 -0
  21. data/lib/cloud_payments/models/on_pay.rb +1 -0
  22. data/lib/cloud_payments/models/on_recurrent.rb +1 -0
  23. data/lib/cloud_payments/models/order.rb +1 -0
  24. data/lib/cloud_payments/models/secure3d.rb +1 -0
  25. data/lib/cloud_payments/models/subscription.rb +1 -0
  26. data/lib/cloud_payments/models/transaction.rb +1 -0
  27. data/lib/cloud_payments/namespaces.rb +1 -0
  28. data/lib/cloud_payments/namespaces/base.rb +1 -0
  29. data/lib/cloud_payments/namespaces/cards.rb +1 -0
  30. data/lib/cloud_payments/namespaces/orders.rb +1 -0
  31. data/lib/cloud_payments/namespaces/payments.rb +11 -0
  32. data/lib/cloud_payments/namespaces/subscriptions.rb +1 -0
  33. data/lib/cloud_payments/namespaces/tokens.rb +1 -0
  34. data/lib/cloud_payments/version.rb +2 -1
  35. data/lib/cloud_payments/webhooks.rb +1 -0
  36. data/spec/cloud_payments/client/response_spec.rb +3 -1
  37. data/spec/cloud_payments/client/serializer/multi_json_spec.rb +1 -0
  38. data/spec/cloud_payments/client_spec.rb +1 -0
  39. data/spec/cloud_payments/models/order_spec.rb +1 -0
  40. data/spec/cloud_payments/models/secure3d_spec.rb +1 -0
  41. data/spec/cloud_payments/models/subscription_spec.rb +1 -0
  42. data/spec/cloud_payments/models/transaction_spec.rb +1 -0
  43. data/spec/cloud_payments/namespaces/base_spec.rb +1 -0
  44. data/spec/cloud_payments/namespaces/cards_spec.rb +1 -0
  45. data/spec/cloud_payments/namespaces/orders_spec.rb +1 -0
  46. data/spec/cloud_payments/namespaces/payments_spec.rb +113 -0
  47. data/spec/cloud_payments/namespaces/subscriptions_spec.rb +1 -0
  48. data/spec/cloud_payments/namespaces/tokens_spec.rb +1 -0
  49. data/spec/cloud_payments/namespaces_spec.rb +1 -0
  50. data/spec/cloud_payments/webhooks_spec.rb +1 -0
  51. data/spec/cloud_payments_spec.rb +1 -0
  52. data/spec/fixtures/apis/payments/find/failed.yml +45 -0
  53. data/spec/fixtures/apis/payments/find/failed_with_message.yml +6 -0
  54. data/spec/fixtures/apis/payments/find/successful.yml +48 -0
  55. data/spec/fixtures/apis/payments/get/failed.yml +45 -0
  56. data/spec/fixtures/apis/payments/get/failed_with_message.yml +6 -0
  57. data/spec/fixtures/apis/payments/get/successful.yml +48 -0
  58. data/spec/spec_helper.rb +1 -7
  59. data/spec/support/examples.rb +1 -0
  60. data/spec/support/helpers.rb +1 -0
  61. metadata +15 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87ad4228e46b088bd3c828392f883daed80b30a9
4
- data.tar.gz: e557846dcc4fce01747d2d852d717560d4d36068
3
+ metadata.gz: ed4e88a861a6e0f61c9758ae8db253faf5479e74
4
+ data.tar.gz: 26b8c758021f249079c5b00d88e62cdf7bc80327
5
5
  SHA512:
6
- metadata.gz: f6d77521d6995902f1f6692c4f39faa2ac84c0daffe44d3c57c80e2209b6d37426ab2791158a536d8023706c15170769af00d1f7dbb8d9eac71b89e486266b51
7
- data.tar.gz: d6c183255aa997ec093fe8ff4b745ed5079e5f85926c350c9e17876689589d29bfb9938da0c3bb8b024017cd03306771a019bc48c25540020fbf49c2c50e5499
6
+ metadata.gz: 1556658db7e02a39c840876f9017218182a853b92fe590fb7ed0ca793a20784b81c917ca959e72b565d8df616ed1354cd91e21f921ac5a82b4cd32be64f76dc2
7
+ data.tar.gz: 4a1c1a70e208bc95d3c3bfaf07219309c8e0171912ca0267a18e47667112c8cadf67ae4809ab723348fb1351029d3fd9a8c9bca53e7271b3eb5eaa1cf862abe1
data/.travis.yml CHANGED
@@ -2,8 +2,6 @@ language: ruby
2
2
  cache: bundler
3
3
  script: bundle exec rspec
4
4
  before_install: gem install bundler
5
- env:
6
- - CODECLIMATE_REPO_TOKEN=8e9b89269d9aafc2dec2706a43825201de496b743505d7a7666068f7b22b07d
7
5
  rvm:
8
6
  - '2.2'
9
7
  - '2.3'
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in cloud_payments.gemspec
@@ -7,4 +8,3 @@ gem 'oj'
7
8
  gem 'pry'
8
9
  gem 'rack'
9
10
  gem 'webmock'
10
- gem "codeclimate-test-reporter", group: :test, require: nil
data/README.md CHANGED
@@ -3,8 +3,6 @@
3
3
  CloudPayments ruby client (http://cloudpayments.eu/Docs/Integration)
4
4
 
5
5
  [![Build Status](https://travis-ci.org/undr/cloud_payments.svg)](https://travis-ci.org/undr/cloud_payments)
6
- [![Code Climate](https://codeclimate.com/github/undr/cloud_payments/badges/gpa.svg)](https://codeclimate.com/github/undr/cloud_payments)
7
- [![Test Coverage](https://codeclimate.com/github/undr/cloud_payments/badges/coverage.svg)](https://codeclimate.com/github/undr/cloud_payments)
8
6
 
9
7
  ## Installation
10
8
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rspec/core/rake_task'
3
4
 
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'cloud_payments/version'
data/config.ru CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
3
  require 'cloud_payments'
3
4
  require 'rack'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'date'
2
3
  require 'hashie'
3
4
  require 'faraday'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cloud_payments/client/errors'
2
3
  require 'cloud_payments/client/gateway_errors'
3
4
  require 'cloud_payments/client/response'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Client
3
4
  class Error < StandardError; end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Client
3
4
  class ReasonedGatewayError < StandardError; end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Client
3
4
  class Response
@@ -5,7 +6,7 @@ module CloudPayments
5
6
 
6
7
  def initialize(status, body, headers = {})
7
8
  @status, @origin_body, @headers = status, body, headers
8
- @origin_body = body.force_encoding('UTF-8') if body.respond_to?(:force_encoding)
9
+ @origin_body = body.dup.force_encoding('UTF-8') if body.respond_to?(:force_encoding)
9
10
  end
10
11
 
11
12
  def body
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cloud_payments/client/serializer/base'
2
3
  require 'cloud_payments/client/serializer/multi_json'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Client
3
4
  module Serializer
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Client
3
4
  module Serializer
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Config
3
4
  attr_accessor :connection_options, :serializer, :log, :public_key, :secret_key, :host, :raise_banking_errors
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cloud_payments/models/model'
2
3
  require 'cloud_payments/models/like_subscription'
3
4
  require 'cloud_payments/models/secure3d'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  module LikeSubscription
3
4
  ACTIVE = 'Active'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bigdecimal'
2
3
  require 'bigdecimal/util'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  # @see https://cloudpayments.ru/Docs/Notifications#fail CloudPayments API
3
4
  class OnFail < Model
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class OnPay < Model
3
4
  property :id, from: :transaction_id, required: true
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class OnRecurrent < Model
3
4
  property :id, required: true
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Order < Model
3
4
  property :id, required: true
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Secure3D < Model
3
4
  property :transaction_id, required: true
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Subscription < Model
3
4
  include LikeSubscription
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  class Transaction < Model
3
4
  AWAITING_AUTHENTICATION = 'AwaitingAuthentication'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cloud_payments/namespaces/base'
2
3
  require 'cloud_payments/namespaces/cards'
3
4
  require 'cloud_payments/namespaces/tokens'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  module Namespaces
3
4
  class Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  module Namespaces
3
4
  class Cards < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  module Namespaces
3
4
  class Orders < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  module Namespaces
3
4
  class Payments < Base
@@ -27,6 +28,16 @@ module CloudPayments
27
28
  response = request(:post3ds, transaction_id: id, pa_res: pa_res)
28
29
  Transaction.new(response[:model])
29
30
  end
31
+
32
+ def get(id)
33
+ response = request(:get, transaction_id: id)
34
+ Transaction.new(response[:model])
35
+ end
36
+
37
+ def find(invoice_id)
38
+ response = request(:find, invoice_id: invoice_id)
39
+ Transaction.new(response[:model])
40
+ end
30
41
  end
31
42
  end
32
43
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  module Namespaces
3
4
  class Subscriptions < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
3
  module Namespaces
3
4
  class Tokens < Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CloudPayments
2
- VERSION = '0.0.4'
3
+ VERSION = '0.0.6'
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'openssl'
2
3
  require 'base64'
3
4
 
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Client::Response do
4
5
  let(:status){ 200 }
5
- let(:body){ '{"Model":{"Id":123,"CurrencyCode":"RUB","Amount":120},"Success":true}' }
6
+ let(:body){ '{"Model":{"Id":123,"CurrencyCode":"RUB","Amount":120},"Success":true}'.dup.force_encoding('CP1251').freeze }
6
7
  let(:headers){ { 'content-type' => 'application/json' } }
7
8
 
8
9
  subject{ CloudPayments::Client::Response.new(status, body, headers) }
@@ -13,6 +14,7 @@ describe CloudPayments::Client::Response do
13
14
  context 'wnen content type does not match /json/' do
14
15
  let(:headers){ { 'content-type' => 'text/plain' } }
15
16
  specify{ expect(subject.body).to eq(body) }
17
+ specify{ expect(subject.body.encoding.name).to eq('UTF-8') }
16
18
  end
17
19
  end
18
20
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Client::Serializer::MultiJson do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Client do
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
+ # frozen_string_literal: true
3
4
  require 'spec_helper'
4
5
 
5
6
  describe CloudPayments::Order do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Secure3D do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Subscription do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Transaction do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class TestNamespace < CloudPayments::Namespaces::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Namespaces::Cards do
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
+ # frozen_string_literal: true
3
4
  require 'spec_helper'
4
5
 
5
6
  describe CloudPayments::Namespaces::Orders do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Namespaces::Payments do
@@ -93,4 +94,116 @@ describe CloudPayments::Namespaces::Payments do
93
94
  end
94
95
  end
95
96
  end
97
+
98
+ describe '#get' do
99
+ let(:transaction_id) { 12345 }
100
+
101
+ context 'config.raise_banking_errors = false' do
102
+ before { CloudPayments.config.raise_banking_errors = false }
103
+
104
+ context 'transaction not found' do
105
+ before{ stub_api_request('payments/get/failed_with_message').perform }
106
+ specify{ expect{subject.get(transaction_id)}.to raise_error(CloudPayments::Client::GatewayError, 'Not found') }
107
+ end
108
+
109
+ context 'transaction is failed' do
110
+ before{ stub_api_request('payments/get/failed').perform }
111
+ specify{ expect(subject.get(transaction_id)).to be_instance_of(CloudPayments::Transaction) }
112
+ specify{ expect(subject.get(transaction_id)).not_to be_required_secure3d }
113
+ specify{ expect(subject.get(transaction_id)).to be_declined }
114
+ specify{ expect(subject.get(transaction_id).id).to eq(transaction_id) }
115
+ specify{ expect(subject.get(transaction_id).reason).to eq('InsufficientFunds') }
116
+ end
117
+
118
+ context 'transaction is successful' do
119
+ before{ stub_api_request('payments/get/successful').perform }
120
+ specify{ expect(subject.get(transaction_id)).to be_instance_of(CloudPayments::Transaction) }
121
+ specify{ expect(subject.get(transaction_id)).not_to be_required_secure3d }
122
+ specify{ expect(subject.get(transaction_id)).to be_completed }
123
+ specify{ expect(subject.get(transaction_id).id).to eq(transaction_id) }
124
+ specify{ expect(subject.get(transaction_id).reason).to eq('Approved') }
125
+ end
126
+ end
127
+
128
+ context 'config.raise_banking_errors = true' do
129
+ before { CloudPayments.config.raise_banking_errors = true}
130
+
131
+ context 'transaction not found' do
132
+ before{ stub_api_request('payments/get/failed_with_message').perform }
133
+ specify{ expect{subject.get(transaction_id)}.to raise_error(CloudPayments::Client::GatewayError, 'Not found') }
134
+ end
135
+
136
+ context 'transaction is failed' do
137
+ before{ stub_api_request('payments/get/failed').perform }
138
+ specify{ expect{subject.get(transaction_id)}.to raise_error(CloudPayments::Client::GatewayErrors::InsufficientFunds) }
139
+ end
140
+
141
+ context 'transaction is successful' do
142
+ before{ stub_api_request('payments/get/successful').perform }
143
+ specify{ expect{subject.get(transaction_id)}.to_not raise_error }
144
+ specify{ expect(subject.get(transaction_id)).to be_instance_of(CloudPayments::Transaction) }
145
+ specify{ expect(subject.get(transaction_id)).not_to be_required_secure3d }
146
+ specify{ expect(subject.get(transaction_id)).to be_completed }
147
+ specify{ expect(subject.get(transaction_id).id).to eq(transaction_id) }
148
+ specify{ expect(subject.get(transaction_id).reason).to eq('Approved') }
149
+ end
150
+ end
151
+ end
152
+
153
+ describe '#find' do
154
+ let(:invoice_id) { '1234567' }
155
+
156
+ context 'config.raise_banking_errors = false' do
157
+ before { CloudPayments.config.raise_banking_errors = false }
158
+
159
+ context 'payment is not found' do
160
+ before{ stub_api_request('payments/find/failed_with_message').perform }
161
+ specify{ expect{subject.find(invoice_id)}.to raise_error(CloudPayments::Client::GatewayError, 'Not found') }
162
+ end
163
+
164
+ context 'payment is failed' do
165
+ before{ stub_api_request('payments/find/failed').perform }
166
+ specify{ expect(subject.find(invoice_id)).to be_instance_of(CloudPayments::Transaction) }
167
+ specify{ expect(subject.find(invoice_id)).not_to be_required_secure3d }
168
+ specify{ expect(subject.find(invoice_id)).to be_declined }
169
+ specify{ expect(subject.find(invoice_id).id).to eq(12345) }
170
+ specify{ expect(subject.find(invoice_id).invoice_id).to eq(invoice_id) }
171
+ specify{ expect(subject.find(invoice_id).reason).to eq('InsufficientFunds') }
172
+ end
173
+
174
+ context 'transaction is successful' do
175
+ before{ stub_api_request('payments/find/successful').perform }
176
+ specify{ expect(subject.find(invoice_id)).to be_instance_of(CloudPayments::Transaction) }
177
+ specify{ expect(subject.find(invoice_id)).not_to be_required_secure3d }
178
+ specify{ expect(subject.find(invoice_id)).to be_completed }
179
+ specify{ expect(subject.find(invoice_id).id).to eq(12345) }
180
+ specify{ expect(subject.find(invoice_id).invoice_id).to eq(invoice_id) }
181
+ specify{ expect(subject.find(invoice_id).reason).to eq('Approved') }
182
+ end
183
+ end
184
+
185
+ context 'config.raise_banking_errors = true' do
186
+ before { CloudPayments.config.raise_banking_errors = true}
187
+
188
+ context 'payment is not found' do
189
+ before{ stub_api_request('payments/find/failed_with_message').perform }
190
+ specify{ expect{subject.find(invoice_id)}.to raise_error(CloudPayments::Client::GatewayError, 'Not found') }
191
+ end
192
+
193
+ context 'payment is failed' do
194
+ before{ stub_api_request('payments/find/failed').perform }
195
+ specify{ expect{subject.find(invoice_id)}.to raise_error(CloudPayments::Client::GatewayErrors::InsufficientFunds) }
196
+ end
197
+
198
+ context 'transaction is successful' do
199
+ before{ stub_api_request('payments/find/successful').perform }
200
+ specify{ expect(subject.find(invoice_id)).to be_instance_of(CloudPayments::Transaction) }
201
+ specify{ expect(subject.find(invoice_id)).not_to be_required_secure3d }
202
+ specify{ expect(subject.find(invoice_id)).to be_completed }
203
+ specify{ expect(subject.find(invoice_id).id).to eq(12345) }
204
+ specify{ expect(subject.find(invoice_id).invoice_id).to eq(invoice_id) }
205
+ specify{ expect(subject.find(invoice_id).reason).to eq('Approved') }
206
+ end
207
+ end
208
+ end
96
209
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments::Namespaces::Subscriptions do
@@ -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
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
+ # frozen_string_literal: true
3
4
  require 'spec_helper'
4
5
 
5
6
  describe CloudPayments::Webhooks do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe CloudPayments do
@@ -0,0 +1,45 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/find'
4
+ :body: '{"InvoiceId":"1234567"}'
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,6 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/find'
4
+ :body: '{"InvoiceId":"1234567"}'
5
+ :response:
6
+ :body: '{"Success":false,"Message":"Not found"}'
@@ -0,0 +1,48 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/find'
4
+ :body: '{"InvoiceId":"1234567"}'
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,45 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/get'
4
+ :body: '{"TransactionId":12345}'
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,6 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/get'
4
+ :body: '{"TransactionId":12345}'
5
+ :response:
6
+ :body: '{"Success":false,"Message":"Not found"}'
@@ -0,0 +1,48 @@
1
+ ---
2
+ :request:
3
+ :url: '/payments/get'
4
+ :body: '{"TransactionId":12345}'
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
+ }
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,6 @@
1
+ # frozen_string_literal: true
1
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
3
 
3
- if ENV['CODECLIMATE_REPO_TOKEN']
4
- require "codeclimate-test-reporter"
5
- CodeClimate::TestReporter.start
6
- end
7
-
8
4
  require 'bundler'
9
5
  Bundler.require(:default, :test)
10
6
 
@@ -26,6 +22,4 @@ end
26
22
  RSpec.configure do |config|
27
23
  config.mock_with :rspec
28
24
  config.include CloudPayments::RSpec::Helpers
29
-
30
- config.after(:suite){ WebMock.allow_net_connect! }
31
25
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.shared_examples :not_raise_without_attribute do |key, method = nil|
2
3
  method = key unless method
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'yaml'
2
3
 
3
4
  module CloudPayments
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_payments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - undr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-26 00:00:00.000000000 Z
11
+ date: 2017-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -150,6 +150,12 @@ files:
150
150
  - spec/fixtures/apis/payments/confirm/failed.yml
151
151
  - spec/fixtures/apis/payments/confirm/failed_with_message.yml
152
152
  - spec/fixtures/apis/payments/confirm/successful.yml
153
+ - spec/fixtures/apis/payments/find/failed.yml
154
+ - spec/fixtures/apis/payments/find/failed_with_message.yml
155
+ - spec/fixtures/apis/payments/find/successful.yml
156
+ - spec/fixtures/apis/payments/get/failed.yml
157
+ - spec/fixtures/apis/payments/get/failed_with_message.yml
158
+ - spec/fixtures/apis/payments/get/successful.yml
153
159
  - spec/fixtures/apis/payments/post3ds/failed.yml
154
160
  - spec/fixtures/apis/payments/post3ds/successful.yml
155
161
  - spec/fixtures/apis/payments/refund/failed.yml
@@ -192,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
198
  version: '0'
193
199
  requirements: []
194
200
  rubyforge_project:
195
- rubygems_version: 2.4.8
201
+ rubygems_version: 2.6.11
196
202
  signing_key:
197
203
  specification_version: 4
198
204
  summary: CloudPayments ruby client
@@ -223,6 +229,12 @@ test_files:
223
229
  - spec/fixtures/apis/payments/confirm/failed.yml
224
230
  - spec/fixtures/apis/payments/confirm/failed_with_message.yml
225
231
  - spec/fixtures/apis/payments/confirm/successful.yml
232
+ - spec/fixtures/apis/payments/find/failed.yml
233
+ - spec/fixtures/apis/payments/find/failed_with_message.yml
234
+ - spec/fixtures/apis/payments/find/successful.yml
235
+ - spec/fixtures/apis/payments/get/failed.yml
236
+ - spec/fixtures/apis/payments/get/failed_with_message.yml
237
+ - spec/fixtures/apis/payments/get/successful.yml
226
238
  - spec/fixtures/apis/payments/post3ds/failed.yml
227
239
  - spec/fixtures/apis/payments/post3ds/successful.yml
228
240
  - spec/fixtures/apis/payments/refund/failed.yml