tpaga 0.4.5 → 0.4.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +151 -0
- data/lib/tpaga/models/credit_card_charge.rb +37 -53
- data/lib/tpaga/models/customer.rb +43 -27
- data/lib/tpaga/swagger/version.rb +1 -1
- data/tpaga.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af5043cb38385469f6f4cb3e8f4ade696b981ed7
|
4
|
+
data.tar.gz: 2f1af15f7f22902f3bb5f6798d66d162d7085929
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9549834f094606535f930006174a12a0d8964745696e25e6ea2a1451cf98453fbe60802dbfcd4a24cde862a9c14d203bfe8b6d2d482006995462ff2312c584c0
|
7
|
+
data.tar.gz: 4fe23c9dd476a7cd37aaca8d97223863f28cbe1f87bfee7851253b4f7cb76e7db91bc875f44d1f4a23c1ecbb74b72bf056d9a5f0f62e764ee969f66c5470a0c9
|
data/README.md
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
TPaga ruby
|
2
|
+
===
|
3
|
+
|
4
|
+
TPaga ruby gem provides the functionality to call the multiple services of the TPaga platform.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
---
|
8
|
+
|
9
|
+
To install as a gem in your environment type in your console:
|
10
|
+
|
11
|
+
```sh
|
12
|
+
gem install tpaga
|
13
|
+
```
|
14
|
+
|
15
|
+
If you want to use in your rails application, add to your Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'tpaga'
|
19
|
+
```
|
20
|
+
|
21
|
+
And run from your application directory:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
bundle install
|
25
|
+
```
|
26
|
+
|
27
|
+
Configuration
|
28
|
+
---
|
29
|
+
|
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
|
+
|
32
|
+
```ruby
|
33
|
+
config.tpaga_schema = 'https'
|
34
|
+
config.tpaga_host = 'sandbox.tpaga.co'
|
35
|
+
config.tpaga_base_path = '/api'
|
36
|
+
config.tpaga_api_key = 'd13fr8n7vhvkuch3lq2ds5qhjnd2pdd2'
|
37
|
+
```
|
38
|
+
|
39
|
+
using the respective api key for your TPaga user account.
|
40
|
+
|
41
|
+
Next add the the file `tpaga.rb` to the rails initializers (ex: `initializers/tpaga.rb`) with he following lines:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'tpaga'
|
45
|
+
|
46
|
+
Tpaga::Swagger.configure do |config|
|
47
|
+
config.scheme = Rails.application.config.tpaga_schema
|
48
|
+
config.host = Rails.application.config.tpaga_host
|
49
|
+
config.base_path = Rails.application.config.tpaga_base_path
|
50
|
+
config.api_key = Rails.application.config.tpaga_api_key
|
51
|
+
config.inject_format = false
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
if you are not using rails, just simply initialize the service with the lines in the tpaga initializer before you call any service of the api.
|
56
|
+
|
57
|
+
Managing customers
|
58
|
+
---
|
59
|
+
|
60
|
+
You can create a customer:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# if outside from rails
|
64
|
+
require 'tpaga'
|
65
|
+
|
66
|
+
# creating a tpaga customer object
|
67
|
+
customer = Tpaga::Customer.new(
|
68
|
+
firstName: 'foo',
|
69
|
+
lastName: 'bar',
|
70
|
+
email: 'foo@bar.com',
|
71
|
+
phone: '0000000000',
|
72
|
+
gender: 'M'
|
73
|
+
)
|
74
|
+
|
75
|
+
# call of the service to create the customer in the TPaga account
|
76
|
+
customer = Tpaga::CustomerApi.create_customer customer
|
77
|
+
customer.id # The unique identifier of the customer in the TPaga account
|
78
|
+
# if the request cannot be completed, raise a generic error
|
79
|
+
```
|
80
|
+
|
81
|
+
Get a customer by it's id:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
customer = Tpaga::CustomerApi.get_customer_by_id 'id'
|
85
|
+
# returns a Tpaga::Customer object, raise error if not
|
86
|
+
```
|
87
|
+
|
88
|
+
Delete a customer by it's id:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
response = Tpaga::CustomerApi.delete_customer_by_id 'customer_id'
|
92
|
+
# return nil if success, raise an error if not
|
93
|
+
```
|
94
|
+
Managing credit cards
|
95
|
+
---
|
96
|
+
|
97
|
+
You can add a credit card to existing customers:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
# build the credit card object to create
|
101
|
+
credit_card_create = Tpaga::CreditCardCreate.new(
|
102
|
+
primaryAccountNumber: '4111111111111111',
|
103
|
+
expirationMonth: '08',
|
104
|
+
expirationYear: '2019',
|
105
|
+
cardVerificationCode: '789',
|
106
|
+
cardHolderName: 'Jon Snow',
|
107
|
+
billingAddress: Tpaga::BillingAddress.new
|
108
|
+
)
|
109
|
+
|
110
|
+
credit_card = Tpaga::CreditCardApi.add_credit_card 'customer_id', credit_card_create
|
111
|
+
# returns a Tpaga::CreditCard object, raise error if not
|
112
|
+
```
|
113
|
+
|
114
|
+
you can get the credit card of customers:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
credit_card = Tpaga::CreditCardApi.get_credit_card_by_id 'customer_id', 'credit_card_id'
|
118
|
+
# return a Tpaga::CreditCard object, raise error if not
|
119
|
+
```
|
120
|
+
|
121
|
+
You can delete the credit card of customers:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
Tpaga::CreditCardApi.delete_credit_card_by_id 'customer_id', 'credit_card_id'
|
125
|
+
# return nil if success, raise error if not
|
126
|
+
```
|
127
|
+
|
128
|
+
You can charge a credit card:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
# build the charge object
|
132
|
+
charge = Tpaga::CreditCardCharge.new(
|
133
|
+
amount: 10000,
|
134
|
+
taxAmount: 10000 * 0.1,
|
135
|
+
currency: 'COP',
|
136
|
+
orderId: 'Your identifier for the order',
|
137
|
+
installments: 1,
|
138
|
+
description: 'A new leash for ghost',
|
139
|
+
creditCard: 'credit_card_id'
|
140
|
+
)
|
141
|
+
|
142
|
+
charge = Tpaga::CreditCardApi.add_credit_card_charge charge
|
143
|
+
# return a Tpaga::CreditCardCharge object, raise error if not
|
144
|
+
```
|
145
|
+
|
146
|
+
Retrieve a charge by it's id:
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
charge = Tpaga::CreditCardApi.get_credit_card_charge_by_id 'charge_id'
|
150
|
+
# return a Tpaga::CreditCardCharge object, raise error if not
|
151
|
+
```
|
@@ -1,53 +1,47 @@
|
|
1
1
|
module Tpaga
|
2
|
-
#
|
2
|
+
#
|
3
3
|
class CreditCardCharge < BaseObject
|
4
|
-
attr_accessor :id, :amount, :tax_amount, :currency, :credit_card, :installments, :order_id, :description, :paid, :customer, :payment_transaction, :third_party_id
|
4
|
+
attr_accessor :id, :amount, :tax_amount, :currency, :credit_card, :installments, :order_id, :description, :paid, :customer, :payment_transaction, :third_party_id
|
5
5
|
# attribute mapping from ruby-style variable name to JSON key
|
6
6
|
def self.attribute_map
|
7
7
|
{
|
8
|
-
|
9
|
-
#
|
8
|
+
|
9
|
+
#
|
10
10
|
:'id' => :'id',
|
11
|
-
|
12
|
-
#
|
11
|
+
|
12
|
+
#
|
13
13
|
:'amount' => :'amount',
|
14
|
-
|
15
|
-
#
|
14
|
+
|
15
|
+
#
|
16
16
|
:'tax_amount' => :'taxAmount',
|
17
|
-
|
17
|
+
|
18
18
|
# 3-letter ISO code for currency.
|
19
19
|
:'currency' => :'currency',
|
20
|
-
|
21
|
-
#
|
20
|
+
|
21
|
+
#
|
22
22
|
:'credit_card' => :'creditCard',
|
23
|
-
|
23
|
+
|
24
24
|
# The amount of payments to divide the charge amount.
|
25
25
|
:'installments' => :'installments',
|
26
|
-
|
27
|
-
#
|
26
|
+
|
27
|
+
#
|
28
28
|
:'order_id' => :'orderId',
|
29
|
-
|
30
|
-
#
|
29
|
+
|
30
|
+
#
|
31
31
|
:'description' => :'description',
|
32
32
|
|
33
33
|
#
|
34
34
|
:'third_party_id' => :'thirdPartyId',
|
35
35
|
|
36
|
-
#
|
36
|
+
#
|
37
37
|
:'paid' => :'paid',
|
38
|
-
|
39
|
-
#
|
38
|
+
|
39
|
+
#
|
40
40
|
:'customer' => :'customer',
|
41
|
-
|
42
|
-
#
|
43
|
-
:'payment_transaction' => :'paymentTransaction'
|
44
|
-
|
45
|
-
#
|
46
|
-
:'error_code' => :'errorCode',
|
47
|
-
|
48
|
-
#
|
49
|
-
:'error_message' => :'errorMessage'
|
50
|
-
|
41
|
+
|
42
|
+
#
|
43
|
+
:'payment_transaction' => :'paymentTransaction'
|
44
|
+
|
51
45
|
}
|
52
46
|
end
|
53
47
|
|
@@ -65,10 +59,8 @@ module Tpaga
|
|
65
59
|
:'description' => :'string',
|
66
60
|
:'paid' => :'boolean',
|
67
61
|
:'customer' => :'string',
|
68
|
-
:'payment_transaction' => :'string'
|
69
|
-
|
70
|
-
:'error_message' => :'string'
|
71
|
-
|
62
|
+
:'payment_transaction' => :'string'
|
63
|
+
|
72
64
|
}
|
73
65
|
end
|
74
66
|
|
@@ -78,31 +70,31 @@ module Tpaga
|
|
78
70
|
# convert string to symbol for hash key
|
79
71
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
80
72
|
|
81
|
-
|
73
|
+
|
82
74
|
if attributes[:'id']
|
83
75
|
@id = attributes[:'id']
|
84
76
|
end
|
85
|
-
|
77
|
+
|
86
78
|
if attributes[:'amount']
|
87
79
|
@amount = attributes[:'amount']
|
88
80
|
end
|
89
|
-
|
81
|
+
|
90
82
|
if attributes[:'taxAmount']
|
91
83
|
@tax_amount = attributes[:'taxAmount']
|
92
84
|
end
|
93
|
-
|
85
|
+
|
94
86
|
if attributes[:'currency']
|
95
87
|
@currency = attributes[:'currency']
|
96
88
|
end
|
97
|
-
|
89
|
+
|
98
90
|
if attributes[:'creditCard']
|
99
91
|
@credit_card = attributes[:'creditCard']
|
100
92
|
end
|
101
|
-
|
93
|
+
|
102
94
|
if attributes[:'installments']
|
103
95
|
@installments = attributes[:'installments']
|
104
96
|
end
|
105
|
-
|
97
|
+
|
106
98
|
if attributes[:'orderId']
|
107
99
|
@order_id = attributes[:'orderId']
|
108
100
|
end
|
@@ -110,31 +102,23 @@ module Tpaga
|
|
110
102
|
if attributes[:'thirdPartyId']
|
111
103
|
@third_party_id = attributes[:'thirdPartyId']
|
112
104
|
end
|
113
|
-
|
105
|
+
|
114
106
|
if attributes[:'description']
|
115
107
|
@description = attributes[:'description']
|
116
108
|
end
|
117
|
-
|
109
|
+
|
118
110
|
if attributes[:'paid']
|
119
111
|
@paid = attributes[:'paid']
|
120
112
|
end
|
121
|
-
|
113
|
+
|
122
114
|
if attributes[:'customer']
|
123
115
|
@customer = attributes[:'customer']
|
124
116
|
end
|
125
|
-
|
117
|
+
|
126
118
|
if attributes[:'paymentTransaction']
|
127
119
|
@payment_transaction = attributes[:'paymentTransaction']
|
128
120
|
end
|
129
|
-
|
130
|
-
if attributes[:'errorCode']
|
131
|
-
@error_code = attributes[:'errorCode']
|
132
|
-
end
|
133
|
-
|
134
|
-
if attributes[:'errorMessage']
|
135
|
-
@error_message = attributes[:'errorMessage']
|
136
|
-
end
|
137
|
-
|
121
|
+
|
138
122
|
end
|
139
123
|
end
|
140
124
|
end
|
@@ -1,32 +1,38 @@
|
|
1
1
|
module Tpaga
|
2
|
-
#
|
2
|
+
#
|
3
3
|
class Customer < BaseObject
|
4
|
-
attr_accessor :id, :first_name, :last_name, :email, :gender, :phone, :address
|
4
|
+
attr_accessor :id, :first_name, :last_name, :email, :gender, :phone, :address, :legal_id_number, :merchant_customer_id
|
5
5
|
# attribute mapping from ruby-style variable name to JSON key
|
6
6
|
def self.attribute_map
|
7
7
|
{
|
8
|
-
|
9
|
-
#
|
8
|
+
|
9
|
+
#
|
10
10
|
:'id' => :'id',
|
11
|
-
|
12
|
-
#
|
11
|
+
|
12
|
+
#
|
13
13
|
:'first_name' => :'firstName',
|
14
|
-
|
15
|
-
#
|
14
|
+
|
15
|
+
#
|
16
16
|
:'last_name' => :'lastName',
|
17
|
-
|
18
|
-
#
|
17
|
+
|
18
|
+
#
|
19
19
|
:'email' => :'email',
|
20
|
-
|
21
|
-
#
|
20
|
+
|
21
|
+
#
|
22
22
|
:'gender' => :'gender',
|
23
|
-
|
24
|
-
#
|
23
|
+
|
24
|
+
#
|
25
25
|
:'phone' => :'phone',
|
26
|
-
|
27
|
-
#
|
26
|
+
|
27
|
+
#
|
28
|
+
:'legal_id_number' => :'legalIdNumber',
|
29
|
+
|
30
|
+
#
|
31
|
+
:'merchant_customer_id' => :'merchantCustomerId',
|
32
|
+
|
33
|
+
#
|
28
34
|
:'address' => :'address'
|
29
|
-
|
35
|
+
|
30
36
|
}
|
31
37
|
end
|
32
38
|
|
@@ -39,8 +45,10 @@ module Tpaga
|
|
39
45
|
:'email' => :'string',
|
40
46
|
:'gender' => :'string',
|
41
47
|
:'phone' => :'string',
|
42
|
-
:'
|
43
|
-
|
48
|
+
:'legal_id_number' => :'string',
|
49
|
+
:'merchant_customer_id' => :'string',
|
50
|
+
:'address' => :'Address',
|
51
|
+
|
44
52
|
}
|
45
53
|
end
|
46
54
|
|
@@ -50,35 +58,43 @@ module Tpaga
|
|
50
58
|
# convert string to symbol for hash key
|
51
59
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
52
60
|
|
53
|
-
|
61
|
+
|
54
62
|
if attributes[:'id']
|
55
63
|
@id = attributes[:'id']
|
56
64
|
end
|
57
|
-
|
65
|
+
|
58
66
|
if attributes[:'firstName']
|
59
67
|
@first_name = attributes[:'firstName']
|
60
68
|
end
|
61
|
-
|
69
|
+
|
62
70
|
if attributes[:'lastName']
|
63
71
|
@last_name = attributes[:'lastName']
|
64
72
|
end
|
65
|
-
|
73
|
+
|
66
74
|
if attributes[:'email']
|
67
75
|
@email = attributes[:'email']
|
68
76
|
end
|
69
|
-
|
77
|
+
|
70
78
|
if attributes[:'gender']
|
71
79
|
@gender = attributes[:'gender']
|
72
80
|
end
|
73
|
-
|
81
|
+
|
74
82
|
if attributes[:'phone']
|
75
83
|
@phone = attributes[:'phone']
|
76
84
|
end
|
77
|
-
|
85
|
+
|
86
|
+
if attributes[:'phone']
|
87
|
+
@legal_id_number = attributes[:'legalIdNumber']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes[:'merchant_customer_id']
|
91
|
+
@phone = attributes[:'merchantCustomerId']
|
92
|
+
end
|
93
|
+
|
78
94
|
if attributes[:'address']
|
79
95
|
@address = attributes[:'address']
|
80
96
|
end
|
81
|
-
|
97
|
+
|
82
98
|
end
|
83
99
|
end
|
84
100
|
end
|
data/tpaga.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tpaga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Ortiz V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -82,6 +82,7 @@ executables: []
|
|
82
82
|
extensions: []
|
83
83
|
extra_rdoc_files: []
|
84
84
|
files:
|
85
|
+
- README.md
|
85
86
|
- lib/tpaga.rb
|
86
87
|
- lib/tpaga/api/charge_api.rb
|
87
88
|
- lib/tpaga/api/chargeback_api.rb
|
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
134
|
version: '0'
|
134
135
|
requirements: []
|
135
136
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.2.2
|
137
138
|
signing_key:
|
138
139
|
specification_version: 4
|
139
140
|
summary: TPaga API Ruby Bindings powered by Swagger
|