tpaga_service 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1188de672e27642b768dbd6903e48a69cb10881b4c92e85d14cf59fa8cd2056e
4
- data.tar.gz: 11cb086a4a5680dc8f26241f5368a8a08c1ab175c3071c194b111bbb40e3229b
3
+ metadata.gz: 23055d37c2be0cce1378eab775f17282289274092bf80bcf5e6a8463f507c597
4
+ data.tar.gz: d12c417cdd5b49d595f7c4f6871ca86d7630784bdcf74f5ba74c003aca040028
5
5
  SHA512:
6
- metadata.gz: c1c90d5c4bab8e23b03f0674f0bc7e729614c40e5909a7a399e187a8431e432d4418ce021e675540ac198d99c897235c181c00a1deaecd42181f17559f860d28
7
- data.tar.gz: e83ceebc285ef9385df0e98f8624c0fedece0d4173d6a5a420b096c2eb0c7944cb277467f026174b986a037ac08cbd96d0f55453b7119f99f968dea36a1b71b8
6
+ metadata.gz: 2cb315bd268e40daac245cc7a6433e2767a1a40e09e2c9d9eb53d970115b4216fdfbb18d35037781d60e4c152d31bcf09ccd4e2e64aed800be76fd4466498349
7
+ data.tar.gz: 17074244c08657ecb5eec2941f69c3b3a6b06bda5aa084ff8c71c263e2dc35d2edad53bcc071a579fd4b4f06dccf5ea945ff77bd22ae93260cc61aa68cec6c51
data/README.md CHANGED
@@ -9,7 +9,7 @@ Installation
9
9
  To install as a gem in your environment type in your console:
10
10
 
11
11
  ```sh
12
- gem install tpaga-service
12
+ gem install tpaga_service
13
13
  ```
14
14
 
15
15
  If you want to use in your rails application, add to your Gemfile:
@@ -30,16 +30,16 @@ Configuration
30
30
  If you are going to run tpaga in a rails environment add to the environment file (ex: `environments/development.rb`) the following lines:
31
31
 
32
32
  ```ruby
33
- config.schema = 'https'
34
- config.host = 'sandbox.tpaga_service.co'
35
- config.base_path = '/api'
36
- config.private_api_key = 'd13fr8n7vhvkuch3lq2ds5qhjnd2pdd2'
37
- config.public_api_key = 'd13fr8n7vhvkuch3lq2ds5qhjnd2pdd2'
33
+ config.schema = 'https'
34
+ config.host = 'sandbox.tpaga.co'
35
+ config.base_path = '/api'
36
+ config.private_api_key = 'd13fr8n7vhvkuch3lq2ds5qhjnd2pddw2'
37
+ config.public_api_key = 'e8tbtu6bdi1jts34h2ktdipschq9heq0a'
38
38
  ```
39
39
 
40
40
  using the respective api key for your TPaga user account.
41
41
 
42
- Next add the the file `tpaga-service.rb` to the rails initializers (ex: `initializers/tpaga-service.rb`) with he following lines:
42
+ Next add the the file `tpaga_service.rb` to the rails initializers (ex: `initializers/tpaga_service.rb`) with he following lines:
43
43
 
44
44
  ```ruby
45
45
  require 'tpaga_service'
@@ -66,13 +66,13 @@ You can create a customer:
66
66
  require 'tpaga_service'
67
67
 
68
68
  # creating a tpaga_service customer object
69
- customer = TpagaService::Customer.new(
69
+ customer = {
70
70
  firstName: 'foo',
71
71
  lastName: 'bar',
72
72
  email: 'foo@bar.com',
73
73
  phone: '0000000000',
74
74
  gender: 'M'
75
- )
75
+ }
76
76
 
77
77
  # call of the api to create the customer in the TPaga account
78
78
  customer = TpagaService::CustomerApi.create_customer customer
@@ -100,20 +100,19 @@ You can add a credit card to existing customers:
100
100
 
101
101
  ```ruby
102
102
  # build the credit card object to create
103
- credit_card_create = TpagaService::CreditCardCreate.new(
103
+ credit_card_create = {
104
104
  primaryAccountNumber: '4111111111111111',
105
105
  expirationMonth: '08',
106
- expirationYear: '2019',
106
+ expirationYear: '2023',
107
107
  cardVerificationCode: '789',
108
- cardHolderName: 'Jon Snow',
109
- billingAddress: TpagaService::BillingAddress.new
110
- )
108
+ cardHolderName: 'Jon Snow'
109
+ }
111
110
 
