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.
- checksums.yaml +7 -0
- data/.codeclimate.yml +3 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +21 -0
- data/Gemfile +6 -0
- data/Guardfile +70 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +11 -0
- data/examples/capture_and_authorize.rb +90 -0
- data/examples/get_a_customer.rb +14 -0
- data/lib/upay/address/address.rb +53 -0
- data/lib/upay/address/billing_address.rb +13 -0
- data/lib/upay/address/shipping_address.rb +13 -0
- data/lib/upay/configure.rb +28 -0
- data/lib/upay/credit_card.rb +131 -0
- data/lib/upay/customer.rb +161 -0
- data/lib/upay/order.rb +56 -0
- data/lib/upay/payment.rb +15 -0
- data/lib/upay/people/buyer.rb +33 -0
- data/lib/upay/people/payer.rb +30 -0
- data/lib/upay/people/person.rb +37 -0
- data/lib/upay/plan.rb +145 -0
- data/lib/upay/report.rb +22 -0
- data/lib/upay/requestor.rb +90 -0
- data/lib/upay/signature.rb +26 -0
- data/lib/upay/subscription.rb +94 -0
- data/lib/upay/token.rb +98 -0
- data/lib/upay/transaction.rb +137 -0
- data/lib/upay/version.rb +3 -0
- data/lib/upay.rb +86 -0
- data/spec/factories/address.rb +36 -0
- data/spec/factories/credit_card.rb +22 -0
- data/spec/factories/customer.rb +12 -0
- data/spec/factories/order.rb +13 -0
- data/spec/factories/people.rb +29 -0
- data/spec/factories/plan.rb +26 -0
- data/spec/factories/token.rb +18 -0
- data/spec/factories/transaction.rb +16 -0
- data/spec/lib/upay/address/address_spec.rb +34 -0
- data/spec/lib/upay/address/billing_address_spec.rb +34 -0
- data/spec/lib/upay/address/shipping_address_spec.rb +34 -0
- data/spec/lib/upay/credit_card_spec.rb +39 -0
- data/spec/lib/upay/customer_spec.rb +18 -0
- data/spec/lib/upay/order_spec.rb +29 -0
- data/spec/lib/upay/people/buyer_spec.rb +19 -0
- data/spec/lib/upay/people/payer_spec.rb +19 -0
- data/spec/lib/upay/people/person_spec.rb +19 -0
- data/spec/lib/upay/plan_spec.rb +54 -0
- data/spec/lib/upay/token_spec.rb +33 -0
- data/spec/lib/upay/transaction_spec.rb +39 -0
- data/spec/lib/upay_spec.rb +5 -0
- data/spec/spec_helper.rb +123 -0
- data/spec/support/factory_girl.rb +5 -0
- data/upay.gemspec +47 -0
- metadata +361 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e868dd319211d75a20c3b6c37c2628577a87d99
|
4
|
+
data.tar.gz: b62f71306f1e3dd9a022f702a234c30df2b54e26
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f379d2b47dd87101630229bda7689327b0548c1f62edcfb4ffa7da8995f7201d4504b7f954bd83237e3cf3ae312e1a2acbbc5e9c0781a09e76741473df33dd3
|
7
|
+
data.tar.gz: 2224ce33db0a264f0fd639a47f2fec35725b845bc06c97061c98555c109872751d1c5c802a22e0e76811b745a8a3791c574a26a7a8ba268defb471360e85eca4
|
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
upay
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem update bundler
|
4
|
+
|
5
|
+
cache: bundler
|
6
|
+
|
7
|
+
rvm:
|
8
|
+
- 2.1.2
|
9
|
+
|
10
|
+
script: 'bundle exec rake'
|
11
|
+
|
12
|
+
notifications:
|
13
|
+
email:
|
14
|
+
recipients:
|
15
|
+
- hola@gessgallardo.com
|
16
|
+
on_failure: change
|
17
|
+
on_success: never
|
18
|
+
|
19
|
+
addons:
|
20
|
+
code_climate:
|
21
|
+
repo_token: 60aa936375efa981484ef157887d3120eb6d8aaa6ccc7659e3741e3e2fbe1253
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
70
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Gess Gallardo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Upay
|
2
|
+
|
3
|
+
|
4
|
+
[](https://travis-ci.org/gessgallardo/upay)
|
5
|
+
[](https://codeclimate.com/github/gessgallardo/upay)
|
6
|
+
[](https://coveralls.io/github/gessgallardo/upay?branch=master)
|
7
|
+
[](https://gemnasium.com/gessgallardo/upay)
|
8
|
+
[](https://inch-ci.org/github/gessgallardo/upay.svg?branch=master)
|
9
|
+
|
10
|
+
Upay it's a simple wrapper for make transactions in Payu
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'upay'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install upay
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
TODO: Write usage instructions here
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/gessgallardo/upay/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
# Default directory to look in is `/specs`
|
5
|
+
# Run with `rake spec`
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
11
|
+
task :test => :spec
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "upay"
|
2
|
+
require "faker"
|
3
|
+
require "digest"
|
4
|
+
|
5
|
+
#Configure Upay
|
6
|
+
|
7
|
+
Upay.config do |c|
|
8
|
+
c.api_login = "11959c415b33d0c"
|
9
|
+
c.api_key = "6u39nqhq8ftd0hlvnjfs66eh8c"
|
10
|
+
c.test = true
|
11
|
+
c.lang = "es"
|
12
|
+
c.merchant_id = "500238"
|
13
|
+
c.account_id = "500538"
|
14
|
+
c.notifyUrl = "test.localhome.com/webhook"
|
15
|
+
end
|
16
|
+
|
17
|
+
#Setting up the transaction signature
|
18
|
+
|
19
|
+
product_description = Faker::Commerce.product_name
|
20
|
+
product_value = Faker::Number.number(5).to_i
|
21
|
+
transaction_reference = Faker::Company.duns_number
|
22
|
+
|
23
|
+
signature = Upay::Signature.new({
|
24
|
+
transaction_reference: transaction_reference,
|
25
|
+
transaction_value: product_value,
|
26
|
+
currency: "COP"
|
27
|
+
})
|
28
|
+
|
29
|
+
|
30
|
+
#Creating a Customer
|
31
|
+
|
32
|
+
cus_name = Faker::Name.name
|
33
|
+
cus_email = cus_name.gsub(/[^A-Za-z0-9]/, "").downcase+"@gessgallardo.com"
|
34
|
+
cus_phone = Faker::Number.number(10)
|
35
|
+
cus_dni = Faker::Number.number(10)
|
36
|
+
|
37
|
+
customer = Upay::Customer.new({
|
38
|
+
fullName: cus_name,
|
39
|
+
email: cus_email
|
40
|
+
})
|
41
|
+
|
42
|
+
customer.create
|
43
|
+
|
44
|
+
#Requesting a token
|
45
|
+
|
46
|
+
token = Upay::Token.new({
|
47
|
+
payerId: customer.customerId,
|
48
|
+
name: "APPROVED",
|
49
|
+
paymentMethod: "VISA",
|
50
|
+
number: "4024007182061886",
|
51
|
+
expirationDate: "2017/01",
|
52
|
+
identificationNumber: "1234567890"
|
53
|
+
})
|
54
|
+
|
55
|
+
token.create
|
56
|
+
|
57
|
+
#Capture and authorize transaction
|
58
|
+
|
59
|
+
transaction = Upay::Transaction.new({
|
60
|
+
order: Upay::Order.new({
|
61
|
+
referenceCode: transaction_reference,
|
62
|
+
description: product_description,
|
63
|
+
signature: signature.signature_digest,
|
64
|
+
additionalValues:{
|
65
|
+
TX_VALUE:{
|
66
|
+
value: product_value,
|
67
|
+
currency: "COP"
|
68
|
+
}
|
69
|
+
},
|
70
|
+
buyer: Upay::People::Buyer.new({
|
71
|
+
merchantBuyerId: "1000",
|
72
|
+
fullName: cus_name,
|
73
|
+
emailAddress: cus_email,
|
74
|
+
contactPhone: cus_phone,
|
75
|
+
dniNumber: cus_dni
|
76
|
+
}),
|
77
|
+
}),
|
78
|
+
payer: Upay::People::Payer.new({
|
79
|
+
merchantPayerId: "1000",
|
80
|
+
fullName: cus_name,
|
81
|
+
emailAddress: cus_email
|
82
|
+
}),
|
83
|
+
creditCardTokenId: token.creditCardTokenId,
|
84
|
+
type: "AUTHORIZATION_AND_CAPTURE",
|
85
|
+
paymentMethod: "VISA",
|
86
|
+
paymentCountry: "CO",
|
87
|
+
deviceSessionId: Faker::Internet.password(10, 20)
|
88
|
+
})
|
89
|
+
|
90
|
+
transaction_response = transaction.capture_and_authorize
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "upay"
|
2
|
+
|
3
|
+
Upay.config do |c|
|
4
|
+
c.api_login = "11959c415b33d0c"
|
5
|
+
c.api_key = "6u39nqhq8ftd0hlvnjfs66eh8c"
|
6
|
+
c.test = true
|
7
|
+
c.lang = "es"
|
8
|
+
c.merchant_id = "500238"
|
9
|
+
c.account_id = "500538"
|
10
|
+
c.notifyUrl = "test.localhome.com/webhook"
|
11
|
+
end
|
12
|
+
|
13
|
+
customer = Upay::Customer.new({customerId: "95b99ct2pnc"})
|
14
|
+
customer.show
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Upay
|
2
|
+
module Address
|
3
|
+
class Address
|
4
|
+
def initialize(args = {})
|
5
|
+
args.each do |k,v|
|
6
|
+
instance_variable_set("@#{k}", v)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def street1; @street1 end
|
11
|
+
def street1=(street1 = nil) @street1 = street1; end
|
12
|
+
|
13
|
+
def street2; @street2 end
|
14
|
+
def street2=(street2 = nil) @street2 = street2; end
|
15
|
+
|
16
|
+
def city; @city end
|
17
|
+
def city=(city = nil) @city = city; end
|
18
|
+
|
19
|
+
def state; @state end
|
20
|
+
def state=(state = nil) @state = state; end
|
21
|
+
|
22
|
+
def country; @country end
|
23
|
+
def country=(country = nil) @country = country; end
|
24
|
+
|
25
|
+
def postalCode; @postalCode end
|
26
|
+
def postalCode=(postalCode = nil) @postalCode = postalCode; end
|
27
|
+
|
28
|
+
def phone; @phone end
|
29
|
+
def phone=(phone = nil) @phone = phone; end
|
30
|
+
|
31
|
+
def valid?
|
32
|
+
validator = AddressValidator.new
|
33
|
+
validator.valid?(self)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_hash
|
37
|
+
self.instance_variables.each_with_object({}) { |var,hash| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var)}
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
class AddressValidator
|
43
|
+
include Veto.validator
|
44
|
+
|
45
|
+
validates :street1, presence: true
|
46
|
+
validates :city, presence: true
|
47
|
+
validates :state, presence: true
|
48
|
+
validates :country, presence: true
|
49
|
+
validates :postalCode, presence: true
|
50
|
+
validates :phone, presence: true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Upay
|
2
|
+
class Configure
|
3
|
+
def initialize(args = {})
|
4
|
+
args.each do |k,v|
|
5
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
6
|
+
end
|
7
|
+
setup!
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def setup!
|
13
|
+
if Rails
|
14
|
+
payu_yml = Rails.root.join('config', 'u_pay.yml')
|
15
|
+
payu_config = YAML.load_file(payu_yml)[Rails.env]
|
16
|
+
|
17
|
+
#configuration
|
18
|
+
|
19
|
+
Upay.api_login = payu_config["api_login"]
|
20
|
+
Upay.api_key = payu_config["api_key"]
|
21
|
+
Upay.test = payu_config["test"]
|
22
|
+
Upay.lang = payu_config["lang"]
|
23
|
+
Upay.merchant_id = payu_config["merchant_id"]
|
24
|
+
Upay.account_id = payu_config["account_id"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module Upay
|
2
|
+
class CreditCard
|
3
|
+
|
4
|
+
def initialize(args = {})
|
5
|
+
reload(args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def reload(args = {})
|
9
|
+
args.each do |k,v|
|
10
|
+
case k
|
11
|
+
when "token"
|
12
|
+
instance_variable_set("@#{k}", v)
|
13
|
+
instance_variable_set("@creditCardId", v)
|
14
|
+
when "creditCardId"
|
15
|
+
instance_variable_set("@#{k}", v)
|
16
|
+
instance_variable_set("@token", v)
|
17
|
+
else
|
18
|
+
instance_variable_set("@#{k}", v)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def creditCardId; @creditCardId end
|
24
|
+
def creditCardId=(creditCardId);
|
25
|
+
@creditCardId = creditCardId
|
26
|
+
end
|
27
|
+
|
28
|
+
def name; @name end
|
29
|
+
def name=(name);
|
30
|
+
@name=name;
|
31
|
+
end
|
32
|
+
|
33
|
+
def document; @document end
|
34
|
+
def document=(document);
|
35
|
+
@document = document
|
36
|
+
end
|
37
|
+
|
38
|
+
def number; @number end
|
39
|
+
def number=(number);
|
40
|
+
@number = number
|
41
|
+
end
|
42
|
+
|
43
|
+
def expMonth; @expMonth end
|
44
|
+
def expMonth=(expMonth);
|
45
|
+
@expMonth = expMonth
|
46
|
+
end
|
47
|
+
|
48
|
+
def expYear; @expYear end
|
49
|
+
def expYear=(expYear);
|
50
|
+
@expYear = expYear
|
51
|
+
end
|
52
|
+
|
53
|
+
def type; @type end
|
54
|
+
def type=(type);
|
55
|
+
@type = type
|
56
|
+
end
|
57
|
+
|
58
|
+
def address; @address end
|
59
|
+
def address=(address);
|
60
|
+
@address = address
|
61
|
+
end
|
62
|
+
|
63
|
+
def token; @token end
|
64
|
+
def token=(token);
|
65
|
+
@token = token
|
66
|
+
end
|
67
|
+
|
68
|
+
def valid?
|
69
|
+
validator = CreditCardValidator.new
|
70
|
+
validator.valid?(self)
|
71
|
+
end
|
72
|
+
|
73
|
+
def create(customerID)
|
74
|
+
url = "rest/v4.3/customers/#{customerID}/creditCards"
|
75
|
+
data = {
|
76
|
+
:type => self.type,
|
77
|
+
:expMonth => self.expMonth,
|
78
|
+
:expYear => self.expYear,
|
79
|
+
:name => self.name,
|
80
|
+
:number => self.number
|
81
|
+
}
|
82
|
+
request = Requestor.new.post(url, data)
|
83
|
+
self.creditCardId = request["token"]
|
84
|
+
self.token = request["token"]
|
85
|
+
end
|
86
|
+
|
87
|
+
def update
|
88
|
+
url = "rest/v4.3/creditCards/#{self.creditCardId}"
|
89
|
+
data = {
|
90
|
+
:type => self.type,
|
91
|
+
:expMonth => self.expMonth,
|
92
|
+
:expYear => self.expYear,
|
93
|
+
:name => self.name,
|
94
|
+
:number => self.number
|
95
|
+
}
|
96
|
+
Requestor.new.put(url, data)
|
97
|
+
end
|
98
|
+
|
99
|
+
def show
|
100
|
+
begin
|
101
|
+
unless self.creditCardId.nil?
|
102
|
+
url = "rest/v4.3/creditCards/#{self.creditCardId}"
|
103
|
+
Requestor.new.get(url, {:creditCardId => self.creditCardId})
|
104
|
+
else
|
105
|
+
raise "creditCardId cannot be blank"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def all
|
111
|
+
url = "rest/v4.3/creditCards/"
|
112
|
+
Requestor.new.get(url, {:creditCardId => ""})
|
113
|
+
end
|
114
|
+
|
115
|
+
def delete(customerID, creditCardId)
|
116
|
+
url = "rest/v4.3/customers/#{customerID}/creditCards/#{creditCardId}"
|
117
|
+
Requestor.new.delete(url, {})
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class CreditCardValidator
|
122
|
+
include Veto.validator
|
123
|
+
|
124
|
+
validates :name, presence: true
|
125
|
+
validates :document, presence: true
|
126
|
+
validates :number, presence: true
|
127
|
+
validates :expMonth, presence: true
|
128
|
+
validates :expYear, presence: true
|
129
|
+
validates :type, presence: true
|
130
|
+
end
|
131
|
+
end
|