maxipago_api 0.1.1 → 0.1.2

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: ffed09807de45e083486d9bcf204842852938367462029e79ec12ed46aff5d05
4
- data.tar.gz: 2be65b875d208c4d7fe9e1fd4fc8a365313825d4378b50f35b0bee94e1369b87
3
+ metadata.gz: b65b599f6aef9ed3f2d3208d090691d1afc2040cff9aff5e549f308d3bc4fc12
4
+ data.tar.gz: 50c80ba50caab3a25e0736f23b0296865fc91795c5df66c856d7467a9ab64b47
5
5
  SHA512:
6
- metadata.gz: 1e6437acf911701d671bdd590a11f86d614dd2c6ceccf622ba9fd8595f079a3832fb7f92e0e917022031e475e848b550fc0bfa35b94f1db81a841e5d6977923f
7
- data.tar.gz: b760328c5629854746a10632f3a94baf7308931076e8a2e9cc4fc553eec702417b7811cd3e7ae2335f6c778fc9c159f1610c5b4a2ddd6a989ec2db1dabd5639f
6
+ metadata.gz: 165d2d155ae0b8f6e8e41f1bfb9e905e68c203c66c8e518b8def5b80cd02ec0c72eeb4df057beba0d647c56eb979ee2923c9286be7686fc7c80561583f7e4b57
7
+ data.tar.gz: 2aaf02f89ae915e1740ed990ae130f318494baec48101540fd2015052b48ee0c627975505b33a2dc9bc6845b81ab38e6c37804695ee6e15f5dc3ed341012c692
@@ -7,12 +7,12 @@ 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, :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
16
 
17
17
  def self.production?
18
18
  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
@@ -35,7 +35,12 @@ module MaxipagoApi
35
35
  {
36
36
  customerIdExt: self.customer_id_ext,
37
37
  firstName: self.first_name,
38
- lastName: self.last_name
38
+ lastName: self.last_name,
39
+ zip: self.zipcode,
40
+ email: self.email,
41
+ dob: self.sex,
42
+ ssn: self.document,
43
+ sex: self.sex
39
44
  }
40
45
  end
41
46
  end
@@ -1,8 +1,11 @@
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
4
5
  def initialize(options = {})
5
- self.customer_id_ext = options[:customer_id_ext]
6
+ self.customer_id = options[:customer_id]
7
+ self.token = options[:token]
8
+ self.ip_address = options[:ip_address]
6
9
  self.reference_number = options[:reference_number]
7
10
  self.charge_total = options[:charge_total]
8
11
  end
@@ -13,5 +16,27 @@ module MaxipagoApi
13
16
 
14
17
  def find
15
18
  end
19
+
20
+ def to_object
21
+ {
22
+ sale: {
23
+ processorID: 1,
24
+ referenceNum: self.reference_number,
25
+ ipAddress: self.ip_address,
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
+ }
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,19 @@
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
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module MaxipagoApi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.1
4
+ version: 0.1.2
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-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,8 @@ 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
94
96
  - maxipago_api.gemspec
95
97
  homepage: https://github.com/sidneip
96
98
  licenses: