openpay 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +1 -0
- data/.idea/.rakeTasks +2 -2
- data/.idea/OpenPay.iml +30 -20
- data/.idea/runConfigurations/Run_spec__bankaccounts_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__cards_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__charges_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__customers_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__exceptions_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__fees_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__payouts_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__plans_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__subscriptions_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__transfers_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/all_specs.xml +1 -0
- data/.idea/workspace.xml +484 -268
- data/Gemfile +0 -6
- data/README.md +111 -29
- data/lib/openpay.rb +7 -3
- data/lib/openpay/bankaccounts.rb +10 -11
- data/lib/openpay/cards.rb +12 -14
- data/lib/openpay/charges.rb +38 -14
- data/lib/openpay/customers.rb +73 -67
- data/lib/openpay/errors/openpay_exception_factory.rb +14 -26
- data/lib/openpay/fees.rb +1 -1
- data/lib/openpay/open_pay_resource.rb +77 -77
- data/lib/openpay/open_pay_resource_factory.rb +1 -1
- data/lib/openpay/openpay_api.rb +6 -16
- data/lib/openpay/payouts.rb +13 -17
- data/lib/openpay/plans.rb +1 -7
- data/lib/openpay/subscriptions.rb +21 -29
- data/lib/openpay/transfers.rb +14 -18
- data/lib/openpay/utils/search_params.rb +20 -0
- data/lib/version.rb +1 -2
- data/openpay.gemspec +0 -8
- data/test/Factories.rb +80 -126
- data/test/spec/bankaccounts_spec.rb +55 -61
- data/test/spec/cards_spec.rb +56 -76
- data/test/spec/charges_spec.rb +89 -84
- data/test/spec/customers_spec.rb +37 -47
- data/test/spec/exceptions_spec.rb +4 -21
- data/test/spec/fees_spec.rb +51 -7
- data/test/spec/payouts_spec.rb +102 -65
- data/test/spec/plans_spec.rb +27 -50
- data/test/spec/subscriptions_spec.rb +87 -24
- data/test/spec/transfers_spec.rb +42 -44
- data/test/spec/utils/search_params_spec.rb +36 -0
- data/test/spec_helper.rb +1 -5
- metadata +15 -55
- data/lib/OpenPay/Cards.rb +0 -75
- data/lib/OpenPay/Charges.rb +0 -77
- data/lib/OpenPay/Customers.rb +0 -194
- data/lib/OpenPay/Fees.rb +0 -5
- data/lib/OpenPay/Payouts.rb +0 -59
- data/lib/OpenPay/Plans.rb +0 -23
- data/lib/OpenPay/Subscriptions.rb +0 -58
- data/lib/OpenPay/Transfers.rb +0 -43
- data/lib/OpenPay/bankaccounts.rb +0 -59
- data/lib/OpenPay/errors/openpay_connection_exception.rb +0 -3
- data/lib/OpenPay/errors/openpay_exception.rb +0 -29
- data/lib/OpenPay/errors/openpay_exception_factory.rb +0 -60
- data/lib/OpenPay/errors/openpay_transaction_exception.rb +0 -5
- data/lib/OpenPay/open_pay_resource.rb +0 -242
- data/lib/OpenPay/open_pay_resource_factory.rb +0 -10
- data/lib/OpenPay/openpay_api.rb +0 -58
@@ -1,10 +0,0 @@
|
|
1
|
-
class OpenPayResourceFactory
|
2
|
-
def OpenPayResourceFactory::create(resource,merchant_id,private_key,production)
|
3
|
-
begin
|
4
|
-
Object.const_get(resource.capitalize).new(merchant_id,private_key,production)
|
5
|
-
rescue NameError
|
6
|
-
raise OpenpayException.new("Invalid resource name:#{resource}",false)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
data/lib/OpenPay/openpay_api.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'base64'
|
3
|
-
require 'rest-client'
|
4
|
-
require 'uri'
|
5
|
-
|
6
|
-
require 'openpay/open_pay_resource_factory'
|
7
|
-
require 'errors/openpay_exception'
|
8
|
-
|
9
|
-
LOG= Logger.new(STDOUT)
|
10
|
-
#change to Logger::DEBUG if need trace information
|
11
|
-
#due the nature of the information, we recommend to never use a log file when in debug
|
12
|
-
LOG.level=Logger::ERROR
|
13
|
-
|
14
|
-
class OpenpayApi
|
15
|
-
#API Endpoints
|
16
|
-
API_DEV='https://sandbox-api.openpay.mx/v1/'
|
17
|
-
API_PROD='https://api.openpay.mx/v1/'
|
18
|
-
|
19
|
-
#by default the testing environment is used
|
20
|
-
def initialize(merchant_id, private_key,production=false)
|
21
|
-
@merchant_id=merchant_id
|
22
|
-
@private_key=private_key
|
23
|
-
@production=production
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
# @return [nil]
|
28
|
-
def create(resource)
|
29
|
-
klass=OpenPayResourceFactory::create(resource, @merchant_id,@private_key,@production)
|
30
|
-
#attach api hook to be able to refere to same API instance from created resources
|
31
|
-
#TODO we may move it to the initialize method
|
32
|
-
klass.api_hook=self
|
33
|
-
klass
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
def OpenpayApi::base_url(production)
|
38
|
-
if production
|
39
|
-
API_PROD
|
40
|
-
else
|
41
|
-
API_DEV
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def env
|
47
|
-
if @production
|
48
|
-
:production
|
49
|
-
else
|
50
|
-
:test
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|