upay 0.0.1

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.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +3 -0
  3. data/.gitignore +16 -0
  4. data/.rspec +3 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +21 -0
  8. data/Gemfile +6 -0
  9. data/Guardfile +70 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +39 -0
  12. data/Rakefile +11 -0
  13. data/examples/capture_and_authorize.rb +90 -0
  14. data/examples/get_a_customer.rb +14 -0
  15. data/lib/upay/address/address.rb +53 -0
  16. data/lib/upay/address/billing_address.rb +13 -0
  17. data/lib/upay/address/shipping_address.rb +13 -0
  18. data/lib/upay/configure.rb +28 -0
  19. data/lib/upay/credit_card.rb +131 -0
  20. data/lib/upay/customer.rb +161 -0
  21. data/lib/upay/order.rb +56 -0
  22. data/lib/upay/payment.rb +15 -0
  23. data/lib/upay/people/buyer.rb +33 -0
  24. data/lib/upay/people/payer.rb +30 -0
  25. data/lib/upay/people/person.rb +37 -0
  26. data/lib/upay/plan.rb +145 -0
  27. data/lib/upay/report.rb +22 -0
  28. data/lib/upay/requestor.rb +90 -0
  29. data/lib/upay/signature.rb +26 -0
  30. data/lib/upay/subscription.rb +94 -0
  31. data/lib/upay/token.rb +98 -0
  32. data/lib/upay/transaction.rb +137 -0
  33. data/lib/upay/version.rb +3 -0
  34. data/lib/upay.rb +86 -0
  35. data/spec/factories/address.rb +36 -0
  36. data/spec/factories/credit_card.rb +22 -0
  37. data/spec/factories/customer.rb +12 -0
  38. data/spec/factories/order.rb +13 -0
  39. data/spec/factories/people.rb +29 -0
  40. data/spec/factories/plan.rb +26 -0
  41. data/spec/factories/token.rb +18 -0
  42. data/spec/factories/transaction.rb +16 -0
  43. data/spec/lib/upay/address/address_spec.rb +34 -0
  44. data/spec/lib/upay/address/billing_address_spec.rb +34 -0
  45. data/spec/lib/upay/address/shipping_address_spec.rb +34 -0
  46. data/spec/lib/upay/credit_card_spec.rb +39 -0
  47. data/spec/lib/upay/customer_spec.rb +18 -0
  48. data/spec/lib/upay/order_spec.rb +29 -0
  49. data/spec/lib/upay/people/buyer_spec.rb +19 -0
  50. data/spec/lib/upay/people/payer_spec.rb +19 -0
  51. data/spec/lib/upay/people/person_spec.rb +19 -0
  52. data/spec/lib/upay/plan_spec.rb +54 -0
  53. data/spec/lib/upay/token_spec.rb +33 -0
  54. data/spec/lib/upay/transaction_spec.rb +39 -0
  55. data/spec/lib/upay_spec.rb +5 -0
  56. data/spec/spec_helper.rb +123 -0
  57. data/spec/support/factory_girl.rb +5 -0
  58. data/upay.gemspec +47 -0
  59. metadata +361 -0
