maxipago_api 0.1.0 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d3e63e19f857e48a09dd64147ef318fbcd8c7087c85a71451446b3e0246a13c
4
- data.tar.gz: 393578b9049b7550e49510541008c1a880e345c3e94492e8df91311faadffc77
3
+ metadata.gz: 301ee17d4713b2b358904a4c74958b5d9ef173fe4f106b2789955c015f74918e
4
+ data.tar.gz: 6a615b8e7fe6c40e47b397e77610a17c25f42c3d9bde5c6555f47f7991558d10
5
5
  SHA512:
6
- metadata.gz: 64604d0145af946c9a8f621ba82be31483b11b533e7a4ff448a9faadd715fa3a3bb00e4ce9443bc62a4951d5edb930c73b160848f4b4562359b7da0a252101ec
7
- data.tar.gz: d61559e7f2d26fca2a947ba687a5f52efbd927d3a36e04004a549c8dbe09a890636fc6e57a76a3a828947f89ea786bfe6532b0af5880d8fc6623bdb35a915c28
6
+ metadata.gz: 231bf015da02d69dabece5f461c85cf0aadeed36f7a5d6dbb3d8930e1ea9cb13a988aa0e5da44a693aad18f5ec999aa22d0130b353b8a982ff621a8408221d16
7
+ data.tar.gz: 3760da2eecdd862a07bd9ee8cf6efd137fe854d5bc29fda4e6b73eab9d95e361bc2a4f63b8c9130856dbbec6cbe941dce2caaf515963b3650ce36a8a87736684
@@ -7,12 +7,13 @@ require 'maxipago_api/requests/customer_request.rb'
7
7
  module MaxipagoApi
8
8
  class Error < StandardError; end
9
9
  class << self
10
- attr_accessor :api_register_endpoint, :api_transaction_endpoiont, :store_id, :store_key
10
+ attr_accessor :api_register_endpoint, :api_transaction_endpoint, :api_reports_endpoint, :store_id, :store_key
11
11
  end
12
12
  self.store_key = ENV['MAXIPAGO_API_KEY']
13
13
  self.store_id = ENV['MAXIPAGO_STORE_ID']
14
14
  self.api_register_endpoint = 'https://testapi.maxipago.net/UniversalAPI/postAPI'
15
- self.api_transaction_endpoiont = 'https://testapi.maxipago.net/UniversalAPI/postXML'
15
+ self.api_transaction_endpoint = 'https://testapi.maxipago.net/UniversalAPI/postXML'
16
+ self.api_reports_endpoint = 'https://testapi.maxipago.net/ReportsAPI/servlet/ReportsAPI'
16
17
 
17
18
  def self.production?
18
19
  ENV['RACK_ENV'] == 'production' ||
@@ -1,3 +1,4 @@
1
+ require 'maxipago_api/requests/credit_card_request.rb'
1
2
  module MaxipagoApi
2
3
  class CreditCardModel
3
4
  attr_accessor :customer_id, :credit_card_number, :expiration_month, :expiration_year,
@@ -6,23 +7,23 @@ module MaxipagoApi
6
7
  :billing_email
7
8
 
8
9
  def initialize(options = {})
9
- self.customer_id = params[:customer_id]
10
- self.credit_card_number = params[:credit_card_number]
11
- self.expiration_month = params[:expiration_month]
12
- self.expiration_year = params[:expiration_year]
13
- self.billing_name = params[:billing_name]
14
- self.billing_address1 = params[:billing_address1]
15
- self.billing_address2 = params[:billing_address2]
16
- self.billing_city = params[:billing_city]
17
- self.billing_state = params[:billing_state]
18
- self.billing_zipcode = params[:billing_zipcode]
19
- self.billing_country = params[:billing_country]
20
- self.billing_phone = params[:billing_phone]
21
- self.billing_email = params[:billing_email]
10
+ self.customer_id = options[:customer_id]
11
+ self.credit_card_number = options[:credit_card_number]
12
+ self.expiration_month = options[:expiration_month]
13
+ self.expiration_year = options[:expiration_year]
14
+ self.billing_name = options[:billing_name]
15
+ self.billing_address1 = options[:billing_address1]
16
+ self.billing_address2 = options[:billing_address2]
17
+ self.billing_city = options[:billing_city]
18
+ self.billing_state = options[:billing_state]
19
+ self.billing_zipcode = options[:billing_zipcode]
20
+ self.billing_country = options[:billing_country]
21
+ self.billing_phone = options[:billing_phone]
22
+ self.billing_email = options[:billing_email]
22
23
  end
23
24
 
24
25
  def save
25
- MaxipagoApi::CreditCardRequest.new(self).save
26
+ MaxipagoApi::CreditCardRequest.save(self)
26
27
  end
27
28
 
28
29
  def to_object
@@ -40,7 +41,7 @@ module MaxipagoApi
40
41
  billingCountry: self.billing_country,
41
42
  billingPhone: self.billing_phone,
42
43
  billingEmail: self.billing_email,
43
- }
44
+ }.select{|k,v| v.present?}
44
45
  end
45
46
  end
46
47
  end
@@ -3,10 +3,9 @@ module MaxipagoApi
3
3
  class CustomerModel
4
4
  attr_accessor :customer_id_ext, :first_name,
5
5
  :last_name, :email,:birth_date, :document,
6
- :sex, :address1, :address2, :city, :state, :zipcode, :country, :phone, :email
6
+ :sex, :address1, :address2, :city, :state, :zipcode, :country, :phone, :email, :id, :response_error
7
7
 
