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

Commit 1cbba25

Browse files
authored
Merge pull request #85 from catarse/fix/limit_data_size_sent_to_antifraud
Limita tamanho dos dados enviados ao Konduto e atualiza versão para 2.16.3
2 parents f81c452 + 27f7850 commit 1cbba25

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
catarse_pagarme (2.16.2)
4+
catarse_pagarme (2.16.3)
55
countries (= 3.0.0)
66
konduto-ruby (= 2.1.0)
77
pagarme (= 2.1.4)

app/models/catarse_pagarme/antifraud_order_wrapper.rb

+22-22
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def build_seller
5959

6060
def order_attributes
6161
{
62-
id: self.transaction.id.to_s,
62+
id: self.transaction.id.to_s[0..99],
6363
total_amount: self.attributes[:amount] / 100.0,
64-
visitor: self.attributes.dig(:metadata, :contribution_id).to_s,
64+
visitor: self.attributes.dig(:metadata, :contribution_id).to_s[0..40],
6565
currency: 'BRL',
6666
installments: self.attributes[:installments],
6767
purchased_at: self.transaction.date_created,
@@ -74,10 +74,10 @@ def customer_attributes
7474
tax_id = customer[:document_number].present? ? { tax_id: customer[:document_number] } : {}
7575

7676
{
77-
id: customer[:id].to_s,
78-
name: customer[:name],
79-
email: customer[:email],
80-
phone1: customer[:phone].to_h.values.join,
77+
id: customer[:id].to_s[0..99],
78+
name: customer[:name].to_s[0..99],
79+
email: customer[:email].to_s[0..99],
80+
phone1: customer[:phone].to_h.values.join.to_s[0..99],
8181
created_at: self.attributes.dig(:antifraud_metadata, :register, :registered_at)
8282
}.merge(tax_id)
8383
end
@@ -95,33 +95,33 @@ def payment_attributes
9595
def billing_address_attributes
9696
billing_data = self.attributes.dig(:antifraud_metadata, :billing)
9797
{
98-
name: self.transaction.card.holder_name,
99-
address1: billing_data.dig(:address, :street),
100-
city: billing_data.dig(:address, :city),
101-
state: billing_data.dig(:address, :state),
102-
zip: billing_data.dig(:address, :zipcode),
103-
country: billing_data.dig(:address, :country_code),
98+
name: self.transaction.card.holder_name.to_s[0..99],
99+
address1: billing_data.dig(:address, :street).to_s[0..254],
100+
city: billing_data.dig(:address, :city).to_s[0..99],
101+
state: billing_data.dig(:address, :state).to_s[0..99],
102+
zip: billing_data.dig(:address, :zipcode).to_s[0..99],
103+
country: billing_data.dig(:address, :country_code).to_s[0..1],
104104
}
105105
end
106106

107107
def shipping_address_attributes
108108
shipping_data = self.attributes.dig(:antifraud_metadata, :shipping)
109109
{
110-
name: shipping_data.dig(:customer, :name),
111-
address1: shipping_data.dig(:address, :street),
112-
city: shipping_data.dig(:address, :city),
113-
state: shipping_data.dig(:address, :state),
114-
zip: shipping_data.dig(:address, :zipcode)
110+
name: shipping_data.dig(:customer, :name).to_s[0..99],
111+
address1: shipping_data.dig(:address, :street).to_s[0..254],
112+
city: shipping_data.dig(:address, :city).to_s[0..99],
113+
state: shipping_data.dig(:address, :state).to_s[0..99],
114+
zip: shipping_data.dig(:address, :zipcode).to_s[0..99]
115115
}
116116
end
117117

118118
def item_attributes
119119
shopping_cart_data = self.attributes.dig(:antifraud_metadata, :shopping_cart).first
120120
{
121-
sku: self.attributes.dig(:metadata, :contribution_id).to_s,
122-
product_code: self.attributes.dig(:metadata, :contribution_id).to_s,
121+
sku: self.attributes.dig(:metadata, :contribution_id).to_s[0..99],
122+
product_code: self.attributes.dig(:metadata, :contribution_id).to_s[0..99],
123123
category: 9999,
124-
name: shopping_cart_data[:name],
124+
name: shopping_cart_data[:name].to_s[0..99],
125125
unit_cost: self.attributes[:amount] / 100.0,
126126
quantity: 1,
127127
created_at: self.attributes.dig(:metadata, :project_online).to_s[0..9]
@@ -131,8 +131,8 @@ def item_attributes
131131
def seller_attributes
132132
event_data = self.attributes.dig(:antifraud_metadata, :events).first
133133
{
134-
id: event_data[:id],
135-
name: event_data[:venue_name],
134+
id: event_data[:id].to_s[0..99],
135+
name: event_data[:venue_name].to_s[0..99],
136136
created_at: event_data[:date]
137137
}
138138
end

lib/catarse_pagarme/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module CatarsePagarme
2-
VERSION = "2.16.2"
2+
VERSION = "2.16.3"
33
end

0 commit comments

Comments
 (0)