maxipago 0.1.2 → 0.1.3
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 +4 -4
- data/.gitignore +45 -7
- data/LICENSE +21 -0
- data/lib/generators/maxipago/USAGE +3 -0
- data/lib/generators/maxipago/install_generator.rb +15 -0
- data/lib/generators/maxipago/templates/maxipago_config_template.rb +16 -0
- data/lib/maxipago.rb +9 -5
- data/lib/maxipago/client.rb +18 -0
- data/lib/maxipago/request_builder/api_request.rb +20 -0
- data/lib/maxipago/request_builder/rapi_request.rb +20 -0
- data/lib/maxipago/request_builder/request.rb +51 -0
- data/lib/maxipago/request_builder/transaction_request.rb +20 -0
- data/lib/maxipago/version.rb +1 -1
- data/lib/maxipago/xml_builder/builder.rb +37 -0
- data/lib/maxipago/xml_builder/builder_api.rb +146 -0
- data/lib/maxipago/xml_builder/builder_rapi.rb +73 -0
- data/lib/maxipago/xml_builder/builder_transaction.rb +505 -0
- data/maxipago.gemspec +2 -13
- metadata +29 -5
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/README.md +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38a9b28d9806f999c1e45bdcef0be0ab4d01a4b9f87af0970c75cc821f2ad5f4
|
4
|
+
data.tar.gz: e20e84d4e4938e848ff39d8601c9597ce31a40425d4350279ab9e7e04c1235b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35b561462a307d96edd6fb221d3bdabb5d1abceebbe7aa716ad83b18a312b7f070b2beeb20dbaf5bb51eada7f1d31febfa918b7e8c437edaffc6cf447214716e
|
7
|
+
data.tar.gz: d0c65121a1b3890b4efffbc058642825cd6af9bddb70130f111143d1c535e61d38733333362d58412e3adc5664a89f1aee4181bedb808bb220e41549d164598d
|
data/.gitignore
CHANGED
@@ -1,12 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
4
|
/coverage/
|
5
|
-
/
|
5
|
+
/InstalledFiles
|
6
6
|
/pkg/
|
7
7
|
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
8
11
|
/tmp/
|
9
12
|
|
10
|
-
#
|
11
|
-
.
|
12
|
-
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Leonardo Freitas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Maxipago
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
desc "Copy Maxipago initializer file"
|
7
|
+
source_root File.expand_path('../templates',__FILES__)
|
8
|
+
|
9
|
+
def copy_maxipago_config_file
|
10
|
+
puts "copy maxipago.rb in /config/initializers"
|
11
|
+
copy_file "maxipago_config_template.rb", "config/initializers/maxipago.rb"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Set your key and id
|
2
|
+
MP_APIKEY = ENV['MP_APIKEY']
|
3
|
+
MP_ID = ENV['MP_ID']
|
4
|
+
|
5
|
+
# Set the Maxipago API version: currently (3.1.1.15)
|
6
|
+
MP_APIVERSION = "3.1.1.15"
|
7
|
+
|
8
|
+
# Maxipago API Urls - production
|
9
|
+
MP_URL_TRANSACTION = "https://api.maxipago.net/UniversalAPI/postXML"
|
10
|
+
MP_URL_API = "https://api.maxipago.net/UniversalAPI/postAPI"
|
11
|
+
MP_URL_RAPI = "https://api.maxipago.net/ReportsAPI/servlet/ReportsAPI"
|
12
|
+
|
13
|
+
# Maxipago API Urls - development and test
|
14
|
+
URL_TEST_TRANSACTION = "https://testapi.maxipago.net/UniversalAPI/postXML"
|
15
|
+
URL_TEST_API = "https://testapi.maxipago.net/UniversalAPI/postAPI"
|
16
|
+
URL_TEST_RAPI = "https://testapi.maxipago.net/ReportsAPI/servlet/ReportsAPI"
|
data/lib/maxipago.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require "maxipago/version"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
require "maxipago/client"
|
3
|
+
require "maxipago/request_builder/request"
|
4
|
+
require "maxipago/request_builder/api_request"
|
5
|
+
require "maxipago/request_builder/rapi_request"
|
6
|
+
require "maxipago/request_builder/transaction_request"
|
7
|
+
require "maxipago/xml_builder/builder"
|
8
|
+
require "maxipago/xml_builder/builder_api"
|
9
|
+
require "maxipago/xml_builder/builder_rapi"
|
10
|
+
require "maxipago/xml_builder/builder_transaction"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Maxipago
|
2
|
+
class Client
|
3
|
+
APIVERSION = "3.1.1.15"
|
4
|
+
|
5
|
+
attr_reader :response, :request
|
6
|
+
|
7
|
+
def use(request)
|
8
|
+
@request = request
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute(opts = {})
|
12
|
+
raise "Sets the api type vefore execute commands." if request.nil?
|
13
|
+
raise ArgumentError, "Execute method needs options" if opts.empty?
|
14
|
+
|
15
|
+
@response = request.send_command(opts)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "net/https"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
module Maxipago
|
5
|
+
module RequestBuilder
|
6
|
+
class ApiRequest < Maxipago::RequestBuilder::Request
|
7
|
+
URL = ENV['MP_URL_API'] || "https://testeapi.maxipago.net/UniversalAPI/postAPI"
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def set_uri
|
12
|
+
@uri = URI.parse(URL)
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_xml(opts)
|
16
|
+
Maxipago::XmlBuilder::BuilderApi.new(@maxipagoId, @apiKey, @apiVersion, opts).get_xml_data
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "net_https"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
module Maxipago
|
5
|
+
module RequestBuilder
|
6
|
+
class RapiRequest < Maxipago::RequestBuilder::Request
|
7
|
+
URL = ENV[MP_URL_RAPI] || "https://testeapi.maxipago.net/ReportsAPI/servlet/ReportsAPI"
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def set_uri
|
12
|
+
@uri = URI.parse(opts)
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_xml(opts)
|
16
|
+
Maxipago::XmlBuilder::BuilderRapi.new(@maxipagoId, @apiKey, @apiVersion, opts).get_xml_data
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Maxipago
|
5
|
+
module RequestBuilder
|
6
|
+
class Request
|
7
|
+
def def initialize(maxipagoId, apiKey)
|
8
|
+
@maxipagoId = maxipagoId
|
9
|
+
@apiKey = apiKey
|
10
|
+
@apiVersion = Maxipago::Client::APIVERSION
|
11
|
+
@header = {"Content-Type" => 'text/xml'}
|
12
|
+
end
|
13
|
+
|
14
|
+
def send_command(opts)
|
15
|
+
xml = build_xml(opts)
|
16
|
+
send_request(xml)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def send_request(xml)
|
22
|
+
set_uri
|
23
|
+
set_http_session
|
24
|
+
|
25
|
+
@http_session.start {|http|
|
26
|
+
repsonse = http.post(@uri.path, xml, @header)
|
27
|
+
{header: response, body: response.body, message: response.message}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_uri
|
32
|
+
raise "This is an abstract method"
|
33
|
+
end
|
34
|
+
|
35
|
+
def buid_xml(opts)
|
36
|
+
raise "This is an abstract method"
|
37
|
+
end
|
38
|
+
|
39
|
+
def set_http_session
|
40
|
+
@http_session = Net::HTTP.new(@uri.host, @uri.port)
|
41
|
+
@http_session.use_ssl = true if @uri.scheme == "https"
|
42
|
+
set_ssl_mode if @http_session.use_ssl?
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_ssl_mode
|
46
|
+
@http_session.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
47
|
+
@http_session.ssl_timeout = 30
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "net/https"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
module Maxipago
|
5
|
+
module RequestBuilder
|
6
|
+
class TransactionRequest < Maxipago::RequestBuilder::Request
|
7
|
+
URL = ENV['MP_URL_TRANSACTION'] || "https://testapi.maxipago.net/UniversalAPI/postXML"
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def set_uri
|
12
|
+
@uri = URI.parse(URL)
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_xml
|
16
|
+
Maxipago::XmlBuilder::BuilderTransaction.new(@maxipagoId, @apiKey, @apiVersion, opts).get_xml_data
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/maxipago/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Maxipago
|
4
|
+
module XmlBuilder
|
5
|
+
class Builder
|
6
|
+
attr_reader :maxipagoId, :apiKey, :apiVersion, :command, :options
|
7
|
+
|
8
|
+
MAXIPAGO_COMMANDS = %w(add_consumer delete_consumer update_consumer add_card_onfile delete_card_onfile sale void reversal recurring cancel_recurring bank_bill online_debit save_on_file one_transaction_report list_transactions_report transaction_paginate authorization authentication capture)
|
9
|
+
|
10
|
+
def def initialize(maxipagoId, apiKey, apiVersion, apts)
|
11
|
+
@maxipagoId = maxipagoId
|
12
|
+
@apiKey = apiKey
|
13
|
+
@apiVersion = apiVersion
|
14
|
+
@command = opts[:command].downcase
|
15
|
+
@options = opts
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_xml_data
|
19
|
+
if command_defined?
|
20
|
+
build_xml_data
|
21
|
+
else
|
22
|
+
raise "Command not defined!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def command_defined?
|
29
|
+
MAXIPAGO_COMMANDS.include?(self.command)
|
30
|
+
end
|
31
|
+
|
32
|
+
def build_xml_data
|
33
|
+
method(self.command).call
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module Maxipago
|
2
|
+
module XmlBuilder
|
3
|
+
class BuilderApi < Maxipago::XmlBuilder::Builder
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def add_consumer
|
8
|
+
builder = Nokogiri::XML::Bulder.new(encoding: 'UTF-8') do |xml|
|
9
|
+
xml.send("api-request") {
|
10
|
+
xml.verification {
|
11
|
+
xml.merchantId maxipagoId
|
12
|
+
xml.merchantKey apiKey
|
13
|
+
}
|
14
|
+
xml.command "add-consumer"
|
15
|
+
xml.request {
|
16
|
+
xml.customerIdExt options[:customer_id_ext]
|
17
|
+
xml.firstName options[:firstname]
|
18
|
+
xml.lastName options[:lastname]
|
19
|
+
xml.address1 options[:address1] unless options[:address1].nil?
|
20
|
+
xml.address2 options[:address2] unless options[:address2].nil?
|
21
|
+
xml.city options[:city] unless options[:city].nil?
|
22
|
+
xml.state options[:state] unless options[:state].nil?
|
23
|
+
xml.zip options[:zip] unless options[:zip].nil?
|
24
|
+
xml.phone options[:phone] unless options[:phone].nil?
|
25
|
+
xml.email options[:email] unless options[:email].nil?
|
26
|
+
xml.dob options[:dob] unless options[:dob].nil?
|
27
|
+
xml.ssn options[:ssn] unless options[:ssn].nil?
|
28
|
+
xml.sex options[:sex] unless options[:sex].nil?
|
29
|
+
}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
builder.to_xml(indent: 2)
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_consumer
|
36
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
37
|
+
xml.send("api-request") {
|
38
|
+
xml.verification {
|
39
|
+
xml.merchantId self.maxipagoId
|
40
|
+
xml.merchantKey self.apiKey
|
41
|
+
}
|
42
|
+
xml.command "delete-consumer"
|
43
|
+
xml.request {
|
44
|
+
xml.customerId self.options[:customer_id]
|
45
|
+
}
|
46
|
+
}
|
47
|
+
end
|
48
|
+
builder.to_xml(indent: 2)
|
49
|
+
end
|
50
|
+
|
51
|
+
def update_consumer
|
52
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
53
|
+
xml.send("api-request") {
|
54
|
+
xml.verification {
|
55
|
+
xml.merchantId self.maxipagoId
|
56
|
+
xml.merchantKey self.apiKey
|
57
|
+
}
|
58
|
+
xml.command "update-consumer"
|
59
|
+
xml.request {
|
60
|
+
xml.customerId self.options[:customer_id]
|
61
|
+
xml.customerIdExt self.options[:customer_id_ext]
|
62
|
+
xml.firstName self.options[:firstname] unless self.options[:firstname].nil?
|
63
|
+
xml.lastName self.options[:lastname] unless self.options[:lastname].nil?
|
64
|
+
xml.address1 self.options[:address1] unless self.options[:address1].nil?
|
65
|
+
xml.address2 self.options[:address2] unless self.options[:address2].nil?
|
66
|
+
xml.city self.options[:city] unless self.options[:city].nil?
|
67
|
+
xml.state self.options[:state] unless self.options[:state].nil?
|
68
|
+
xml.zip self.options[:zip] unless self.options[:zip].nil?
|
69
|
+
xml.phone self.options[:phone] unless self.options[:phone].nil?
|
70
|
+
xml.email self.options[:email] unless self.options[:email].nil?
|
71
|
+
xml.dob self.options[:dob] unless self.options[:dob].nil?
|
72
|
+
xml.ssn self.options[:ssn] unless self.options[:ssn].nil?
|
73
|
+
xml.sex self.options[:sex] unless self.options[:sex].nil?
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
builder.to_xml(indent: 2)
|
78
|
+
end
|
79
|
+
|
80
|
+
def add_card_onfile
|
81
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
82
|
+
xml.send("api-request") {
|
83
|
+
xml.verification {
|
84
|
+
xml.merchantId self.maxipagoId
|
85
|
+
xml.merchantKey self.apiKey
|
86
|
+
}
|
87
|
+
xml.command "add-card-onfile"
|
88
|
+
xml.request {
|
89
|
+
xml.customerId self.options[:customer_id]
|
90
|
+
xml.creditCardNumber self.options[:credit_card_number]
|
91
|
+
xml.expirationMonth self.options[:expiration_month]
|
92
|
+
xml.expirationYear self.options[:expiration_year]
|
93
|
+
xml.billingName self.options[:billing_name]
|
94
|
+
xml.billingAddress1 self.options[:billing_address1]
|
95
|
+
xml.billingAddress2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
96
|
+
xml.billingCity self.options[:billing_city]
|
97
|
+
xml.billingState self.options[:billing_state]
|
98
|
+
xml.billingZip self.options[:billing_zip]
|
99
|
+
xml.billingCountry self.options[:billing_country]
|
100
|
+
xml.billingPhone self.options[:billing_phone]
|
101
|
+
xml.billingEmail self.options[:billing_email]
|
102
|
+
xml.onFileEndDate self.options[:onfile_end_date] unless self.options[:onfile_end_date].nil?
|
103
|
+
xml.onFilePermissions self.options[:onfile_permissions] unless self.options[:onfile_permissions].nil?
|
104
|
+
xml.onFileComment self.options[:onfile_comment] unless self.options[:onfile_comment].nil?
|
105
|
+
xml.onFileMaxChargeAmount self.options[:onfile_max_charge_amount] unless self.options[:onfile_max_charge_amount].nil?
|
106
|
+
}
|
107
|
+
}
|
108
|
+
end
|
109
|
+
builder.to_xml(indent: 2)
|
110
|
+
end
|
111
|
+
|
112
|
+
def delete_card_onfile
|
113
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
114
|
+
xml.send("api-request") {
|
115
|
+
xml.verification {
|
116
|
+
xml.merchantId self.maxipagoId
|
117
|
+
xml.merchantKey self.apiKey
|
118
|
+
}
|
119
|
+
xml.command "delete-card-onfile"
|
120
|
+
xml.request {
|
121
|
+
xml.customerId self.options[:customer_id]
|
122
|
+
xml.token self.options[:token]
|
123
|
+
}
|
124
|
+
}
|
125
|
+
end
|
126
|
+
builder.to_xml(indent: 2)
|
127
|
+
end
|
128
|
+
|
129
|
+
def cancel_recurring
|
130
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
131
|
+
xml.send("api-request") {
|
132
|
+
xml.verification {
|
133
|
+
xml.merchantId self.maxipagoId
|
134
|
+
xml.merchantKey self.apiKey
|
135
|
+
}
|
136
|
+
xml.command "cancel-recurring"
|
137
|
+
xml.request {
|
138
|
+
xml.orderID self.options[:order_id]
|
139
|
+
}
|
140
|
+
}
|
141
|
+
end
|
142
|
+
builder.to_xml(indent: 2)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Maxipago
|
2
|
+
module XmlBuilder
|
3
|
+
class BuilderRapi < Maxipago::XmlBuilder::Builder
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def one_transaction_report
|
8
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
9
|
+
xml.send("rapi-request") {
|
10
|
+
xml.verification {
|
11
|
+
xml.merchantId self.maxipagoId
|
12
|
+
xml.merchantKey self.apiKey
|
13
|
+
}
|
14
|
+
xml.command "transactionDetailReport"
|
15
|
+
xml.request {
|
16
|
+
xml.filterOptions {
|
17
|
+
xml.transactionId self.options[:transaction_id]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
builder.to_xml(indent: 2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def list_transactions_report
|
26
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
27
|
+
xml.send("rapi-request") {
|
28
|
+
xml.verification {
|
29
|
+
xml.merchantId self.maxipagoId
|
30
|
+
xml.merchantKey self.apiKey
|
31
|
+
}
|
32
|
+
xml.command "transactionDetailReport"
|
33
|
+
xml.request {
|
34
|
+
xml.filterOptions {
|
35
|
+
xml.period self.options[:period]
|
36
|
+
xml.pageSize self.options[:pagesize] unless self.options[:pagesize].nil?
|
37
|
+
xml.startDate self.options[:start_date] unless self.options[:start_date].nil?
|
38
|
+
xml.endDate self.options[:end_date] unless self.options[:end_date].nil?
|
39
|
+
xml.startTime self.options[:start_time] unless self.options[:start_time].nil?
|
40
|
+
xml.endTime self.options[:end_time] unless self.options[:end_time].nil?
|
41
|
+
xml.orderByName self.options[:order_by_name] unless self.options[:order_by_name].nil?
|
42
|
+
xml.orderByDirection self.options[:order_by_direction] unless self.options[:order_by_direction].nil?
|
43
|
+
xml.startRecordNumber self.options[:start_record_number] unless self.options[:start_record_number].nil?
|
44
|
+
xml.endRecordNumber self.options[:end_record_number] unless self.options[:end_record_number].nil?
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
builder.to_xml(indent: 2)
|
50
|
+
end
|
51
|
+
|
52
|
+
def transaction_paginate
|
53
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
54
|
+
xml.send("rapi-request") {
|
55
|
+
xml.version self.apiversion
|
56
|
+
xml.verification {
|
57
|
+
xml.merchantId self.maxipagoId
|
58
|
+
xml.merchantKey self.apiKey
|
59
|
+
}
|
60
|
+
xml.command "transactionDetailReport"
|
61
|
+
xml.request {
|
62
|
+
xml.filterOptions {
|
63
|
+
xml.pageToken self.options[:page_token]
|
64
|
+
xml.pageNumber self.options[:page_number]
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
end
|
69
|
+
builder.to_xml(indent: 2)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,505 @@
|
|
1
|
+
module Maxipago
|
2
|
+
module XmlBuilder
|
3
|
+
class BuilderTransaction < Maxipago::XmlBuilder::Builder
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def save_on_file
|
8
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
9
|
+
xml.send("transaction-request") {
|
10
|
+
xml.version self.apiversion
|
11
|
+
xml.verification {
|
12
|
+
xml.merchantId self.maxipagoId
|
13
|
+
xml.merchantKey self.apiKey
|
14
|
+
}
|
15
|
+
xml.order {
|
16
|
+
xml.sale {
|
17
|
+
xml.processorID self.options[:processor_id]
|
18
|
+
xml.referenceNum self.options[:reference_num]
|
19
|
+
xml.billing {
|
20
|
+
xml.name self.options[:billing_name] unless self.options[:billing_name].nil?
|
21
|
+
xml.address self.options[:billing_address] unless self.options[:billing_address].nil?
|
22
|
+
xml.address2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
23
|
+
xml.city self.options[:billing_city] unless self.options[:billing_city].nil?
|
24
|
+
xml.state self.options[:billing_state] unless self.options[:billing_state].nil?
|
25
|
+
xml.postalcode self.options[:billing_postalcode] unless self.options[:billing_postalcode].nil?
|
26
|
+
xml.country self.options[:billing_country] unless self.options[:billing_country].nil?
|
27
|
+
xml.phone self.options[:billing_phone] unless self.options[:billing_phone].nil?
|
28
|
+
xml.email self.options[:billing_email] unless self.options[:billing_email].nil?
|
29
|
+
}
|
30
|
+
xml.transactionDetail {
|
31
|
+
xml.payType {
|
32
|
+
xml.creditCard {
|
33
|
+
xml.number self.options[:number]
|
34
|
+
xml.expMonth self.options[:exp_month]
|
35
|
+
xml.expYear self.options[:exp_year]
|
36
|
+
xml.cvvNumber self.options[:cvv_number] unless self.options[:cvv_number].nil?
|
37
|
+
xml.eCommInd "eci"
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
xml.payment {
|
42
|
+
xml.chargeTotal self.options[:charge_total]
|
43
|
+
}
|
44
|
+
xml.saveOnFile {
|
45
|
+
xml.customerToken self.options[:customer_id]
|
46
|
+
xml.onFileEndDate self.options[:onfile_end_date] unless self.options[:onfile_end_date].nil?
|
47
|
+
xml.onFileComment self.options[:onfile_comment] unless self.options[:onfile_comment].nil?
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
builder.to_xml(indent: 2)
|
54
|
+
end
|
55
|
+
|
56
|
+
def authorization
|
57
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
58
|
+
xml.send("transaction-request") {
|
59
|
+
xml.version self.apiversion
|
60
|
+
xml.verification {
|
61
|
+
xml.merchantId self.maxipagoId
|
62
|
+
xml.merchantKey self.apiKey
|
63
|
+
}
|
64
|
+
xml.order {
|
65
|
+
xml.auth {
|
66
|
+
xml.fraudCheck self.options[:fraud_check] unless self.options[:fraud_check].nil?
|
67
|
+
xml.processorID self.options[:processor_id]
|
68
|
+
xml.fraudCheck self.options[:fraud_check] unless self.options[:fraud_check].nil?
|
69
|
+
xml.referenceNum self.options[:reference_num]
|
70
|
+
xml.ipAddress self.options[:ip_address] unless self.options[:ip_address].nil?
|
71
|
+
unless self.options[:billing_name].nil?
|
72
|
+
xml.billing {
|
73
|
+
xml.name self.options[:billing_name]
|
74
|
+
xml.address self.options[:billing_address] unless self.options[:billing_address].nil?
|
75
|
+
xml.address2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
76
|
+
xml.city self.options[:billing_city] unless self.options[:billing_city].nil?
|
77
|
+
xml.state self.options[:billing_state] unless self.options[:billing_state].nil?
|
78
|
+
xml.postalcode self.options[:billing_postalcode] unless self.options[:billing_postalcode].nil?
|
79
|
+
xml.country self.options[:billing_country] unless self.options[:billing_country].nil?
|
80
|
+
xml.phone self.options[:billing_phone] unless self.options[:billing_phone].nil?
|
81
|
+
xml.email self.options[:billing_email] unless self.options[:billing_email].nil?
|
82
|
+
}
|
83
|
+
end
|
84
|
+
unless self.options[:shipping_name].nil?
|
85
|
+
xml.shipping {
|
86
|
+
xml.name self.options[:shipping_name]
|
87
|
+
xml.address self.options[:shipping_address] unless self.options[:shipping_address].nil?
|
88
|
+
xml.address2 self.options[:shipping_address2] unless self.options[:shipping_address2].nil?
|
89
|
+
xml.city self.options[:shipping_city] unless self.options[:shipping_city].nil?
|
90
|
+
xml.state self.options[:shipping_state] unless self.options[:shipping_state].nil?
|
91
|
+
xml.postalcode self.options[:shipping_postalcode] unless self.options[:shipping_postalcode].nil?
|
92
|
+
xml.country self.options[:shipping_country] unless self.options[:shipping_country].nil?
|
93
|
+
xml.phone self.options[:shipping_phone] unless self.options[:shipping_phone].nil?
|
94
|
+
xml.email self.options[:shipping_email] unless self.options[:shipping_email].nil?
|
95
|
+
}
|
96
|
+
end
|
97
|
+
xml.transactionDetail {
|
98
|
+
xml.payType {
|
99
|
+
xml.creditCard {
|
100
|
+
xml.number self.options[:number]
|
101
|
+
xml.expMonth self.options[:exp_month]
|
102
|
+
xml.expYear self.options[:exp_year]
|
103
|
+
xml.cvvNumber self.options[:cvv_number] unless self.options[:cvv_number].nil?
|
104
|
+
xml.eCommInd "eci"
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
xml.payment {
|
109
|
+
xml.chargeTotal self.options[:charge_total]
|
110
|
+
unless self.options[:number_of_installments].nil?
|
111
|
+
xml.creditInstallment {
|
112
|
+
xml.numberOfInstallments self.options[:number_of_installments] unless self.options[:number_of_installments].nil?
|
113
|
+
xml.chargeInterest self.options[:charge_interest] unless self.options[:charge_interest].nil?
|
114
|
+
}
|
115
|
+
end
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
121
|
+
builder.to_xml(indent: 2)
|
122
|
+
end
|
123
|
+
|
124
|
+
def authentication
|
125
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
126
|
+
xml.send("transaction-request") {
|
127
|
+
xml.version self.apiversion
|
128
|
+
xml.verification {
|
129
|
+
xml.merchantId self.maxipagoId
|
130
|
+
xml.merchantKey self.apiKey
|
131
|
+
}
|
132
|
+
xml.order {
|
133
|
+
xml.auth {
|
134
|
+
xml.processorID self.options[:processor_id]
|
135
|
+
xml.authentication self.options[:authentication]
|
136
|
+
xml.referenceNum self.options[:reference_num]
|
137
|
+
xml.ipAddress self.options[:ip_address] unless self.options[:ip_address].nil?
|
138
|
+
unless self.options[:billing_name].nil?
|
139
|
+
xml.billing {
|
140
|
+
xml.name self.options[:billing_name]
|
141
|
+
xml.address self.options[:billing_address] unless self.options[:billing_address].nil?
|
142
|
+
xml.address2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
143
|
+
xml.city self.options[:billing_city] unless self.options[:billing_city].nil?
|
144
|
+
xml.state self.options[:billing_state] unless self.options[:billing_state].nil?
|
145
|
+
xml.postalcode self.options[:billing_postalcode] unless self.options[:billing_postalcode].nil?
|
146
|
+
xml.country self.options[:billing_country] unless self.options[:billing_country].nil?
|
147
|
+
xml.phone self.options[:billing_phone] unless self.options[:billing_phone].nil?
|
148
|
+
xml.email self.options[:billing_email] unless self.options[:billing_email].nil?
|
149
|
+
}
|
150
|
+
end
|
151
|
+
unless self.options[:shipping_name].nil?
|
152
|
+
xml.shipping {
|
153
|
+
xml.name self.options[:shipping_name]
|
154
|
+
xml.address self.options[:shipping_address] unless self.options[:shipping_address].nil?
|
155
|
+
xml.address2 self.options[:shipping_address2] unless self.options[:shipping_address2].nil?
|
156
|
+
xml.city self.options[:shipping_city] unless self.options[:shipping_city].nil?
|
157
|
+
xml.state self.options[:shipping_state] unless self.options[:shipping_state].nil?
|
158
|
+
xml.postalcode self.options[:shipping_postalcode] unless self.options[:shipping_postalcode].nil?
|
159
|
+
xml.country self.options[:shipping_country] unless self.options[:shipping_country].nil?
|
160
|
+
xml.phone self.options[:shipping_phone] unless self.options[:shipping_phone].nil?
|
161
|
+
xml.email self.options[:shipping_email] unless self.options[:shipping_email].nil?
|
162
|
+
}
|
163
|
+
end
|
164
|
+
xml.transactionDetail {
|
165
|
+
xml.payType {
|
166
|
+
xml.creditCard {
|
167
|
+
xml.number self.options[:number]
|
168
|
+
xml.expMonth self.options[:exp_month]
|
169
|
+
xml.expYear self.options[:exp_year]
|
170
|
+
xml.cvvNumber self.options[:cvv_number] unless self.options[:cvv_number].nil?
|
171
|
+
xml.eCommInd "eci"
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
xml.payment {
|
176
|
+
xml.chargeTotal self.options[:charge_total]
|
177
|
+
unless self.options[:number_of_installments].nil?
|
178
|
+
xml.creditInstallment {
|
179
|
+
xml.numberOfInstallments self.options[:number_of_installments]
|
180
|
+
xml.chargeInterest self.options[:charge_interest]
|
181
|
+
}
|
182
|
+
end
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
end
|
188
|
+
builder.to_xml(indent: 2)
|
189
|
+
end
|
190
|
+
|
191
|
+
# Use xml.capture! because capture is a Kernel method.
|
192
|
+
def capture
|
193
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
194
|
+
xml.send("transaction-request") {
|
195
|
+
xml.version self.apiversion
|
196
|
+
xml.verification {
|
197
|
+
xml.merchantId self.maxipagoId
|
198
|
+
xml.merchantKey self.apiKey
|
199
|
+
}
|
200
|
+
xml.order {
|
201
|
+
xml.capture! {
|
202
|
+
xml.orderID self.options[:order_id]
|
203
|
+
xml.referenceNum self.options[:reference_num]
|
204
|
+
xml.payment {
|
205
|
+
xml.chargeTotal self.options[:charge_total]
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
end
|
211
|
+
builder.to_xml(indent: 2)
|
212
|
+
end
|
213
|
+
|
214
|
+
def sale
|
215
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
216
|
+
xml.send("transaction-request") {
|
217
|
+
xml.version self.apiversion
|
218
|
+
xml.verification {
|
219
|
+
xml.merchantId self.maxipagoId
|
220
|
+
xml.merchantKey self.apiKey
|
221
|
+
}
|
222
|
+
xml.order {
|
223
|
+
xml.sale {
|
224
|
+
xml.processorID self.options[:processor_id]
|
225
|
+
xml.referenceNum self.options[:reference_num]
|
226
|
+
xml.fraudCheck self.options[:fraud_check] unless self.options[:fraud_check].nil?
|
227
|
+
xml.ipAddress self.options[:ip_address] unless self.options[:ip_address].nil?
|
228
|
+
unless self.options[:billing_name].nil?
|
229
|
+
xml.billing {
|
230
|
+
xml.name self.options[:billing_name]
|
231
|
+
xml.address self.options[:billing_address] unless self.options[:billing_address].nil?
|
232
|
+
xml.address2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
233
|
+
xml.city self.options[:billing_city] unless self.options[:billing_city].nil?
|
234
|
+
xml.state self.options[:billing_state] unless self.options[:billing_state].nil?
|
235
|
+
xml.postalcode self.options[:billing_postalcode] unless self.options[:billing_postalcode].nil?
|
236
|
+
xml.country self.options[:billing_country] unless self.options[:billing_country].nil?
|
237
|
+
xml.phone self.options[:billing_phone] unless self.options[:billing_phone].nil?
|
238
|
+
xml.email self.options[:billing_email] unless self.options[:billing_email].nil?
|
239
|
+
}
|
240
|
+
end
|
241
|
+
unless self.options[:shipping_name].nil?
|
242
|
+
xml.shipping {
|
243
|
+
xml.name self.options[:shipping_name]
|
244
|
+
xml.address self.options[:shipping_address] unless self.options[:shipping_address].nil?
|
245
|
+
xml.address2 self.options[:shipping_address2] unless self.options[:shipping_address2].nil?
|
246
|
+
xml.city self.options[:shipping_city] unless self.options[:shipping_city].nil?
|
247
|
+
xml.state self.options[:shipping_state] unless self.options[:shipping_state].nil?
|
248
|
+
xml.postalcode self.options[:shipping_postalcode] unless self.options[:shipping_postalcode].nil?
|
249
|
+
xml.country self.options[:shipping_country] unless self.options[:shipping_country].nil?
|
250
|
+
xml.phone self.options[:shipping_phone] unless self.options[:shipping_phone].nil?
|
251
|
+
xml.email self.options[:shipping_email] unless self.options[:shipping_email].nil?
|
252
|
+
}
|
253
|
+
end
|
254
|
+
xml.transactionDetail {
|
255
|
+
xml.payType {
|
256
|
+
if self.options[:token].nil?
|
257
|
+
xml.creditCard {
|
258
|
+
xml.number self.options[:number]
|
259
|
+
xml.expMonth self.options[:exp_month]
|
260
|
+
xml.expYear self.options[:exp_year]
|
261
|
+
xml.cvvNumber self.options[:cvv_number] unless self.options[:cvv_number].nil?
|
262
|
+
xml.eCommInd "eci"
|
263
|
+
}
|
264
|
+
else
|
265
|
+
xml.onFile {
|
266
|
+
xml.customerId self.options[:customer_id]
|
267
|
+
xml.token self.options[:token]
|
268
|
+
}
|
269
|
+
end
|
270
|
+
}
|
271
|
+
}
|
272
|
+
xml.payment {
|
273
|
+
xml.chargeTotal self.options[:charge_total]
|
274
|
+
unless self.options[:number_of_installments].nil?
|
275
|
+
xml.creditInstallment {
|
276
|
+
xml.numberOfInstallments self.options[:number_of_installments]
|
277
|
+
xml.chargeInterest self.options[:charge_interest] unless self.options[:charge_interest].nil?
|
278
|
+
}
|
279
|
+
end
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
end
|
285
|
+
builder.to_xml(indent: 2)
|
286
|
+
end
|
287
|
+
|
288
|
+
def void
|
289
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
290
|
+
xml.send("transaction-request") {
|
291
|
+
xml.version self.apiversion
|
292
|
+
xml.verification {
|
293
|
+
xml.merchantId self.maxipagoId
|
294
|
+
xml.merchantKey self.apiKey
|
295
|
+
}
|
296
|
+
xml.order {
|
297
|
+
xml.void {
|
298
|
+
xml.transactionID self.options[:transaction_id]
|
299
|
+
}
|
300
|
+
}
|
301
|
+
}
|
302
|
+
end
|
303
|
+
builder.to_xml(indent: 2)
|
304
|
+
end
|
305
|
+
|
306
|
+
def reversal
|
307
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
308
|
+
xml.send("transaction-request") {
|
309
|
+
xml.version self.apiversion
|
310
|
+
xml.verification {
|
311
|
+
xml.merchantId self.maxipagoId
|
312
|
+
xml.merchantKey self.apiKey
|
313
|
+
}
|
314
|
+
xml.order {
|
315
|
+
xml.return {
|
316
|
+
xml.orderID self.options[:order_id]
|
317
|
+
xml.referenceNum self.options[:reference_num]
|
318
|
+
xml.payment {
|
319
|
+
xml.chargeTotal self.options[:charge_total]
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
end
|
325
|
+
builder.to_xml(indent: 2)
|
326
|
+
end
|
327
|
+
|
328
|
+
def recurring
|
329
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
330
|
+
xml.send("transaction-request") {
|
331
|
+
xml.version self.apiversion
|
332
|
+
xml.verification {
|
333
|
+
xml.merchantId self.maxipagoId
|
334
|
+
xml.merchantKey self.apiKey
|
335
|
+
}
|
336
|
+
xml.order {
|
337
|
+
xml.recurringPayment {
|
338
|
+
xml.processorID self.options[:processor_id]
|
339
|
+
xml.referenceNum self.options[:reference_num]
|
340
|
+
xml.ipAddress self.options[:ip_address] unless self.options[:ip_address].nil?
|
341
|
+
unless self.options[:billing_name].nil?
|
342
|
+
xml.billing {
|
343
|
+
xml.name self.options[:billing_name]
|
344
|
+
xml.address self.options[:billing_address] unless self.options[:billing_address].nil?
|
345
|
+
xml.address2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
346
|
+
xml.city self.options[:billing_city] unless self.options[:billing_city].nil?
|
347
|
+
xml.state self.options[:billing_state] unless self.options[:billing_state].nil?
|
348
|
+
xml.postalcode self.options[:billing_postalcode] unless self.options[:billing_postalcode].nil?
|
349
|
+
xml.country self.options[:billing_country] unless self.options[:billing_country].nil?
|
350
|
+
xml.phone self.options[:billing_phone] unless self.options[:billing_phone].nil?
|
351
|
+
xml.email self.options[:billing_email] unless self.options[:billing_email].nil?
|
352
|
+
}
|
353
|
+
end
|
354
|
+
unless self.options[:shipping_name].nil?
|
355
|
+
xml.shipping {
|
356
|
+
xml.name self.options[:shipping_name]
|
357
|
+
xml.address self.options[:shipping_address] unless self.options[:shipping_address].nil?
|
358
|
+
xml.address2 self.options[:shipping_address2] unless self.options[:shipping_address2].nil?
|
359
|
+
xml.city self.options[:shipping_city] unless self.options[:shipping_city].nil?
|
360
|
+
xml.state self.options[:shipping_state] unless self.options[:shipping_state].nil?
|
361
|
+
xml.postalcode self.options[:shipping_postalcode] unless self.options[:shipping_postalcode].nil?
|
362
|
+
xml.country self.options[:shipping_country] unless self.options[:shipping_country].nil?
|
363
|
+
xml.phone self.options[:shipping_phone] unless self.options[:shipping_phone].nil?
|
364
|
+
xml.email self.options[:shipping_email] unless self.options[:shipping_email].nil?
|
365
|
+
}
|
366
|
+
end
|
367
|
+
xml.transactionDetail {
|
368
|
+
xml.payType {
|
369
|
+
if self.options[:token].nil?
|
370
|
+
xml.creditCard {
|
371
|
+
xml.number self.options[:number]
|
372
|
+
xml.expMonth self.options[:exp_month]
|
373
|
+
xml.expYear self.options[:exp_year]
|
374
|
+
xml.cvvNumber self.options[:cvv_number] unless self.options[:cvv_number].nil?
|
375
|
+
xml.eCommInd "eci"
|
376
|
+
}
|
377
|
+
else
|
378
|
+
xml.onFile {
|
379
|
+
xml.customerId self.options[:customer_id]
|
380
|
+
xml.token self.options[:token]
|
381
|
+
}
|
382
|
+
end
|
383
|
+
}
|
384
|
+
}
|
385
|
+
xml.payment {
|
386
|
+
xml.chargeTotal self.options[:charge_total]
|
387
|
+
}
|
388
|
+
xml.recurring {
|
389
|
+
xml.action "new"
|
390
|
+
xml.startDate self.options[:start_date]
|
391
|
+
xml.frequency self.options[:frequency]
|
392
|
+
xml.period self.options[:period]
|
393
|
+
xml.installments self.options[:installments]
|
394
|
+
xml.failureThreshold self.options[:failure_threshold]
|
395
|
+
}
|
396
|
+
}
|
397
|
+
}
|
398
|
+
}
|
399
|
+
end
|
400
|
+
builder.to_xml(indent: 2)
|
401
|
+
end
|
402
|
+
|
403
|
+
def bank_bill
|
404
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
405
|
+
xml.send("transaction-request") {
|
406
|
+
xml.version self.apiversion
|
407
|
+
xml.verification {
|
408
|
+
xml.merchantId self.maxipagoId
|
409
|
+
xml.merchantKey self.apiKey
|
410
|
+
}
|
411
|
+
xml.order {
|
412
|
+
xml.sale {
|
413
|
+
xml.processorID self.options[:processor_id]
|
414
|
+
xml.referenceNum self.options[:reference_num]
|
415
|
+
xml.ipAddress self.options[:ip_address] unless self.options[:ip_address].nil?
|
416
|
+
unless self.options[:billing_name].nil?
|
417
|
+
xml.billing {
|
418
|
+
xml.name self.options[:billing_name]
|
419
|
+
xml.address self.options[:billing_address] unless self.options[:billing_address].nil?
|
420
|
+
xml.address2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
421
|
+
xml.city self.options[:billing_city] unless self.options[:billing_city].nil?
|
422
|
+
xml.state self.options[:billing_state] unless self.options[:billing_state].nil?
|
423
|
+
xml.postalcode self.options[:billing_postalcode] unless self.options[:billing_postalcode].nil?
|
424
|
+
xml.country self.options[:billing_country] unless self.options[:billing_country].nil?
|
425
|
+
xml.phone self.options[:billing_phone] unless self.options[:billing_phone].nil?
|
426
|
+
xml.email self.options[:billing_email] unless self.options[:billing_email].nil?
|
427
|
+
}
|
428
|
+
end
|
429
|
+
unless self.options[:shipping_name].nil?
|
430
|
+
xml.shipping {
|
431
|
+
xml.name self.options[:shipping_name]
|
432
|
+
xml.address self.options[:shipping_address] unless self.options[:shipping_address].nil?
|
433
|
+
xml.address2 self.options[:shipping_address2] unless self.options[:shipping_address2].nil?
|
434
|
+
xml.city self.options[:shipping_city] unless self.options[:shipping_city].nil?
|
435
|
+
xml.state self.options[:shipping_state] unless self.options[:shipping_state].nil?
|
436
|
+
xml.postalcode self.options[:shipping_postalcode] unless self.options[:shipping_postalcode].nil?
|
437
|
+
xml.country self.options[:shipping_country] unless self.options[:shipping_country].nil?
|
438
|
+
xml.phone self.options[:shipping_phone] unless self.options[:shipping_phone].nil?
|
439
|
+
xml.email self.options[:shipping_email] unless self.options[:shipping_email].nil?
|
440
|
+
}
|
441
|
+
end
|
442
|
+
xml.transactionDetail {
|
443
|
+
xml.payType {
|
444
|
+
xml.boleto {
|
445
|
+
xml.expirationDate self.options[:expiration_date]
|
446
|
+
xml.number self.options[:number]
|
447
|
+
xml.instructions self.options[:instructions] unless self.options[:instructions].nil?
|
448
|
+
}
|
449
|
+
}
|
450
|
+
}
|
451
|
+
xml.payment {
|
452
|
+
xml.chargeTotal self.options[:charge_total]
|
453
|
+
}
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
end
|
458
|
+
builder.to_xml(indent: 2)
|
459
|
+
end
|
460
|
+
|
461
|
+
def online_debit
|
462
|
+
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
463
|
+
xml.send("transaction-request") {
|
464
|
+
xml.version self.apiversion
|
465
|
+
xml.verification {
|
466
|
+
xml.merchantId self.maxipagoId
|
467
|
+
xml.merchantKey self.apiKey
|
468
|
+
}
|
469
|
+
xml.order {
|
470
|
+
xml.sale {
|
471
|
+
xml.processorID self.options[:processor_id]
|
472
|
+
xml.referenceNum self.options[:reference_num]
|
473
|
+
xml.ipAddress self.options[:ip_address] unless self.options[:ip_address].nil?
|
474
|
+
unless self.options[:billing_name].nil?
|
475
|
+
xml.billing {
|
476
|
+
xml.name self.options[:billing_name]
|
477
|
+
xml.address self.options[:billing_address] unless self.options[:billing_address].nil?
|
478
|
+
xml.address2 self.options[:billing_address2] unless self.options[:billing_address2].nil?
|
479
|
+
xml.city self.options[:billing_city] unless self.options[:billing_city].nil?
|
480
|
+
xml.state self.options[:billing_state] unless self.options[:billing_state].nil?
|
481
|
+
xml.postalcode self.options[:billing_postalcode] unless self.options[:billing_postalcode].nil?
|
482
|
+
xml.country self.options[:billing_country] unless self.options[:billing_country].nil?
|
483
|
+
xml.phone self.options[:billing_phone] unless self.options[:billing_phone].nil?
|
484
|
+
xml.email self.options[:billing_email] unless self.options[:billing_email].nil?
|
485
|
+
}
|
486
|
+
end
|
487
|
+
xml.transactionDetail {
|
488
|
+
xml.payType {
|
489
|
+
xml.onlineDebit {
|
490
|
+
xml.parametersURL self.options[:parameters_url]
|
491
|
+
}
|
492
|
+
}
|
493
|
+
}
|
494
|
+
xml.payment {
|
495
|
+
xml.chargeTotal self.options[:charge_total]
|
496
|
+
}
|
497
|
+
}
|
498
|
+
}
|
499
|
+
}
|
500
|
+
end
|
501
|
+
builder.to_xml(indent: 2)
|
502
|
+
end
|
503
|
+
end
|
504
|
+
end
|
505
|
+
end
|
data/maxipago.gemspec
CHANGED
@@ -11,21 +11,9 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{This gem is to consume maxipago API}
|
13
13
|
spec.description = %q{This gem is to consume maxipago API}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/leotads/maxipago.git"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
# if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata["allowed_push_host"] = "https://github.com/leonardo-lfs/maxipago"
|
21
|
-
|
22
|
-
# spec.metadata["homepage_uri"] = spec.homepage
|
23
|
-
# spec.metadata["source_code_uri"] = "https://github.com/leonardo-lfs/maxipago"
|
24
|
-
# spec.metadata["changelog_uri"] = "https://github.com/leonardo-lfs/maxipago"
|
25
|
-
# else
|
26
|
-
# raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
-
# "public gem pushes."
|
28
|
-
# end
|
29
17
|
|
30
18
|
# Specify which files should be added to the gem when it is released.
|
31
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -36,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
36
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
25
|
spec.require_paths = ["lib"]
|
38
26
|
|
27
|
+
spec.add_dependency "nokogiri", '~> 1.6'
|
39
28
|
spec.add_development_dependency "bundler", "~> 1.17"
|
40
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
41
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxipago
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- leotads
|
@@ -10,6 +10,20 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,19 +74,29 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
63
|
-
- ".rspec"
|
64
|
-
- ".travis.yml"
|
65
77
|
- CODE_OF_CONDUCT.md
|
66
78
|
- Gemfile
|
79
|
+
- LICENSE
|
67
80
|
- LICENSE.txt
|
68
|
-
- README.md
|
69
81
|
- Rakefile
|
70
82
|
- bin/console
|
71
83
|
- bin/setup
|
84
|
+
- lib/generators/maxipago/USAGE
|
85
|
+
- lib/generators/maxipago/install_generator.rb
|
86
|
+
- lib/generators/maxipago/templates/maxipago_config_template.rb
|
72
87
|
- lib/maxipago.rb
|
88
|
+
- lib/maxipago/client.rb
|
89
|
+
- lib/maxipago/request_builder/api_request.rb
|
90
|
+
- lib/maxipago/request_builder/rapi_request.rb
|
91
|
+
- lib/maxipago/request_builder/request.rb
|
92
|
+
- lib/maxipago/request_builder/transaction_request.rb
|
73
93
|
- lib/maxipago/version.rb
|
94
|
+
- lib/maxipago/xml_builder/builder.rb
|
95
|
+
- lib/maxipago/xml_builder/builder_api.rb
|
96
|
+
- lib/maxipago/xml_builder/builder_rapi.rb
|
97
|
+
- lib/maxipago/xml_builder/builder_transaction.rb
|
74
98
|
- maxipago.gemspec
|
75
|
-
homepage: https://github.com/
|
99
|
+
homepage: https://github.com/leotads/maxipago.git
|
76
100
|
licenses:
|
77
101
|
- MIT
|
78
102
|
metadata: {}
|
data/.rspec
DELETED
data/.travis.yml
DELETED
data/README.md
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# Maxipago
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/maxipago`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'maxipago'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install maxipago
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/maxipago. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
-
|
41
|
-
## Code of Conduct
|
42
|
-
|
43
|
-
Everyone interacting in the Maxipago project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/maxipago/blob/master/CODE_OF_CONDUCT.md).
|