braspag-rest 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +81 -0
- data/lib/braspag-rest.rb +2 -1
- data/lib/braspag-rest/customer.rb +0 -2
- data/lib/braspag-rest/fraud_analyses.rb +14 -0
- data/lib/braspag-rest/fraud_analyses/browser.rb +11 -0
- data/lib/braspag-rest/fraud_analyses/cart.rb +13 -0
- data/lib/braspag-rest/fraud_analyses/item.rb +24 -0
- data/lib/braspag-rest/fraud_analyses/leg.rb +8 -0
- data/lib/braspag-rest/fraud_analyses/merchant_defined_field.rb +8 -0
- data/lib/braspag-rest/fraud_analyses/passenger.rb +12 -0
- data/lib/braspag-rest/fraud_analyses/reply_data.rb +17 -0
- data/lib/braspag-rest/fraud_analyses/shipping.rb +9 -0
- data/lib/braspag-rest/fraud_analyses/travel.rb +14 -0
- data/lib/braspag-rest/fraud_analysis.rb +44 -0
- data/lib/braspag-rest/hashie/iutrash.rb +19 -6
- data/lib/braspag-rest/payment.rb +16 -1
- data/lib/braspag-rest/request.rb +0 -1
- data/lib/braspag-rest/version.rb +1 -1
- metadata +14 -4
- data/lib/braspag-rest/address.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af51da75eacd0111305201619309a0526ef5947c
|
4
|
+
data.tar.gz: c0542dd1d64a09fbb86792b091467f2df2d96888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bbc186e05f37800f9ee185f668da8b24897ab4a8a16ca1ba5b12eebe0411fba7b59ec17aff7e5c953284696088071751a70c6cf0ab02af84403a17c235bf20f
|
7
|
+
data.tar.gz: 6dc039cb0af98ef161d49ce8e691cceeb8e075ec4e5b81ba307ae32de88799817f2564076a3b788826d2ac2a9f28cd73494ecacf72e5b7cf580df345909a06c1
|
data/README.md
CHANGED
@@ -93,6 +93,87 @@ sale = BraspagRest::Sale.new(
|
|
93
93
|
sale.save
|
94
94
|
```
|
95
95
|
|
96
|
+
### Authorize an order support fraud analysis fields
|
97
|
+
|
98
|
+
```rb
|
99
|
+
sale = BraspagRest::Sale.new(
|
100
|
+
order_id: '123456',
|
101
|
+
request_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
102
|
+
customer: {
|
103
|
+
name: 'Comprador Teste'
|
104
|
+
},
|
105
|
+
payment: {
|
106
|
+
type: 'CreditCard',
|
107
|
+
amount: 15700,
|
108
|
+
provider: 'Simulado',
|
109
|
+
installments: 1,
|
110
|
+
credit_card: {
|
111
|
+
number: '0000000000000001',
|
112
|
+
holder: 'Teste Holder',
|
113
|
+
expiration_date: '12/2021',
|
114
|
+
security_code: '123',
|
115
|
+
brand: 'Visa'
|
116
|
+
}
|
117
|
+
fraud_analysis: {
|
118
|
+
sequence: 'AuthorizeFirst',
|
119
|
+
sequence_criteria: 'Always',
|
120
|
+
capture_on_low_risk: false,
|
121
|
+
void_on_high_risk: false,
|
122
|
+
browser: {
|
123
|
+
cookies_accepted: false,
|
124
|
+
email: 'compradorteste@live.com',
|
125
|
+
host_name: 'Teste',
|
126
|
+
ip_address: '202.190.150.350',
|
127
|
+
type: 'Chrome'
|
128
|
+
},
|
129
|
+
cart: {
|
130
|
+
is_gift: false,
|
131
|
+
returns_accepted: true,
|
132
|
+
items: [
|
133
|
+
{
|
134
|
+
gift_category: 'Undefined',
|
135
|
+
host_hedge: 'Off',
|
136
|
+
non_sensical_hedge: 'Off',
|
137
|
+
obscenities_hedge: 'Off',
|
138
|
+
phone_hedge: 'Off',
|
139
|
+
name: 'ItemTeste',
|
140
|
+
quantity: 1,
|
141
|
+
sku: '201411170235134521346',
|
142
|
+
unit_price: 123,
|
143
|
+
risk: 'High',
|
144
|
+
time_hedge: 'Normal',
|
145
|
+
type: 'AdultContent',
|
146
|
+
velocity_hedge: 'High'
|
147
|
+
}
|
148
|
+
]
|
149
|
+
},
|
150
|
+
merchant_defined_fields: [
|
151
|
+
{
|
152
|
+
id: 9,
|
153
|
+
value: 'web'
|
154
|
+
}
|
155
|
+
],
|
156
|
+
shipping: {
|
157
|
+
addressee: 'Sr Comprador Teste',
|
158
|
+
method: 'LowCost',
|
159
|
+
phone: '21114740'
|
160
|
+
},
|
161
|
+
travel: {
|
162
|
+
departure_time: '2010-01-02',
|
163
|
+
journey_type: 'Ida',
|
164
|
+
route: 'MAO-RJO',
|
165
|
+
legs: [{
|
166
|
+
destination: 'GYN',
|
167
|
+
origin: 'VCP'
|
168
|
+
}]
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
)
|
173
|
+
|
174
|
+
sale.save
|
175
|
+
```
|
176
|
+
|
96
177
|
And to create a protected credit card, you should set the credit card saved as true:
|
97
178
|
|
98
179
|
```rb
|
data/lib/braspag-rest.rb
CHANGED
@@ -15,6 +15,7 @@ require 'braspag-rest/response'
|
|
15
15
|
require 'braspag-rest/request'
|
16
16
|
require 'braspag-rest/customer'
|
17
17
|
require 'braspag-rest/credit_card'
|
18
|
+
require 'braspag-rest/fraud_analyses'
|
19
|
+
require 'braspag-rest/fraud_analysis'
|
18
20
|
require 'braspag-rest/payment'
|
19
21
|
require 'braspag-rest/sale'
|
20
|
-
require 'braspag-rest/address'
|
@@ -2,7 +2,5 @@ module BraspagRest
|
|
2
2
|
class Customer < Hashie::IUTrash
|
3
3
|
property :name, from: 'Name'
|
4
4
|
property :identity, from: 'Identity'
|
5
|
-
property :identity_type, from: 'IdentityType'
|
6
|
-
property :address, from: 'Address', with: ->(values) { BraspagRest::Address.new(values) }
|
7
5
|
end
|
8
6
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
module FraudAnalyses
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'braspag-rest/fraud_analyses/passenger'
|
7
|
+
require 'braspag-rest/fraud_analyses/item'
|
8
|
+
require 'braspag-rest/fraud_analyses/leg'
|
9
|
+
require 'braspag-rest/fraud_analyses/reply_data'
|
10
|
+
require 'braspag-rest/fraud_analyses/travel'
|
11
|
+
require 'braspag-rest/fraud_analyses/shipping'
|
12
|
+
require 'braspag-rest/fraud_analyses/cart'
|
13
|
+
require 'braspag-rest/fraud_analyses/browser'
|
14
|
+
require 'braspag-rest/fraud_analyses/merchant_defined_field'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
module FraudAnalyses
|
3
|
+
class Browser < Hashie::IUTrash
|
4
|
+
property :cookies_accepted, from: 'CookiesAccepted'
|
5
|
+
property :email, from: 'Email'
|
6
|
+
property :host_name, from: 'HostName'
|
7
|
+
property :ip_address, from: 'IpAddress'
|
8
|
+
property :type, from: 'Type'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
module FraudAnalyses
|
3
|
+
class Cart < Hashie::IUTrash
|
4
|
+
include Hashie::Extensions::Coercion
|
5
|
+
|
6
|
+
property :is_gift, from: 'IsGift'
|
7
|
+
property :returns_accepted, from: 'ReturnsAccepted'
|
8
|
+
property :items, from: 'Items'
|
9
|
+
|
10
|
+
coerce_key :items, Array[Item]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
module FraudAnalyses
|
3
|
+
class Item < Hashie::IUTrash
|
4
|
+
include Hashie::Extensions::Coercion
|
5
|
+
|
6
|
+
property :gift_category, from: 'GiftCategory'
|
7
|
+
property :host_hedge, from: 'HostHedge'
|
8
|
+
property :non_sensical_hedge, from: 'NonSensicalHedge'
|
9
|
+
property :obscenities_hedge, from: 'ObscenitiesHedge'
|
10
|
+
property :phone_hedge, from: 'PhoneHedge'
|
11
|
+
property :name, from: 'Name'
|
12
|
+
property :quantity, from: 'Quantity'
|
13
|
+
property :sku, from: 'Sku'
|
14
|
+
property :unit_price, from: 'UnitPrice'
|
15
|
+
property :risk, from: 'Risk'
|
16
|
+
property :time_hedge, from: 'TimeHedge'
|
17
|
+
property :type, from: 'Type'
|
18
|
+
property :velocity_hedge, from: 'VelocityHedge'
|
19
|
+
property :passenger, from: 'Passenger'
|
20
|
+
|
21
|
+
coerce_key :passenger, BraspagRest::FraudAnalyses::Passenger
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
module FraudAnalyses
|
3
|
+
class Passenger < Hashie::IUTrash
|
4
|
+
property :email, from: 'Email'
|
5
|
+
property :identity, from: 'Identity'
|
6
|
+
property :name, from: 'Name'
|
7
|
+
property :rating, from: 'Rating'
|
8
|
+
property :phone, from: 'Phone'
|
9
|
+
property :status, from: 'Status'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
module FraudAnalyses
|
3
|
+
class ReplyData < Hashie::IUTrash
|
4
|
+
property :address_info_code, from: 'AddressInfoCode'
|
5
|
+
property :factor_code, from: 'FactorCode'
|
6
|
+
property :score, from: 'Score'
|
7
|
+
property :bin_country, from: 'BinCountry'
|
8
|
+
property :card_issuer, from: 'CardIssuer'
|
9
|
+
property :card_scheme, from: 'CardScheme'
|
10
|
+
property :host_severity, from: 'HostSeverity'
|
11
|
+
property :internet_info_code, from: 'InternetInfoCode'
|
12
|
+
property :ip_routing_method, from: 'IpRoutingMethod'
|
13
|
+
property :score_model_used, from: 'ScoreModelUsed'
|
14
|
+
property :case_priority, from: 'CasePriority'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
module FraudAnalyses
|
3
|
+
class Travel < Hashie::IUTrash
|
4
|
+
include Hashie::Extensions::Coercion
|
5
|
+
|
6
|
+
property :departure_time, from: 'DepartureTime'
|
7
|
+
property :journey_type, from: 'JourneyType'
|
8
|
+
property :route, from: 'Route'
|
9
|
+
property :legs, from: 'Legs'
|
10
|
+
|
11
|
+
coerce_key :legs, Array[BraspagRest::FraudAnalyses::Leg]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module BraspagRest
|
2
|
+
class FraudAnalysis < Hashie::IUTrash
|
3
|
+
include Hashie::Extensions::Coercion
|
4
|
+
|
5
|
+
STATUS_ACCEPTED = 1
|
6
|
+
STATUS_REJECTED = 2
|
7
|
+
|
8
|
+
property :sequence, from: 'Sequence'
|
9
|
+
property :sequence_criteria, from: 'SequenceCriteria'
|
10
|
+
property :finger_print_id, from: 'FingerPrintId'
|
11
|
+
property :capture_on_low_risk, from: 'CaptureOnLowRisk'
|
12
|
+
property :void_on_high_risk, from: 'VoidOnHighRisk'
|
13
|
+
property :browser, from: 'Browser'
|
14
|
+
property :cart, from: 'Cart'
|
15
|
+
property :merchant_defined_fields, from: 'MerchantDefinedFields'
|
16
|
+
|
17
|
+
property :shipping, from: 'Shipping'
|
18
|
+
property :travel, from: 'Travel'
|
19
|
+
|
20
|
+
property :status, from: 'Status'
|
21
|
+
property :fraud_analysis_reason_code, from: 'FraudAnalysisReasonCode'
|
22
|
+
|
23
|
+
# Response
|
24
|
+
property :travel, from: 'Travel'
|
25
|
+
property :shipping, from: 'Shipping'
|
26
|
+
property :id, from: 'Id'
|
27
|
+
property :reply_data, from: 'ReplyData'
|
28
|
+
|
29
|
+
coerce_key :browser, BraspagRest::FraudAnalyses::Browser
|
30
|
+
coerce_key :cart, BraspagRest::FraudAnalyses::Cart
|
31
|
+
coerce_key :shipping, BraspagRest::FraudAnalyses::Shipping
|
32
|
+
coerce_key :travel, BraspagRest::FraudAnalyses::Travel
|
33
|
+
coerce_key :reply_data, BraspagRest::FraudAnalyses::ReplyData
|
34
|
+
coerce_key :merchant_defined_fields, Array[BraspagRest::FraudAnalyses::MerchantDefinedFields]
|
35
|
+
|
36
|
+
def accepted?
|
37
|
+
status.to_i.eql?(STATUS_ACCEPTED)
|
38
|
+
end
|
39
|
+
|
40
|
+
def rejected?
|
41
|
+
status.to_i.eql?(STATUS_REJECTED)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -5,14 +5,27 @@ module Hashie
|
|
5
5
|
include Hashie::Extensions::Dash::PropertyTranslation
|
6
6
|
|
7
7
|
def inverse_attributes
|
8
|
-
{}
|
9
|
-
self.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
attributes[from] = value unless value.nil?
|
8
|
+
self.class.translations.each_with_object({}) do |(from, property), attributes|
|
9
|
+
value = nested_inverse(self.send(property))
|
10
|
+
|
11
|
+
unless value.nil?
|
12
|
+
attributes[from] = value
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def nested_inverse(value)
|
20
|
+
if [Array, Set].include?(value.class)
|
21
|
+
value.map { |item| attributes_for(item) }
|
22
|
+
else
|
23
|
+
attributes_for(value)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def attributes_for(value)
|
28
|
+
value.respond_to?(:inverse_attributes) ? value.inverse_attributes : value
|
29
|
+
end
|
17
30
|
end
|
18
31
|
end
|
data/lib/braspag-rest/payment.rb
CHANGED
@@ -9,7 +9,6 @@ module BraspagRest
|
|
9
9
|
property :id, from: 'PaymentId'
|
10
10
|
property :type, from: 'Type'
|
11
11
|
property :amount, from: 'Amount'
|
12
|
-
property :boleto_number, from: 'BoletoNumber'
|
13
12
|
property :captured_amount, from: 'CapturedAmount'
|
14
13
|
property :status, from: 'Status'
|
15
14
|
property :provider, from: 'Provider'
|
@@ -28,6 +27,22 @@ module BraspagRest
|
|
28
27
|
property :instructions, from: 'Instructions'
|
29
28
|
property :printable_page_url, from: 'Url'
|
30
29
|
|
30
|
+
property :currency, from: 'Currency'
|
31
|
+
property :country, from: 'Country'
|
32
|
+
property :service_tax_amount, from: 'ServiceTaxAmount'
|
33
|
+
property :interest, from: 'Interest'
|
34
|
+
property :capture, from: 'Capture'
|
35
|
+
property :authenticate, from: 'Authenticate'
|
36
|
+
property :soft_descriptor, from: 'SoftDescriptor'
|
37
|
+
property :fraud_analysis, from: 'FraudAnalysis'
|
38
|
+
|
39
|
+
# Response fields
|
40
|
+
property :received_date, from: 'ReceivedDate'
|
41
|
+
property :provider_return_code, from: 'ProviderReturnCode'
|
42
|
+
property :provider_return_message, from: 'ProviderReturnMessage'
|
43
|
+
property :links, from: 'Links'
|
44
|
+
|
45
|
+
coerce_key :fraud_analysis, BraspagRest::FraudAnalysis
|
31
46
|
coerce_key :credit_card, BraspagRest::CreditCard
|
32
47
|
|
33
48
|
def authorized?
|
data/lib/braspag-rest/request.rb
CHANGED
data/lib/braspag-rest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: braspag-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dinda Dev Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -128,10 +128,20 @@ files:
|
|
128
128
|
- bin/setup
|
129
129
|
- braspag-rest.gemspec
|
130
130
|
- lib/braspag-rest.rb
|
131
|
-
- lib/braspag-rest/address.rb
|
132
131
|
- lib/braspag-rest/configuration.rb
|
133
132
|
- lib/braspag-rest/credit_card.rb
|
134
133
|
- lib/braspag-rest/customer.rb
|
134
|
+
- lib/braspag-rest/fraud_analyses.rb
|
135
|
+
- lib/braspag-rest/fraud_analyses/browser.rb
|
136
|
+
- lib/braspag-rest/fraud_analyses/cart.rb
|
137
|
+
- lib/braspag-rest/fraud_analyses/item.rb
|
138
|
+
- lib/braspag-rest/fraud_analyses/leg.rb
|
139
|
+
- lib/braspag-rest/fraud_analyses/merchant_defined_field.rb
|
140
|
+
- lib/braspag-rest/fraud_analyses/passenger.rb
|
141
|
+
- lib/braspag-rest/fraud_analyses/reply_data.rb
|
142
|
+
- lib/braspag-rest/fraud_analyses/shipping.rb
|
143
|
+
- lib/braspag-rest/fraud_analyses/travel.rb
|
144
|
+
- lib/braspag-rest/fraud_analysis.rb
|
135
145
|
- lib/braspag-rest/hashie.rb
|
136
146
|
- lib/braspag-rest/hashie/iudash.rb
|
137
147
|
- lib/braspag-rest/hashie/iutrash.rb
|
@@ -160,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
170
|
version: '0'
|
161
171
|
requirements: []
|
162
172
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.5.
|
173
|
+
rubygems_version: 2.5.1
|
164
174
|
signing_key:
|
165
175
|
specification_version: 4
|
166
176
|
summary: Gem to use Braspag gateway in his REST version
|
data/lib/braspag-rest/address.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module BraspagRest
|
2
|
-
class Address < Hashie::IUTrash
|
3
|
-
property :street, from: 'Street'
|
4
|
-
property :number, from: 'Number'
|
5
|
-
property :complement, from: 'Complement'
|
6
|
-
property :zip_code, from: 'ZipCode'
|
7
|
-
property :city, from: 'City'
|
8
|
-
property :state, from: 'State'
|
9
|
-
property :country, from: 'Country'
|
10
|
-
property :district, from: 'District'
|
11
|
-
end
|
12
|
-
end
|