forked from Dinda-com-br/braspag-rest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kassio Borges
committed
May 31, 2016
1 parent
c7db0c7
commit a3aff11
Showing
15 changed files
with
370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,87 @@ sale = BraspagRest::Sale.new( | |
sale.save | ||
``` | ||
|
||
### Authorize an order support fraud analysis fields | ||
|
||
```rb | ||
sale = BraspagRest::Sale.new( | ||
order_id: '123456', | ||
request_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', | ||
customer: { | ||
name: 'Comprador Teste' | ||
}, | ||
payment: { | ||
type: 'CreditCard', | ||
amount: 15700, | ||
provider: 'Simulado', | ||
installments: 1, | ||
credit_card: { | ||
number: '0000000000000001', | ||
holder: 'Teste Holder', | ||
expiration_date: '12/2021', | ||
security_code: '123', | ||
brand: 'Visa' | ||
} | ||
fraud_analysis: { | ||
sequence: 'AuthorizeFirst', | ||
sequence_criteria: 'Always', | ||
capture_on_low_risk: false, | ||
void_on_high_risk: false, | ||
browser: { | ||
cookies_accepted: false, | ||
email: '[email protected]', | ||
host_name: 'Teste', | ||
ip_address: '202.190.150.350', | ||
type: 'Chrome' | ||
}, | ||
cart: { | ||
is_gift: false, | ||
returns_accepted: true, | ||
items: [ | ||
{ | ||
gift_category: 'Undefined', | ||
host_hedge: 'Off', | ||
non_sensical_hedge: 'Off', | ||
obscenities_hedge: 'Off', | ||
phone_hedge: 'Off', | ||
name: 'ItemTeste', | ||
quantity: 1, | ||
sku: '201411170235134521346', | ||
unit_price: 123, | ||
risk: 'High', | ||
time_hedge: 'Normal', | ||
type: 'AdultContent', | ||
velocity_hedge: 'High' | ||
} | ||
] | ||
}, | ||
merchant_defined_fields: [ | ||
{ | ||
id: 9, | ||
value: 'web' | ||
} | ||
], | ||
shipping: { | ||
addressee: 'Sr Comprador Teste', | ||
method: 'LowCost', | ||
phone: '21114740' | ||
}, | ||
travel: { | ||
departure_time: '2010-01-02', | ||
journey_type: 'Ida', | ||
route: 'MAO-RJO', | ||
legs: [{ | ||
destination: 'GYN', | ||
origin: 'VCP' | ||
}] | ||
} | ||
} | ||
} | ||
) | ||
sale.save | ||
``` | ||
|
||
And to create a protected credit card, you should set the credit card saved as true: | ||
|
||
```rb | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
end | ||
end | ||
|
||
require 'braspag-rest/fraud_analyses/passenger' | ||
require 'braspag-rest/fraud_analyses/item' | ||
require 'braspag-rest/fraud_analyses/leg' | ||
require 'braspag-rest/fraud_analyses/reply_data' | ||
require 'braspag-rest/fraud_analyses/travel' | ||
require 'braspag-rest/fraud_analyses/shipping' | ||
require 'braspag-rest/fraud_analyses/cart' | ||
require 'braspag-rest/fraud_analyses/browser' | ||
require 'braspag-rest/fraud_analyses/merchant_defined_field' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class Browser < Hashie::IUTrash | ||
property :cookies_accepted, from: 'CookiesAccepted' | ||
property :email, from: 'Email' | ||
property :host_name, from: 'HostName' | ||
property :ip_address, from: 'IpAddress' | ||
property :type, from: 'Type' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class Cart < Hashie::IUTrash | ||
include Hashie::Extensions::Coercion | ||
|
||
property :is_gift, from: 'IsGift' | ||
property :returns_accepted, from: 'ReturnsAccepted' | ||
property :items, from: 'Items' | ||
|
||
coerce_key :items, Array[Item] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class Item < Hashie::IUTrash | ||
include Hashie::Extensions::Coercion | ||
|
||
property :gift_category, from: 'GiftCategory' | ||
property :host_hedge, from: 'HostHedge' | ||
property :non_sensical_hedge, from: 'NonSensicalHedge' | ||
property :obscenities_hedge, from: 'ObscenitiesHedge' | ||
property :phone_hedge, from: 'PhoneHedge' | ||
property :name, from: 'Name' | ||
property :quantity, from: 'Quantity' | ||
property :sku, from: 'Sku' | ||
property :unit_price, from: 'UnitPrice' | ||
property :risk, from: 'Risk' | ||
property :time_hedge, from: 'TimeHedge' | ||
property :type, from: 'Type' | ||
property :velocity_hedge, from: 'VelocityHedge' | ||
property :passenger, from: 'Passenger' | ||
|
||
coerce_key :passenger, BraspagRest::FraudAnalyses::Passenger | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class Leg < Hashie::IUTrash | ||
property :destination, from: 'Destination' | ||
property :origin, from: 'Origin' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class MerchantDefinedFields < Hashie::IUTrash | ||
property :id, from: 'Id' | ||
property :value, from: 'Value' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class Passenger < Hashie::IUTrash | ||
property :email, from: 'Email' | ||
property :identity, from: 'Identity' | ||
property :name, from: 'Name' | ||
property :rating, from: 'Rating' | ||
property :phone, from: 'Phone' | ||
property :status, from: 'Status' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class ReplyData < Hashie::IUTrash | ||
property :address_info_code, from: 'AddressInfoCode' | ||
property :factor_code, from: 'FactorCode' | ||
property :score, from: 'Score' | ||
property :bin_country, from: 'BinCountry' | ||
property :card_issuer, from: 'CardIssuer' | ||
property :card_scheme, from: 'CardScheme' | ||
property :host_severity, from: 'HostSeverity' | ||
property :internet_info_code, from: 'InternetInfoCode' | ||
property :ip_routing_method, from: 'IpRoutingMethod' | ||
property :score_model_used, from: 'ScoreModelUsed' | ||
property :case_priority, from: 'CasePriority' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class Shipping < Hashie::IUTrash | ||
property :addressee, from: 'Addressee' | ||
property :method, from: 'Method' | ||
property :phone, from: 'Phone' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module BraspagRest | ||
module FraudAnalyses | ||
class Travel < Hashie::IUTrash | ||
include Hashie::Extensions::Coercion | ||
|
||
property :departure_time, from: 'DepartureTime' | ||
property :journey_type, from: 'JourneyType' | ||
property :route, from: 'Route' | ||
property :legs, from: 'Legs' | ||
|
||
coerce_key :legs, Array[BraspagRest::FraudAnalyses::Leg] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module BraspagRest | ||
class FraudAnalysis < Hashie::IUTrash | ||
include Hashie::Extensions::Coercion | ||
|
||
STATUS_ACCEPTED = 1 | ||
STATUS_REJECTED = 2 | ||
|
||
property :sequence, from: 'Sequence' | ||
property :sequence_criteria, from: 'SequenceCriteria' | ||
property :finger_print_id, from: 'FingerPrintId' | ||
property :capture_on_low_risk, from: 'CaptureOnLowRisk' | ||
property :void_on_high_risk, from: 'VoidOnHighRisk' | ||
property :browser, from: 'Browser' | ||
property :cart, from: 'Cart' | ||
property :merchant_defined_fields, from: 'MerchantDefinedFields' | ||
|
||
property :shipping, from: 'Shipping' | ||
property :travel, from: 'Travel' | ||
|
||
property :status, from: 'Status' | ||
property :fraud_analysis_reason_code, from: 'FraudAnalysisReasonCode' | ||
|
||
# Response | ||
property :travel, from: 'Travel' | ||
property :shipping, from: 'Shipping' | ||
property :id, from: 'Id' | ||
property :reply_data, from: 'ReplyData' | ||
|
||
coerce_key :browser, BraspagRest::FraudAnalyses::Browser | ||
coerce_key :cart, BraspagRest::FraudAnalyses::Cart | ||
coerce_key :shipping, BraspagRest::FraudAnalyses::Shipping | ||
coerce_key :travel, BraspagRest::FraudAnalyses::Travel | ||
coerce_key :reply_data, BraspagRest::FraudAnalyses::ReplyData | ||
coerce_key :merchant_defined_fields, Array[BraspagRest::FraudAnalyses::MerchantDefinedFields] | ||
|
||
def accepted? | ||
status.to_i.eql?(STATUS_ACCEPTED) | ||
end | ||
|
||
def rejected? | ||
status.to_i.eql?(STATUS_REJECTED) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.