openpay 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Gemfile +1 -0
- data/README.md +11 -1
- data/lib/openpay/open_pay_resource.rb +2 -2
- data/lib/openpay/open_pay_resource_factory.rb +2 -2
- data/lib/openpay/openpay_api.rb +3 -2
- data/lib/version.rb +1 -1
- data/openpay.gemspec +1 -1
- data/test/spec/customers_spec.rb +2 -2
- data/test/spec/requesttimeout_spec.rb +38 -0
- data/test/spec_helper.rb +0 -1
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
N2NkZjA0NWIwOGVkNGE4OGE2ZDEyYzAzNjExOGUwMmYwMjA2ZTdlMQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d76a36a8a210880d4d9f915f6034daeb95af848a
|
4
|
+
data.tar.gz: ac4548deb7c79e7e938743f3d8b547c83a24809e
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YWRhMjdjYWJiODIxNjg5NzU0YWM4YWJiOGFiZDNlOGNlNGE0OWNiZWYxMWFl
|
11
|
-
N2JlYmY5NTlmMGI2YjY4ZmIxMzM4ODA0YTgwNzA3MWI0ZDczMzA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
M2RiYzU1NjZmMWMzMzI0ZmRkOGJiYzU2NTc3MzAwODQ1NTljMDEyOWUxNWVj
|
14
|
-
MTZhOGY1Y2MzYWYyMGMzMzFjNGYxOGM1NzE4MGM0NTE4M2JkZjFiZGEyMWI3
|
15
|
-
Yjg2ZDUwZjRlYmMzZjAwOTYwNzhiMGU0NTYxZjFlYjljNzcwNGU=
|
6
|
+
metadata.gz: a16717da2675093422157648ec8d8546effcd32be3ea89671540c08ab3c3b4ca674c500a4d3ed27cf82b3fa981eefe2d83a81b871cdaaf14da04c14dcc680bdc
|
7
|
+
data.tar.gz: 0dc77e62e3789d538509cd007741e0e50a318078ed3cf9fcbe7b5c68dfea718e5457250a91726278db0a7fe3b98feeabfc2a9710bde64b32e73907980daf3802
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
# Openpay-Ruby [![Build Status](https://travis-ci.org/open-pay/openpay-ruby.png?branch=master)](https://travis-ci.org/open-pay/openpay-ruby)
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/openpay.svg)](http://badge.fury.io/rb/openpay)
|
6
|
+
|
5
7
|
##Description
|
6
8
|
|
7
|
-
ruby client for *Openpay api* services (version 1.0.
|
9
|
+
ruby client for *Openpay api* services (version 1.0.5)
|
8
10
|
|
9
11
|
This is a ruby client implementing the payment services for *Openpay* at openpay.mx
|
10
12
|
|
@@ -52,6 +54,14 @@ openpay=OpenpayApi.new(merchant_id,private_key)
|
|
52
54
|
|
53
55
|
#To enable production mode you should pass a third argument as true.
|
54
56
|
#openpay_prod=OpenpayApi.new(merchant_id,private_key,true)
|
57
|
+
|
58
|
+
#This ruby client manages a default timeout of 90 seconds to make the request
|
59
|
+
# to Openpay services, if you need to modify this value, you need to explicitly
|
60
|
+
# define the type of environment and followed by the new value for the timeout.
|
61
|
+
#Syntax:
|
62
|
+
# openpay_prod=OpenpayApi.new(merchant_id,private_key,isProduction,timeout)
|
63
|
+
#Example:
|
64
|
+
# openpay_prod=OpenpayApi.new(merchant_id,private_key,false,30)
|
55
65
|
```
|
56
66
|
|
57
67
|
The openpay factory instance is in charge to generate the required resources through a factory method (create).
|
@@ -5,14 +5,14 @@ class OpenPayResource
|
|
5
5
|
|
6
6
|
attr_accessor :api_hook
|
7
7
|
|
8
|
-
def initialize(merchant_id, private_key, production=false)
|
8
|
+
def initialize(merchant_id, private_key, production=false,timeout=90)
|
9
9
|
@merchant_id=merchant_id
|
10
10
|
@private_key=private_key
|
11
11
|
#assigns base url depending the requested env
|
12
12
|
@base_url=OpenpayApi::base_url(production)
|
13
13
|
@errors=false
|
14
14
|
@production=production
|
15
|
-
@timeout=
|
15
|
+
@timeout=timeout
|
16
16
|
#created resources should have a hook with the base class to keep control of created resources
|
17
17
|
@api_hook=nil
|
18
18
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class OpenPayResourceFactory
|
2
|
-
def OpenPayResourceFactory::create(resource,merchant_id,private_key,production)
|
2
|
+
def OpenPayResourceFactory::create(resource,merchant_id,private_key,production,timeout)
|
3
3
|
begin
|
4
|
-
Object.const_get(resource.capitalize).new(merchant_id,private_key,production)
|
4
|
+
Object.const_get(resource.capitalize).new(merchant_id,private_key,production,timeout)
|
5
5
|
rescue NameError
|
6
6
|
raise OpenpayException.new("Invalid resource name:#{resource}",false)
|
7
7
|
end
|
data/lib/openpay/openpay_api.rb
CHANGED
@@ -17,14 +17,15 @@ class OpenpayApi
|
|
17
17
|
API_PROD='https://api.openpay.mx/v1/'
|
18
18
|
|
19
19
|
#by default testing environment is used
|
20
|
-
def initialize(merchant_id, private_key, production=false)
|
20
|
+
def initialize(merchant_id, private_key, production=false, timeout=90)
|
21
21
|
@merchant_id=merchant_id
|
22
22
|
@private_key=private_key
|
23
23
|
@production=production
|
24
|
+
@timeout=timeout
|
24
25
|
end
|
25
26
|
|
26
27
|
def create(resource)
|
27
|
-
klass=OpenPayResourceFactory::create(resource, @merchant_id, @private_key, @production)
|
28
|
+
klass=OpenPayResourceFactory::create(resource, @merchant_id, @private_key, @production, @timeout)
|
28
29
|
klass.api_hook=self
|
29
30
|
klass
|
30
31
|
end
|
data/lib/version.rb
CHANGED
data/openpay.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = Openpay::VERSION
|
10
10
|
spec.authors = ["ronnie_bermejo"]
|
11
11
|
spec.email = ["ronnie.bermejo.mx@gmail.com"]
|
12
|
-
spec.description = %q{ruby client for Openpay API services (version 1.0.
|
12
|
+
spec.description = %q{ruby client for Openpay API services (version 1.0.5)}
|
13
13
|
spec.summary = %q{ruby api for openpay resources}
|
14
14
|
spec.homepage = "http://openpay.mx/"
|
15
15
|
spec.license = "Apache"
|
data/test/spec/customers_spec.rb
CHANGED
@@ -57,7 +57,7 @@ describe Customers do
|
|
57
57
|
it 'fails when passing invalid information' do
|
58
58
|
|
59
59
|
#check no errors
|
60
|
-
expect(@customers.errors?).to
|
60
|
+
expect(@customers.errors?).to eq false
|
61
61
|
|
62
62
|
#invalid email
|
63
63
|
email='foo'
|
@@ -72,7 +72,7 @@ describe Customers do
|
|
72
72
|
expect(e.description).to match /email no es una direcci.n de correo bien formada/
|
73
73
|
end
|
74
74
|
|
75
|
-
expect(@customers.errors?).to
|
75
|
+
expect(@customers.errors?).to eq true
|
76
76
|
|
77
77
|
end
|
78
78
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe Bankaccounts do
|
5
|
+
|
6
|
+
#bankaccounts for merchant cannot be created using the api
|
7
|
+
#the merchant bank account should be created using the Openpay dashboard
|
8
|
+
before(:all) do
|
9
|
+
|
10
|
+
@merchant_id='mywvupjjs9xdnryxtplq'
|
11
|
+
@private_key='sk_92b25d3baec149e6b428d81abfe37006'
|
12
|
+
|
13
|
+
@openpay=OpenpayApi.new(@merchant_id, @private_key, false, 30)
|
14
|
+
@bank_accounts=@openpay.create(:bankaccounts)
|
15
|
+
@customers=@openpay.create(:customers)
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.get' do
|
20
|
+
|
21
|
+
it 'get a given bank account for a given customer' do
|
22
|
+
|
23
|
+
customer_hash= FactoryGirl.build(:customer)
|
24
|
+
customer=@customers.create(customer_hash)
|
25
|
+
|
26
|
+
account_hash=FactoryGirl.build(:bank_account)
|
27
|
+
bank=@bank_accounts.create(account_hash, customer['id'])
|
28
|
+
|
29
|
+
bank_account=@bank_accounts.get(customer['id'], bank['id'])
|
30
|
+
expect(bank_account['alias']).to match 'Cuenta principal'
|
31
|
+
@bank_accounts.delete(customer['id'], bank['id'])
|
32
|
+
@customers.delete(customer['id'])
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/test/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronnie_bermejo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -56,31 +56,31 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json_spec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description: ruby client for Openpay API services (version 1.0.
|
83
|
+
description: ruby client for Openpay API services (version 1.0.5)
|
84
84
|
email:
|
85
85
|
- ronnie.bermejo.mx@gmail.com
|
86
86
|
executables: []
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- test/spec/openpayresource_spec.rb
|
147
147
|
- test/spec/payouts_spec.rb
|
148
148
|
- test/spec/plans_spec.rb
|
149
|
+
- test/spec/requesttimeout_spec.rb
|
149
150
|
- test/spec/subscriptions_spec.rb
|
150
151
|
- test/spec/transfers_spec.rb
|
151
152
|
- test/spec/utils/search_params_spec.rb
|
@@ -163,17 +164,17 @@ require_paths:
|
|
163
164
|
- .
|
164
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
165
166
|
requirements:
|
166
|
-
- -
|
167
|
+
- - '>='
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
171
|
requirements:
|
171
|
-
- -
|
172
|
+
- - '>='
|
172
173
|
- !ruby/object:Gem::Version
|
173
174
|
version: '0'
|
174
175
|
requirements: []
|
175
176
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.0.14
|
177
178
|
signing_key:
|
178
179
|
specification_version: 4
|
179
180
|
summary: ruby api for openpay resources
|
@@ -188,8 +189,8 @@ test_files:
|
|
188
189
|
- test/spec/openpayresource_spec.rb
|
189
190
|
- test/spec/payouts_spec.rb
|
190
191
|
- test/spec/plans_spec.rb
|
192
|
+
- test/spec/requesttimeout_spec.rb
|
191
193
|
- test/spec/subscriptions_spec.rb
|
192
194
|
- test/spec/transfers_spec.rb
|
193
195
|
- test/spec/utils/search_params_spec.rb
|
194
196
|
- test/spec_helper.rb
|
195
|
-
has_rdoc:
|