Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #85 from catarse/fix/limit_data_size_sent_to_antif…
Browse files Browse the repository at this point in the history
…raud

Limita tamanho dos dados enviados ao Konduto e atualiza versão para 2.16.3
  • Loading branch information
devton authored Sep 21, 2020
2 parents f81c452 + 27f7850 commit 1cbba25
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
catarse_pagarme (2.16.2)
catarse_pagarme (2.16.3)
countries (= 3.0.0)
konduto-ruby (= 2.1.0)
pagarme (= 2.1.4)
Expand Down
44 changes: 22 additions & 22 deletions app/models/catarse_pagarme/antifraud_order_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def build_seller

def order_attributes
{
id: self.transaction.id.to_s,
id: self.transaction.id.to_s[0..99],
total_amount: self.attributes[:amount] / 100.0,
visitor: self.attributes.dig(:metadata, :contribution_id).to_s,
visitor: self.attributes.dig(:metadata, :contribution_id).to_s[0..40],
currency: 'BRL',
installments: self.attributes[:installments],
purchased_at: self.transaction.date_created,
Expand All @@ -74,10 +74,10 @@ def customer_attributes
tax_id = customer[:document_number].present? ? { tax_id: customer[:document_number] } : {}

{
id: customer[:id].to_s,
name: customer[:name],
email: customer[:email],
phone1: customer[:phone].to_h.values.join,
id: customer[:id].to_s[0..99],
name: customer[:name].to_s[0..99],
email: customer[:email].to_s[0..99],
phone1: customer[:phone].to_h.values.join.to_s[0..99],
created_at: self.attributes.dig(:antifraud_metadata, :register, :registered_at)
}.merge(tax_id)
end
Expand All @@ -95,33 +95,33 @@ def payment_attributes
def billing_address_attributes
billing_data = self.attributes.dig(:antifraud_metadata, :billing)
{
name: self.transaction.card.holder_name,
address1: billing_data.dig(:address, :street),
city: billing_data.dig(:address, :city),
state: billing_data.dig(:address, :state),
zip: billing_data.dig(:address, :zipcode),
country: billing_data.dig(:address, :country_code),
name: self.transaction.card.holder_name.to_s[0..99],
address1: billing_data.dig(:address, :street).to_s[0..254],
city: billing_data.dig(:address, :city).to_s[0..99],
state: billing_data.dig(:address, :state).to_s[0..99],
zip: billing_data.dig(:address, :zipcode).to_s[0..99],
country: billing_data.dig(:address, :country_code).to_s[0..1],
}
end

def shipping_address_attributes
shipping_data = self.attributes.dig(:antifraud_metadata, :shipping)
{
name: shipping_data.dig(:customer, :name),
address1: shipping_data.dig(:address, :street),
city: shipping_data.dig(:address, :city),
state: shipping_data.dig(:address, :state),
zip: shipping_data.dig(:address, :zipcode)
name: shipping_data.dig(:customer, :name).to_s[0..99],
address1: shipping_data.dig(:address, :street).to_s[0..254],
city: shipping_data.dig(:address, :city).to_s[0..99],
state: shipping_data.dig(:address, :state).to_s[0..99],
zip: shipping_data.dig(:address, :zipcode).to_s[0..99]
}
end

def item_attributes
shopping_cart_data = self.attributes.dig(:antifraud_metadata, :shopping_cart).first
{
sku: self.attributes.dig(:metadata, :contribution_id).to_s,
product_code: self.attributes.dig(:metadata, :contribution_id).to_s,
sku: self.attributes.dig(:metadata, :contribution_id).to_s[0..99],
product_code: self.attributes.dig(:metadata, :contribution_id).to_s[0..99],
category: 9999,
name: shopping_cart_data[:name],
name: shopping_cart_data[:name].to_s[0..99],
unit_cost: self.attributes[:amount] / 100.0,
quantity: 1,
created_at: self.attributes.dig(:metadata, :project_online).to_s[0..9]
Expand All @@ -131,8 +131,8 @@ def item_attributes
def seller_attributes
event_data = self.attributes.dig(:antifraud_metadata, :events).first
{
id: event_data[:id],
name: event_data[:venue_name],
id: event_data[:id].to_s[0..99],
name: event_data[:venue_name].to_s[0..99],
created_at: event_data[:date]
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/catarse_pagarme/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module CatarsePagarme
VERSION = "2.16.2"
VERSION = "2.16.3"
end

0 comments on commit 1cbba25

Please sign in to comment.