112
- credit_card = TpagaService::CreditCardApi.add_credit_card 'customer_id', credit_card_create
111
+ credit_card = TpagaService::CreditCardApi.add_credit_card credit_card_create, 'customer_id'
113
112
  # returns a TpagaService::CreditCard object, raise error if not
114
113
  ```
115
114
 
116
- you can get the credit card of customers:
115
+ you can get the credit card of customers (NOT AVAILABLE):
117
116
 
118
117
  ```ruby
119
118
  credit_card = TpagaService::CreditCardApi.get_credit_card_by_id 'customer_id', 'credit_card_id'
@@ -131,7 +130,7 @@ You can charge a credit card:
131
130
 
132
131
  ```ruby
133
132
  # build the charge object
134
- charge = TpagaService::CreditCardCharge.new(
133
+ charge = {
135
134
  amount: 10000,
136
135
  taxAmount: 10000 * 0.1,
137
136
  currency: 'COP',
@@ -139,14 +138,15 @@ charge = TpagaService::CreditCardCharge.new(
139
138
  installments: 1,
140
139
  description: 'A new leash for ghost',
141
140
  creditCard: 'credit_card_id'
142
- )
141
+ }
143
142
 
144
143
  charge = TpagaService::CreditCardApi.add_credit_card_charge charge
145
144
  # return a TpagaService::CreditCardCharge object, raise error if not
146
145
  ```
147
146
 
148
- Retrieve a charge by it's id:
147
+ Retrieve a charge by it's id (NOT AVAILABLE):
149
148
 
150
149
  ```ruby
151
150
  charge = TpagaService::CreditCardApi.get_credit_card_charge_by_id 'charge_id'
152
- # return a TpagaService::CreditCardCharge object, raise error if not
151
+ # return a TpagaService::CreditCardCharge object, raise error if not
152
+ ```
@@ -13,7 +13,7 @@ module TpagaService
13
13
 
14
14
  conn = Faraday.new
15
15
  resp = conn.delete do |req|
16
- req.url "https://#{host}/api/customer/#{customer_id}"
16
+ req.url "https://#{host}/api/customer/#{customer_id}/credit_card/#{credit_card_id}"
17
17
  req.headers['Content-Type'] = 'application/json'
18
18
  req.headers['Authorization'] = 'Basic ' + ["#{api_key}:"].pack('m').delete("\r\n")
19
19
  end
@@ -1,5 +1,5 @@
1
1
  require 'faraday'
2
2
 
3
3
  module TpagaService
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -68,8 +68,20 @@ module TpagaService
68
68
  end
69
69
 
70
70
  class ServerError < StandardError
71
+ attr_reader :status, :message
72
+
73
+ def initialize(status, message)
74
+ @status = status
75
+ @message = message
76
+ end
71
77
  end
72
78
 
73
79
  class ClientError < StandardError
80
+ attr_reader :status, :message
81
+
82
+ def initialize(status, message)
83
+ @status = status
84
+ @message = message
85
+ end
74
86
  end
75
87
  end
@@ -7,8 +7,8 @@ module TpagaService
7
7
  # *+message_error+ : Hash
8
8
  def initialize(code_response, body_response)
9
9
  case code_response
10
- when 500..510 then raise(ServerError, body_response)
11
- when 299..426 then raise(ClientError, body_response)
10
+ when 500..510 then raise ServerError.new(code_response, body_response) #(ServerError, body_response)
11
+ when 299..426 then raise ClientError.new(code_response, body_response) #(ClientError, body_response)
12
12
  end
13
13
  end
14
14
 
@@ -8,10 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = TpagaService::VERSION
9
9
  spec.authors = ["Juan Contreras"]
10
10
  spec.email = ["juan.contreras@packen.co"]
11
-
12
11
  spec.summary = %q{TPaga API Ruby to Integreate with the payment gateway }
13
12
  spec.description = %q{TPaga Payment Gateway API
14
- [Learn about TPaga](https://tpaga_service.co)
13
+ [Learn about TPaga](https://tpaga.co)
15
14
  }
16
15
  spec.homepage = "https://rubygems.org/gems/tpaga_service"
17
16
  spec.license = "MIT"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tpaga_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Contreras
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2020-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: '0'
83
83
  description: |
84
84
  TPaga Payment Gateway API
85
- [Learn about TPaga](https://tpaga_service.co)
85
+ [Learn about TPaga](https://tpaga.co)
86
86
  email:
87
87
  - juan.contreras@packen.co
88
88
  executables: []