@@ -0,0 +1,34 @@
1
+ # spec/models/shipping_address.rb
2
+ require 'spec_helper'
3
+
4
+ describe Upay::Address::ShippingAddress do
5
+ it "has a valid factory" do
6
+ ship_address = FactoryGirl.build(:shipping_address)
7
+ expect(ship_address).to be_valid
8
+ end
9
+
10
+ it "is invalid without a street1" do
11
+ ship_address = FactoryGirl.build(:shipping_address, street1: nil)
12
+ expect(ship_address).to_not be_valid
13
+ end
14
+
15
+ it "is invalid without a city" do
16
+ ship_address = FactoryGirl.build(:shipping_address, city: nil);
17
+ expect(ship_address).to_not be_valid
18
+ end
19
+
20
+ it "is invalid without a state" do
21
+ ship_address = FactoryGirl.build(:shipping_address, state: nil);
22
+ expect(ship_address).to_not be_valid
23
+ end
24
+
25
+ it "is invalid without a country" do
26
+ ship_address = FactoryGirl.build(:shipping_address, country: nil);
27
+ expect(ship_address).to_not be_valid
28
+ end
29
+
30
+ it "is invalid without a postalCode" do
31
+ ship_address = FactoryGirl.build(:shipping_address, postalCode: nil);
32
+ expect(ship_address).to_not be_valid
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'upay'
3
+
4
+ describe Upay::CreditCard do
5
+ it "has a valid factory" do
6
+ customer = FactoryGirl.build(:credit_card)
7
+ expect(customer).to be_valid
8
+ end
9
+
10
+ it "is invalid without a name" do
11
+ customer = FactoryGirl.build(:credit_card, name: nil)
12
+ expect(customer).not_to be_valid
13
+ end
14
+
15
+ it "is invalid without a document" do
16
+ customer = FactoryGirl.build(:credit_card, document: nil)
17
+ expect(customer).not_to be_valid
18
+ end
19
+
20
+ it "is invalid without a number" do
21
+ customer = FactoryGirl.build(:credit_card, number: nil)
22
+ expect(customer).not_to be_valid
23
+ end
24
+
25
+ it "is invalid without a expMonth" do
26
+ customer = FactoryGirl.build(:credit_card, expMonth: nil)
27
+ expect(customer).not_to be_valid
28
+ end
29
+
30
+ it "is invalid without a expYear" do
31
+ customer = FactoryGirl.build(:credit_card, expYear: nil)
32
+ expect(customer).not_to be_valid
33
+ end
34
+
35
+ it "is invalid without a type" do
36
+ customer = FactoryGirl.build(:credit_card, type: nil)
37
+ expect(customer).not_to be_valid
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upay::Customer do
4
+ it "has a valid factory" do
5
+ customer = FactoryGirl.build(:customer)
6
+ expect(customer).to be_valid
7
+ end
8
+
9
+ it "is invalid without a fullName" do
10
+ customer = FactoryGirl.build(:customer, fullName: nil)
11
+ expect(customer).not_to be_valid
12
+ end
13
+
14
+ it "is invalid without a email" do
15
+ customer = FactoryGirl.build(:customer, email: nil)
16
+ expect(customer).not_to be_valid
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upay::Order do
4
+ it "has a valid factory" do
5
+ ord = FactoryGirl.build(:order)
6
+ expect(ord).to be_valid
7
+ end
8
+
9
+ it "is invalid without a referenceCode" do
10
+ ord = FactoryGirl.build(:order, referenceCode: nil)
11
+ expect(ord).not_to be_valid
12
+ end
13
+
14
+ it "is invalid without a description" do
15
+ ord = FactoryGirl.build(:order, description: nil)
16
+ expect(ord).not_to be_valid
17
+ end
18
+
19
+ it "is invalid without a signature" do
20
+ ord = FactoryGirl.build(:order, signature: nil)
21
+ expect(ord).not_to be_valid
22
+ end
23
+
24
+ it "is invalid without a buyer" do
25
+ ord = FactoryGirl.build(:order, buyer: {})
26
+ expect(ord).not_to be_valid
27
+ end
28
+ end
29
+
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upay::People::Buyer do
4
+ it "has a valid factory" do
5
+ pep_buyer = FactoryGirl.build(:people_buyer)
6
+ expect(pep_buyer).to be_valid
7
+ end
8
+
9
+ it "is invalid without a fullName" do
10
+ pep_buyer = FactoryGirl.build(:people_buyer, fullName: nil)
11
+ expect(pep_buyer).not_to be_valid
12
+ end
13
+
14
+ it "is invalid without a emailAddress" do
15
+ pep_buyer = FactoryGirl.build(:people_buyer, emailAddress: nil)
16
+ expect(pep_buyer).not_to be_valid
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upay::People::Payer do
4
+ it "has a valid factory" do
5
+ pep_payer = FactoryGirl.build(:people_payer)
6
+ expect(pep_payer).to be_valid
7
+ end
8
+
9
+ it "is invalid without a fullName" do
10
+ pep_payer = FactoryGirl.build(:people_payer, fullName: nil)
11
+ expect(pep_payer).not_to be_valid
12
+ end
13
+
14
+ it "is invalid without a emailAddress" do
15
+ pep_payer = FactoryGirl.build(:people_payer, emailAddress: nil)
16
+ expect(pep_payer).not_to be_valid
17
+ end
18
+
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upay::People::Person do
4
+ it "has a valid factory" do
5
+ pep_person = FactoryGirl.build(:people_person)
6
+ expect(pep_person).to be_valid
7
+ end
8
+
9
+ it "is invalid without a fullName" do
10
+ pep_person = FactoryGirl.build(:people_person, fullName: nil)
11
+ expect(pep_person).not_to be_valid
12
+ end
13
+
14
+ it "is invalid without a emailAddress" do
15
+ pep_person = FactoryGirl.build(:people_person, emailAddress: nil)
16
+ expect(pep_person).not_to be_valid
17
+ end
18
+
19
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+ require 'upay'
3
+
4
+ describe Upay::Plan do
5
+ it "has a valid factory" do
6
+ plan = FactoryGirl.build(:plan)
7
+ expect(plan).to be_valid
8
+ end
9
+
10
+ it "is invalid without a accountId" do
11
+ plan = FactoryGirl.build(:plan, accountId: nil)
12
+ expect(plan).not_to be_valid
13
+ end
14
+
15
+ it "is invalid without a planCode" do
16
+ plan = FactoryGirl.build(:plan, planCode: nil)
17
+ expect(plan).not_to be_valid
18
+ end
19
+
20
+ it "is invalid without a description" do
21
+ plan = FactoryGirl.build(:plan, description: nil)
22
+ expect(plan).not_to be_valid
23
+ end
24
+
25
+ it "is invalid without a interval" do
26
+ plan = FactoryGirl.build(:plan, interval: nil)
27
+ expect(plan).not_to be_valid
28
+ end
29
+
30
+ it "is invalid without a value" do
31
+ plan = FactoryGirl.build(:plan, value: nil)
32
+ expect(plan).not_to be_valid
33
+ end
34
+
35
+ it "is invalid without a currency" do
36
+ plan = FactoryGirl.build(:plan, currency: nil)
37
+ expect(plan).not_to be_valid
38
+ end
39
+
40
+ it "is invalid without a intervalCount" do
41
+ plan = FactoryGirl.build(:plan, intervalCount: nil)
42
+ expect(plan).not_to be_valid
43
+ end
44
+
45
+ it "is invalid without a additionalValues" do
46
+ plan = FactoryGirl.build(:plan, additionalValues: nil)
47
+ expect(plan).not_to be_valid
48
+ end
49
+
50
+ it "is invalid without a trialDays" do
51
+ plan = FactoryGirl.build(:plan, trialDays: nil)
52
+ expect(plan).not_to be_valid
53
+ end
54
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upay::Token do
4
+ it "has a valid factory" do
5
+ tok = FactoryGirl.build(:token)
6
+ expect(tok).to be_valid
7
+ end
8
+
9
+ it "is invalid without a name" do
10
+ tok = FactoryGirl.build(:token, name: nil)
11
+ expect(tok).not_to be_valid
12
+ end
13
+
14
+ it "is invalid without a identificationNumber" do
15
+ tok = FactoryGirl.build(:token, identificationNumber: nil)
16
+ expect(tok).not_to be_valid
17
+ end
18
+
19
+ it "is invalid without a paymentMethod" do
20
+ tok = FactoryGirl.build(:token, paymentMethod: nil)
21
+ expect(tok).not_to be_valid
22
+ end
23
+
24
+ it "is invalid without a number" do
25
+ tok = FactoryGirl.build(:token, number: nil)
26
+ expect(tok).not_to be_valid
27
+ end
28
+
29
+ it "is invalid without a expirationDate" do
30
+ tok = FactoryGirl.build(:token, expirationDate: nil)
31
+ expect(tok).not_to be_valid
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upay::Transaction do
4
+ it "has a valid factory" do
5
+ tran = FactoryGirl.build(:transaction)
6
+ expect(tran).to be_valid
7
+ end
8
+
9
+ it "it is invalid without an order" do
10
+ tran = FactoryGirl.build(:transaction, order: nil)
11
+ expect(tran).not_to be_valid
12
+ end
13
+
14
+ it "it is invalid without a payer" do
15
+ tran = FactoryGirl.build(:transaction, payer: nil)
16
+ expect(tran).not_to be_valid
17
+ end
18
+
19
+ it "is invalid without a creditCardTokenId" do
20
+ tran = FactoryGirl.build(:transaction, creditCardTokenId: nil)
21
+ expect(tran).not_to be_valid
22
+ end
23
+
24
+ it "is invalid without a type" do
25
+ tran = FactoryGirl.build(:transaction, type: nil)
26
+ expect(tran).not_to be_valid
27
+ end
28
+
29
+ it "is invalid without a paymentMethod" do
30
+ tran = FactoryGirl.build(:transaction, paymentMethod: nil)
31
+ expect(tran).not_to be_valid
32
+ end
33
+
34
+ it "is invalid without a paymentCountry" do
35
+ tran = FactoryGirl.build(:transaction, paymentCountry: nil)
36
+ expect(tran).not_to be_valid
37
+ end
38
+
39
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+ require 'pry'
3
+
4
+ describe Upay do
5
+ end
@@ -0,0 +1,123 @@
1
+ #require 'bundler/setup'
2
+ #Bundler.setup
3
+
4
+ ENV['CODECLIMATE_REPO_TOKEN'] = "60aa936375efa981484ef157887d3120eb6d8aaa6ccc7659e3741e3e2fbe1253"
5
+
6
+ require 'upay'
7
+ require 'factory_girl'
8
+
9
+ require 'coveralls'
10
+ require 'simplecov'
11
+ require "codeclimate-test-reporter"
12
+
13
+ Coveralls.wear!
14
+
15
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
16
+ SimpleCov::Formatter::HTMLFormatter,
17
+ Coveralls::SimpleCov::Formatter
18
+ ]
19
+
20
+ SimpleCov.start
21
+
22
+
23
+
24
+ FactoryGirl.find_definitions
25
+
26
+ # This file was generated by the `rspec --init` command. Conventionally, all
27
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
28
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
29
+ # this file to always be loaded, without a need to explicitly require it in any
30
+ # files.
31
+ #
32
+ # Given that it is always loaded, you are encouraged to keep this file as
33
+ # light-weight as possible. Requiring heavyweight dependencies from this file
34
+ # will add to the boot time of your test suite on EVERY test run, even for an
35
+ # individual file that may not need all of that loaded. Instead, consider making
36
+ # a separate helper file that requires the additional dependencies and performs
37
+ # the additional setup, and require it from the spec files that actually need
38
+ # it.
39
+ #
40
+ # The `.rspec` file also contains a few flags that are not defaults but that
41
+ # users commonly want.
42
+ #
43
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
44
+ RSpec.configure do |config|
45
+ config.include FactoryGirl::Syntax::Methods
46
+
47
+ # rspec-expectations config goes here. You can use an alternate
48
+ # assertion/expectation library such as wrong or the stdlib/minitest
49
+ # assertions if you prefer.
50
+ config.expect_with :rspec do |expectations|
51
+ # This option will default to `true` in RSpec 4. It makes the `description`
52
+ # and `failure_message` of custom matchers include text for helper methods
53
+ # defined using `chain`, e.g.:
54
+ # be_bigger_than(2).and_smaller_than(4).description
55
+ # # => "be bigger than 2 and smaller than 4"
56
+ # ...rather than:
57
+ # # => "be bigger than 2"
58
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
59
+ end
60
+
61
+ # rspec-mocks config goes here. You can use an alternate test double
62
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
63
+ config.mock_with :rspec do |mocks|
64
+ # Prevents you from mocking or stubbing a method that does not exist on
65
+ # a real object. This is generally recommended, and will default to
66
+ # `true` in RSpec 4.
67
+ mocks.verify_partial_doubles = true
68
+ end
69
+
70
+ # The settings below are suggested to provide a good initial experience
71
+ # with RSpec, but feel free to customize to your heart's content.
72
+ =begin
73
+ # These two settings work together to allow you to limit a spec run
74
+ # to individual examples or groups you care about by tagging them with
75
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
76
+ # get run.
77
+ config.filter_run :focus
78
+ config.run_all_when_everything_filtered = true
79
+
80
+ # Allows RSpec to persist some state between runs in order to support
81
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
82
+ # you configure your source control system to ignore this file.
83
+ config.example_status_persistence_file_path = "spec/examples.txt"
84
+
85
+ # Limits the available syntax to the non-monkey patched syntax that is
86
+ # recommended. For more details, see:
87
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
88
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
89
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
90
+ config.disable_monkey_patching!
91
+
92
+ # This setting enables warnings. It's recommended, but in some cases may
93
+ # be too noisy due to issues in dependencies.
94
+ config.warnings = true
95
+
96
+ # Many RSpec users commonly either run the entire suite or an individual
97
+ # file, and it's useful to allow more verbose output when running an
98
+ # individual spec file.
99
+ if config.files_to_run.one?
100
+ # Use the documentation formatter for detailed output,
101
+ # unless a formatter has already been configured
102
+ # (e.g. via a command-line flag).
103
+ config.default_formatter = 'doc'
104
+ end
105
+
106
+ # Print the 10 slowest examples and example groups at the
107
+ # end of the spec run, to help surface which specs are running
108
+ # particularly slow.
109
+ config.profile_examples = 10
110
+
111
+ # Run specs in random order to surface order dependencies. If you find an
112
+ # order dependency and want to debug it, you can fix the order by providing
113
+ # the seed, which is printed after each run.
114
+ # --seed 1234
115
+ config.order = :random
116
+
117
+ # Seed global randomization in this process using the `--seed` CLI option.
118
+ # Setting this allows you to use `--seed` to deterministically reproduce
119
+ # test failures related to randomization by passing the same `--seed` value
120
+ # as the one that triggered the failure.
121
+ Kernel.srand config.seed
122
+ =end
123
+ end
@@ -0,0 +1,5 @@
1
+ # RSpec
2
+ # spec/support/factory_girl.rb
3
+ RSpec.configure do |config|
4
+ config.include FactoryGirl::Syntax::Methods
5
+ end
data/upay.gemspec ADDED
@@ -0,0 +1,47 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ $:.push lib
5
+
6
+ require 'upay/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "upay"
10
+ spec.version = Upay::VERSION
11
+
12
+ spec.summary = "uPay"
13
+ spec.description = "A simple payu payment gem"
14
+ spec.authors = ["Gess Gallardo"]
15
+ spec.email = 'hola@gessgallardo.com'
16
+ spec.homepage = 'http://rubygems.org/gems/upay'
17
+ spec.license = "MIT"
18
+
19
+ spec.rubyforge_project = "upay"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0")
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.10"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+
29
+ spec.add_development_dependency "rspec"
30
+ spec.add_development_dependency "rspec-nc"
31
+ spec.add_development_dependency "guard"
32
+ spec.add_development_dependency "guard-rspec"
33
+ spec.add_development_dependency "pry"
34
+ spec.add_development_dependency "pry-remote"
35
+ spec.add_development_dependency "pry-nav"
36
+ spec.add_development_dependency "factory_girl", "~> 4.0"
37
+ spec.add_development_dependency "faker"
38
+ spec.add_development_dependency "codeclimate-test-reporter"
39
+ spec.add_development_dependency "coveralls"
40
+ spec.add_development_dependency "simplecov"
41
+
42
+
43
+ spec.add_runtime_dependency "faraday"
44
+ spec.add_runtime_dependency "faraday_middleware"
45
+ spec.add_runtime_dependency "veto"
46
+
47
+ end