8
8
  def initialize(options = {})
9
- self.id
10
9
  self.customer_id_ext = options[:customer_id_ext]
11
10
  self.first_name = options[:first_name]
12
11
  self.last_name = options[:last_name]
@@ -29,15 +28,21 @@ module MaxipagoApi
29
28
  MaxipagoApi::CustomerRequest.create(self)
30
29
  end
31
30
 
32
- def find
31
+ def self.find(id)
32
+ MaxipagoApi::CustomerRequest.find(id)
33
33
  end
34
34
 
35
35
  def to_object
36
36
  {
37
37
  customerIdExt: self.customer_id_ext,
38
38
  firstName: self.first_name,
39
- lastName: self.last_name
40
- }
39
+ lastName: self.last_name,
40
+ zip: self.zipcode,
41
+ email: self.email,
42
+ dob: self.sex,
43
+ ssn: self.document,
44
+ sex: self.sex
45
+ }.select{|k,v| v.present?}
41
46
  end
42
47
  end
43
48
  end
@@ -1,8 +1,12 @@
1
+ require 'maxipago_api/requests/transaction_request.rb'
1
2
  module MaxipagoApi
2
3
  class TransactionModel
3
- attr_accessor :customer_id_ext, :reference_number, :charge_total
4
+ attr_accessor :customer_id, :token, :ip_address, :reference_number, :charge_total, :processor_id
4
5
  def initialize(options = {})
5
- self.customer_id_ext = options[:customer_id_ext]
6
+ self.customer_id = options[:customer_id]
7
+ self.processor_id = options[:processor_id]
8
+ self.token = options[:token]
9
+ self.ip_address = options[:ip_address]
6
10
  self.reference_number = options[:reference_number]
7
11
  self.charge_total = options[:charge_total]
8
12
  end
@@ -13,5 +17,26 @@ module MaxipagoApi
13
17
 
14
18
  def find
15
19
  end
20
+
21
+ def to_object
22
+ {
23
+ sale: {
24
+ processorID: self.processor_id,
25
+ referenceNum: self.reference_number,
26
+ transactionDetail: {
27
+ payType: {
28
+ onFile: {
29
+ customerId: self.customer_id,
30
+ token: self.token,
31
+ },
32
+ }
33
+ },
34
+ payment: {
35
+ currencyCode: 'BRL',
36
+ chargeTotal: self.charge_total
37
+ }
38
+ }
39
+ }.select{|k,v| v.present?}
40
+ end
16
41
  end
17
42
  end
@@ -4,13 +4,16 @@ require "active_support/core_ext"
4
4
  module MaxipagoApi
5
5
  class CreditCardRequest
6
6
  include HTTParty
7
- def save(credit_card)
8
- xml = {
9
- 'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key},
10
- command: 'add-card-onfile',
11
- request: credit_card.to_object
12
- }.to_xml(root: 'api-request')
13
- response = post(MaxipagoApi.api_register_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
7
+
8
+ class << self
9
+ def save(credit_card)
10
+ xml = {
11
+ 'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key},
12
+ command: 'add-card-onfile',
13
+ request: credit_card.to_object
14
+ }.to_xml(root: 'api-request', skip_types: true)
15
+ response = post(MaxipagoApi.api_register_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
16
+ end
14
17
  end
15
18
  end
16
19
  end
@@ -10,7 +10,7 @@ module MaxipagoApi
10
10
  'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key},
11
11
  command: 'add-consumer',
12
12
  request: customer.to_object
13
- }.to_xml(root: 'api-request')
13
+ }.to_xml(root: 'api-request', skip_types: true)
14
14
  response = post(MaxipagoApi.api_register_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
15
15
  Hash.from_xml(response.parsed_response)
16
16
  end
@@ -0,0 +1,34 @@
1
+ require 'httparty'
2
+ require 'active_support'
3
+ require "active_support/core_ext"
4
+ module MaxipagoApi
5
+ class TransactionRequest
6
+ include HTTParty
7
+
8
+ class << self
9
+ def create(transaction)
10
+ xml = {
11
+ 'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key},
12
+ version: '3.1.1.15',
13
+ order: transaction.to_object
14
+ }.to_xml(root: 'transaction-request', skip_types: true)
15
+ response = post(MaxipagoApi.api_transaction_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
16
+ Hash.from_xml(response.parsed_response)
17
+ end
18
+
19
+ def find(id)
20
+ xml = {
21
+ 'verification' => {merchantId: MaxipagoApi.store_id, merchantKey: MaxipagoApi.store_key},
22
+ command: 'transactionDetailReport',
23
+ request: {
24
+ filterOptions: {
25
+ transactionId: id
26
+ }
27
+ }
28
+ }.to_xml(root: 'rapi-request', skip_types: true)
29
+ response = post(MaxipagoApi.api_reports_endpoint, body: xml, headers: {'Content-Type' => 'text/plain'})
30
+ Hash.from_xml(response.parsed_response)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module MaxipagoApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxipago_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidnei Pacheco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,11 @@ files:
91
91
  - lib/maxipago_api/requests/transaction_request.rb
92
92
  - lib/maxipago_api/responses/response_api.rb
93
93
  - lib/maxipago_api/version.rb
94
+ - maxipago_api-0.1.0.gem
95
+ - maxipago_api-0.1.1.gem
96
+ - maxipago_api-0.1.2.gem
97
+ - maxipago_api-0.1.3.gem
98
+ - maxipago_api-0.1.4.gem
94
99
  - maxipago_api.gemspec
95
100
  homepage: https://github.com/sidneip
96
101
  licenses: