pagseguro-oficial 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -7
  3. data/CHANGELOG.md +9 -3
  4. data/README.md +26 -8
  5. data/examples/abandoned_transactions.rb +16 -4
  6. data/examples/authorization.rb +31 -0
  7. data/examples/authorization_by_code.rb +29 -0
  8. data/examples/authorization_by_notification_code.rb +30 -0
  9. data/examples/boleto_transaction_request.rb +6 -0
  10. data/examples/boot.rb +19 -2
  11. data/examples/create_session.rb +6 -0
  12. data/examples/credit_card_transaction_request.rb +6 -0
  13. data/examples/installment.rb +21 -11
  14. data/examples/invalid_transaction_by_notification_code.rb +14 -1
  15. data/examples/online_debit_transaction.rb +6 -0
  16. data/examples/payment_request.rb +11 -0
  17. data/examples/transaction_by_code.rb +23 -9
  18. data/examples/transaction_by_notification_code.rb +22 -9
  19. data/examples/transaction_by_reference.rb +13 -1
  20. data/examples/transactions_by_date.rb +17 -1
  21. data/lib/pagseguro/account_credentials.rb +14 -0
  22. data/lib/pagseguro/application_credentials.rb +18 -0
  23. data/lib/pagseguro/authorization/collection.rb +26 -0
  24. data/lib/pagseguro/authorization/request_serializer.rb +24 -0
  25. data/lib/pagseguro/authorization/response.rb +49 -0
  26. data/lib/pagseguro/authorization/response_serializer.rb +39 -0
  27. data/lib/pagseguro/authorization.rb +52 -0
  28. data/lib/pagseguro/authorization_request/request_serializer.rb +30 -0
  29. data/lib/pagseguro/authorization_request/response.rb +26 -0
  30. data/lib/pagseguro/authorization_request/response_serializer.rb +18 -0
  31. data/lib/pagseguro/authorization_request.rb +72 -0
  32. data/lib/pagseguro/config.rb +20 -0
  33. data/lib/pagseguro/errors.rb +1 -0
  34. data/lib/pagseguro/extensions/credentiable.rb +17 -0
  35. data/lib/pagseguro/installment.rb +4 -2
  36. data/lib/pagseguro/notification/authorization.rb +15 -0
  37. data/lib/pagseguro/notification/transaction.rb +15 -0
  38. data/lib/pagseguro/notification.rb +0 -10
  39. data/lib/pagseguro/payment_request/serializer.rb +1 -0
  40. data/lib/pagseguro/payment_request.rb +2 -13
  41. data/lib/pagseguro/permission.rb +13 -0
  42. data/lib/pagseguro/request.rb +37 -5
  43. data/lib/pagseguro/transaction/search/search_abandoned.rb +2 -1
  44. data/lib/pagseguro/transaction/search/search_by_date.rb +2 -1
  45. data/lib/pagseguro/transaction/search/search_by_reference.rb +1 -0
  46. data/lib/pagseguro/transaction.rb +27 -25
  47. data/lib/pagseguro/version.rb +1 -1
  48. data/lib/pagseguro.rb +57 -14
  49. data/locales/pt-BR.yml +1 -0
  50. data/pagseguro-oficial.gemspec +0 -1
  51. data/spec/fixtures/authorization/find_authorization.xml +17 -0
  52. data/spec/fixtures/authorization_request/success.xml +4 -0
  53. data/spec/pagseguro/account_credentials_spec.rb +10 -0
  54. data/spec/pagseguro/application_credentials_spec.rb +11 -0
  55. data/spec/pagseguro/authorization/collection_spec.rb +49 -0
  56. data/spec/pagseguro/authorization/request_serializer_spec.rb +11 -0
  57. data/spec/pagseguro/authorization/response_serializer_spec.rb +19 -0
  58. data/spec/pagseguro/authorization/response_spec.rb +35 -0
  59. data/spec/pagseguro/authorization_request/request_serializer_spec.rb +23 -0
  60. data/spec/pagseguro/authorization_request/response_serializer_spec.rb +15 -0
  61. data/spec/pagseguro/authorization_request/response_spec.rb +36 -0
  62. data/spec/pagseguro/authorization_request_spec.rb +62 -0
  63. data/spec/pagseguro/authorization_spec.rb +69 -0
  64. data/spec/pagseguro/errors_spec.rb +17 -5
  65. data/spec/pagseguro/installment/response_spec.rb +3 -1
  66. data/spec/pagseguro/installment_spec.rb +1 -1
  67. data/spec/pagseguro/notification_spec.rb +0 -12
  68. data/spec/pagseguro/pagseguro_spec.rb +15 -15
  69. data/spec/pagseguro/payment_request/serializer_spec.rb +10 -0
  70. data/spec/pagseguro/payment_request_spec.rb +0 -31
  71. data/spec/pagseguro/permission_spec.rb +7 -0
  72. data/spec/pagseguro/request_spec.rb +25 -5
  73. data/spec/pagseguro/session/response_spec.rb +2 -1
  74. data/spec/pagseguro/session_spec.rb +2 -1
  75. data/spec/pagseguro/transaction/search/search_abandoned_spec.rb +15 -0
  76. data/spec/pagseguro/transaction/search_spec.rb +1 -1
  77. data/spec/pagseguro/transaction_request/response_spec.rb +1 -1
  78. data/spec/pagseguro/transaction_request_spec.rb +1 -1
  79. data/spec/pagseguro/transaction_spec.rb +34 -1
  80. data/spec/spec_helper.rb +0 -1
  81. data/spec/support/shared_examples_for_configuration.rb +3 -1
  82. metadata +49 -16
@@ -0,0 +1,49 @@
1
+ module PagSeguro
2
+ class Authorization
3
+ class Response
4
+ def initialize(response, object)
5
+ @response = response
6
+ @object = object
7
+ end
8
+
9
+ def serialize
10
+ if success?
11
+ xml = Nokogiri::XML(response.body).css('authorization').first
12
+ serializer = ResponseSerializer.new(xml).serialize
13
+ object.update_attributes(serializer)
14
+ else
15
+ object.errors.add(response)
16
+ end
17
+
18
+ object
19
+ end
20
+
21
+ def serialize_collection
22
+ if success?
23
+ object.authorizations = serialize_authorizations
24
+ else
25
+ object.errors.add(response)
26
+ end
27
+
28
+ object
29
+ end
30
+
31
+ def success?
32
+ (response.success? && response.xml?) ? true : false
33
+ end
34
+
35
+ private
36
+ # The request response.
37
+ attr_reader :response
38
+
39
+ # The PagSeguro::Authorization or PagSeguro::Authorization::Collection object
40
+ attr_reader :object
41
+
42
+ def serialize_authorizations
43
+ Nokogiri::XML(response.body).css('authorizations > authorization').map do |node|
44
+ ResponseSerializer.new(node).serialize
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,39 @@
1
+ module PagSeguro
2
+ class Authorization
3
+ class ResponseSerializer
4
+
5
+ def initialize(xml)
6
+ @xml = xml
7
+ end
8
+
9
+ def serialize
10
+ {}.tap do |data|
11
+ serialize_general(data)
12
+ serialize_permissions(data)
13
+ end
14
+ end
15
+
16
+ private
17
+ def serialize_general(data)
18
+ data[:code] = xml.css("> code").text
19
+ data[:reference] = xml.css("reference").text
20
+ data[:created_at] = Time.parse xml.css("creationDate").text
21
+ end
22
+
23
+ def serialize_permissions(data)
24
+ data[:permissions] = []
25
+
26
+ xml.css("permission").each do |node|
27
+ permission = PagSeguro::Permission.new
28
+ permission.code = node.css("code").text
29
+ permission.status = node.css("status").text
30
+ permission.last_update = node.css("lastUpdate").text
31
+
32
+ data[:permissions] << permission
33
+ end
34
+ end
35
+
36
+ attr_reader :xml
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,52 @@
1
+ module PagSeguro
2
+ class Authorization
3
+ include Extensions::MassAssignment
4
+ include Extensions::Credentiable
5
+
6
+ # The authorization code
7
+ attr_accessor :code
8
+
9
+ # The authorization creation date
10
+ attr_accessor :created_at
11
+
12
+ # The reference related to the authorization
13
+ attr_accessor :reference
14
+
15
+ # The authorization permissions
16
+ attr_accessor :permissions
17
+
18
+ # Find an authorization by it's notification code
19
+ def self.find_by_notification_code(code, options = {})
20
+ request = Request.get("authorizations/notifications/#{code}", "v2", options)
21
+ authorization = PagSeguro::Authorization.new
22
+ Response.new(request, authorization).serialize
23
+
24
+ authorization
25
+ end
26
+
27
+ # Find an authorization by it's code
28
+ def self.find_by_code(code, options = {})
29
+ request = Request.get("authorizations/#{code}", "v2", options)
30
+ authorization = PagSeguro::Authorization.new
31
+ Response.new(request, authorization).serialize
32
+
33
+ authorization
34
+ end
35
+
36
+ def self.find_by_date(options)
37
+ request = Request.get("authorizations", "v2", RequestSerializer.new(options).to_params)
38
+ collection = Collection.new
39
+ Response.new(request, collection).serialize_collection
40
+
41
+ collection
42
+ end
43
+
44
+ def update_attributes(attrs)
45
+ attrs.map { |name, value| send("#{name}=", value) }
46
+ end
47
+
48
+ def errors
49
+ @errors ||= Errors.new
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,30 @@
1
+ module PagSeguro
2
+ class AuthorizationRequest
3
+ class RequestSerializer
4
+ attr_reader :authorization_request
5
+
6
+ def initialize(authorization_request)
7
+ @authorization_request = authorization_request
8
+ end
9
+
10
+ def to_params
11
+ params[:credentials] = authorization_request.credentials if authorization_request.credentials
12
+ params[:notificationURL] = authorization_request.notification_url
13
+ params[:redirectURL] = authorization_request.redirect_url
14
+ params[:permissions] = serialize_permissions(authorization_request.permissions)
15
+ params[:reference] = authorization_request.reference if authorization_request.reference
16
+
17
+ params
18
+ end
19
+
20
+ private
21
+ def params
22
+ @params ||= {}
23
+ end
24
+
25
+ def serialize_permissions(permissions)
26
+ permissions.map { |value| PagSeguro::AuthorizationRequest::PERMISSIONS[value] }.join(',')
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ module PagSeguro
2
+ class AuthorizationRequest
3
+ class Response
4
+ def initialize(response)
5
+ @response = response
6
+ end
7
+
8
+ def serialize
9
+ if response.success? && response.xml?
10
+ xml = Nokogiri::XML(response.body).css('authorizationRequest').first
11
+ ResponseSerializer.new(xml).serialize
12
+ else
13
+ { errors: Errors.new(response) }
14
+ end
15
+ end
16
+
17
+ def success?
18
+ (response.success? && response.xml?) ? true : false
19
+ end
20
+
21
+ private
22
+ # The request response.
23
+ attr_reader :response
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ module PagSeguro
2
+ class AuthorizationRequest
3
+ class ResponseSerializer
4
+ attr_reader :xml
5
+
6
+ def initialize(xml)
7
+ @xml = xml
8
+ end
9
+
10
+ def serialize
11
+ {}.tap do |data|
12
+ data[:code] = xml.css("> code").text
13
+ data[:date] = Time.parse xml.css("date").text
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,72 @@
1
+ module PagSeguro
2
+ class AuthorizationRequest
3
+ include Extensions::MassAssignment
4
+ include Extensions::Credentiable
5
+
6
+ # The permissions given to the application
7
+ # Defaults to all permissions
8
+ attr_accessor :permissions
9
+
10
+ # The seller reference (optional)
11
+ attr_accessor :reference
12
+
13
+ # The url which PagSeguro can send notifications
14
+ attr_accessor :notification_url
15
+
16
+ # The url which the application is going to be redirected after the proccess
17
+ attr_accessor :redirect_url
18
+
19
+ # The code used to confirm the authorization
20
+ attr_reader :code
21
+
22
+ # The date of authorization creation
23
+ attr_reader :date
24
+
25
+ # Errors object.
26
+ attr_writer :errors
27
+
28
+ PERMISSIONS = {
29
+ checkouts: 'CREATE_CHECKOUTS',
30
+ notifications: 'RECEIVE_TRANSACTION_NOTIFICATIONS',
31
+ searches: 'SEARCH_TRANSACTIONS',
32
+ pre_approvals: 'MANAGE_PAYMENT_PRE_APPROVALS',
33
+ payments: 'DIRECT_PAYMENT',
34
+ refunds: 'REFUND_TRANSACTIONS',
35
+ cancels: 'CANCEL_TRANSACTIONS'
36
+ }
37
+
38
+ # Post and create an Authorization.
39
+ # Return Boolean.
40
+ def create
41
+ request = Request.post('authorizations/request', 'v2', params)
42
+ response = Response.new(request)
43
+ update_attributes(response.serialize)
44
+
45
+ response.success?
46
+ end
47
+
48
+ # URL to confirm authorization after create one.
49
+ def url
50
+ PagSeguro.site_url("v2/authorization/request.jhtml?code=#{code}") if code
51
+ end
52
+
53
+ def errors
54
+ @errors ||= Errors.new
55
+ end
56
+
57
+ private
58
+ attr_writer :code, :date
59
+
60
+ def before_initialize
61
+ self.permissions = PERMISSIONS.keys
62
+ end
63
+
64
+ def params
65
+ RequestSerializer.new(self).to_params
66
+ end
67
+
68
+ def update_attributes(attrs)
69
+ attrs.each { |method, value| send("#{method}=", value) }
70
+ end
71
+ end
72
+ end
@@ -10,5 +10,25 @@ module PagSeguro
10
10
 
11
11
  # The API token associated with this account.
12
12
  attr_accessor :token
13
+
14
+ # The application id
15
+ attr_accessor :app_id
16
+
17
+ # A token related to the application that is making the requests
18
+ attr_accessor :app_key
19
+
20
+ # The PagSeguro environment.
21
+ # +production+ or +sandbox+.
22
+ # Defaults to +production+.
23
+ attr_accessor :environment
24
+
25
+ # The encoding that will be used.
26
+ # Defaults to +UTF-8+.
27
+ attr_accessor :encoding
28
+
29
+ def initialize
30
+ @environment = :production
31
+ @encoding = "UTF-8"
32
+ end
13
33
  end
14
34
  end
@@ -21,6 +21,7 @@ module PagSeguro
21
21
  private
22
22
  def process(response)
23
23
  @messages << error_message(:unauthorized, "Unauthorized") if response.unauthorized?
24
+ @messages << error_message(:not_found, "Not found") if response.not_found?
24
25
 
25
26
  response.data.css("errors > error").each do |error|
26
27
  @messages << error_message(error.css("code").text, error.css("message").text)
@@ -0,0 +1,17 @@
1
+ module PagSeguro
2
+ module Extensions
3
+ module Credentiable
4
+ # Get the credential object value
5
+ attr_reader :credentials
6
+
7
+ # Set a credential object
8
+ def credentials=(credentials)
9
+ if credentials.kind_of?(ApplicationCredentials) || credentials.kind_of?(AccountCredentials)
10
+ @credentials = credentials
11
+ else
12
+ raise 'Invalid credentials object'
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -20,9 +20,10 @@ module PagSeguro
20
20
 
21
21
  # Find installment options by a given amount
22
22
  # Optional. Credit card brand
23
+
23
24
  # Return a PagSeguro::Installment::Collection instance
24
- def self.find(amount, card_brand = nil)
25
- request = Request.get("installments", api_version, params(amount: amount, card_brand: card_brand))
25
+ def self.find(amount, card_brand, options = {})
26
+ request = Request.get("installments", api_version, options.merge(params(amount: amount, card_brand: card_brand)))
26
27
  collection = Collection.new
27
28
  Response.new(request, collection).serialize
28
29
 
@@ -30,6 +31,7 @@ module PagSeguro
30
31
  end
31
32
 
32
33
  private
34
+
33
35
  def self.params(options)
34
36
  RequestSerializer.new(options).to_params
35
37
  end
@@ -0,0 +1,15 @@
1
+ module PagSeguro
2
+ class Notification
3
+ class Authorization < PagSeguro::Notification
4
+ # Detect if the notification is from an authorization.
5
+ def authorization?
6
+ type == "applicationAuthorization"
7
+ end
8
+
9
+ # Fetch the authorization by its notificationCode.
10
+ def authorization
11
+ Authorization.find_by_notification_code(code)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module PagSeguro
2
+ class Notification
3
+ class Transaction < PagSeguro::Notification
4
+ # Detect if the notification is from a transaction.
5
+ def transaction?
6
+ type == "transaction"
7
+ end
8
+
9
+ # Fetch the transaction by its notificationCode.
10
+ def transaction
11
+ Transaction.find_by_notification_code(code)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -7,15 +7,5 @@ module PagSeguro
7
7
 
8
8
  # The notification type sent by PagSeguro.
9
9
  attr_accessor :type
10
-
11
- # Detect if the notification is from a transaction.
12
- def transaction?
13
- type == "transaction"
14
- end
15
-
16
- # Fetch the transaction by its notificationCode.
17
- def transaction
18
- Transaction.find_by_notification_code(code)
19
- end
20
10
  end
21
11
  end
@@ -9,6 +9,7 @@ module PagSeguro
9
9
  end
10
10
 
11
11
  def to_params
12
+ params[:credentials] = payment_request.credentials if payment_request.credentials
12
13
  params[:receiverEmail] = PagSeguro.receiver_email
13
14
  params[:currency] = payment_request.currency
14
15
  params[:reference] = payment_request.reference
@@ -2,6 +2,7 @@ module PagSeguro
2
2
  class PaymentRequest
3
3
  include Extensions::MassAssignment
4
4
  include Extensions::EnsureType
5
+ include Extensions::Credentiable
5
6
 
6
7
  # Set the payment currency.
7
8
  # Defaults to BRL.
@@ -51,12 +52,6 @@ module PagSeguro
51
52
  # complete the payment.
52
53
  attr_accessor :abandon_url
53
54
 
54
- # The email that identifies the request. Defaults to PagSeguro.email
55
- attr_accessor :email
56
-
57
- # The token that identifies the request. Defaults to PagSeguro.token
58
- attr_accessor :token
59
-
60
55
  # The extra parameters for payment request
61
56
  attr_accessor :extra_params
62
57
 
@@ -77,10 +72,7 @@ module PagSeguro
77
72
 
78
73
  # Calls the PagSeguro web service and register this request for payment.
79
74
  def register
80
- params = Serializer.new(self).to_params.merge({
81
- email: email,
82
- token: token
83
- })
75
+ params = Serializer.new(self).to_params
84
76
  Response.new Request.post("checkout", api_version, params)
85
77
  end
86
78
 
@@ -88,11 +80,8 @@ module PagSeguro
88
80
  def before_initialize
89
81
  self.extra_params = []
90
82
  self.currency = "BRL"
91
- self.email = PagSeguro.email
92
- self.token = PagSeguro.token
93
83
  end
94
84
 
95
- # The default PagSeguro API version
96
85
  def api_version
97
86
  'v2'
98
87
  end
@@ -0,0 +1,13 @@
1
+ module PagSeguro
2
+ class Permission
3
+ include Extensions::MassAssignment
4
+ # The permission code
5
+ attr_accessor :code
6
+
7
+ # The permission status
8
+ attr_accessor :status
9
+
10
+ # The time when the permission was last updated
11
+ attr_accessor :last_update
12
+ end
13
+ end
@@ -46,11 +46,13 @@ module PagSeguro
46
46
  end
47
47
 
48
48
  def extended_data(data)
49
- data.merge(
50
- email: data[:email] || PagSeguro.email,
51
- token: data[:token] || PagSeguro.token,
52
- charset: PagSeguro.encoding
53
- )
49
+ if data[:credentials]
50
+ data.merge!(credentials_object(data))
51
+ else
52
+ data.merge!(global_credentials(data))
53
+ end
54
+ data.merge!({ charset: PagSeguro.encoding })
55
+ data.delete_if { |key, value| value.nil? }
54
56
  end
55
57
 
56
58
  def extended_headers(request_method, headers)
@@ -69,6 +71,36 @@ module PagSeguro
69
71
  "Accept-Charset" => PagSeguro.encoding
70
72
  }
71
73
  end
74
+
75
+ def credentials_object(data)
76
+ credentials = data.delete(:credentials)
77
+ if credentials.respond_to? :app_id
78
+ {
79
+ appId: credentials.app_id,
80
+ appKey: credentials.app_key,
81
+ authorizationCode: credentials.authorization_code
82
+ }
83
+ else
84
+ {
85
+ email: credentials.email,
86
+ token: credentials.token
87
+ }
88
+ end
89
+ end
90
+
91
+ def global_credentials(data)
92
+ if PagSeguro.app_id && PagSeguro.app_key
93
+ {
94
+ appId: PagSeguro.app_id,
95
+ appKey: PagSeguro.app_key
96
+ }
97
+ else
98
+ {
99
+ email: data[:email] || PagSeguro.email,
100
+ token: data[:token] || PagSeguro.token
101
+ }
102
+ end
103
+ end
72
104
  end
73
105
 
74
106
  Request.configure do |config|
@@ -7,7 +7,8 @@ module PagSeguro
7
7
  initialDate: options[:starts_at].xmlschema,
8
8
  finalDate: options[:ends_at].xmlschema,
9
9
  page: page,
10
- maxPageResults: options.fetch(:per_page, 50)
10
+ maxPageResults: options.fetch(:per_page, 50),
11
+ credentials: options[:credentials]
11
12
  })
12
13
  @errors = Errors.new(@response)
13
14
  end
@@ -7,7 +7,8 @@ module PagSeguro
7
7
  initialDate: options[:starts_at].xmlschema,
8
8
  finalDate: options[:ends_at].xmlschema,
9
9
  page: page,
10
- maxPageResults: options.fetch(:per_page, 50)
10
+ maxPageResults: options.fetch(:per_page, 50),
11
+ credentials: options[:credentials]
11
12
  })
12
13
  @errors = Errors.new(@response)
13
14
  end
@@ -5,6 +5,7 @@ module PagSeguro
5
5
  @response = Request.get(@path, api_version,
6
6
  {
7
7
  reference: options[:reference],
8
+ credentials: options[:credentials]
8
9
  })
9
10
  @errors = Errors.new(@response)
10
11
  end
@@ -2,6 +2,7 @@ module PagSeguro
2
2
  class Transaction
3
3
  include Extensions::MassAssignment
4
4
  include Extensions::EnsureType
5
+ include Extensions::Credentiable
5
6
 
6
7
  # When the payment request was created.
7
8
  attr_accessor :created_at
@@ -65,14 +66,14 @@ module PagSeguro
65
66
 
66
67
  # Find a transaction by its transactionCode
67
68
  # Return a PagSeguro::Transaction instance
68
- def self.find_by_code(code)
69
- load_from_response send_request("transactions/#{code}")
69
+ def self.find_by_code(code, options = {})
70
+ load_from_response send_request("transactions/#{code}", options)
70
71
  end
71
72
 
72
73
  # Find a transaction by its notificationCode.
73
74
  # Return a PagSeguro::Transaction instance.
74
- def self.find_by_notification_code(code)
75
- load_from_response send_request("transactions/notifications/#{code}")
75
+ def self.find_by_notification_code(code, options = {})
76
+ load_from_response send_request("transactions/notifications/#{code}", options)
76
77
  end
77
78
 
78
79
  # Search transactions within a date range.
@@ -101,8 +102,8 @@ module PagSeguro
101
102
  #
102
103
  # # +reference+: the transaction reference code
103
104
  #
104
- def self.find_by_reference(reference)
105
- SearchByReference.new("transactions", { reference: reference })
105
+ def self.find_by_reference(reference, options = {})
106
+ SearchByReference.new("transactions", { reference: reference }.merge(options))
106
107
  end
107
108
 
108
109
  # Get abandoned transactions.
@@ -125,25 +126,6 @@ module PagSeguro
125
126
  SearchAbandoned.new("transactions/abandoned", options, page)
126
127
  end
127
128
 
128
- # Serialize the HTTP response into data.
129
- def self.load_from_response(response) # :nodoc:
130
- if response.success? and response.xml?
131
- load_from_xml Nokogiri::XML(response.body).css("transaction").first
132
- else
133
- Response.new Errors.new(response)
134
- end
135
- end
136
-
137
- # Send a get request to v3 API version, with the path given
138
- def self.send_request(path)
139
- Request.get(path, api_version)
140
- end
141
-
142
- # Serialize the XML object.
143
- def self.load_from_xml(xml) # :nodoc:
144
- new Serializer.new(xml).serialize
145
- end
146
-
147
129
  # Normalize creditor fees object
148
130
  def creditor_fees=(creditor_fees)
149
131
  @creditor_fees = ensure_type(CreditorFee, creditor_fees)
@@ -197,5 +179,25 @@ module PagSeguro
197
179
  def after_initialize
198
180
  @errors = Errors.new
199
181
  end
182
+
183
+ #
184
+ # Serialize the HTTP response into data.
185
+ def self.load_from_response(response) # :nodoc:
186
+ if response.success? and response.xml?
187
+ load_from_xml Nokogiri::XML(response.body).css("transaction").first
188
+ else
189
+ Response.new Errors.new(response)
190
+ end
191
+ end
192
+
193
+ # Send a get request to v3 API version, with the path given
194
+ def self.send_request(path, options)
195
+ Request.get(path, 'v3', options)
196
+ end
197
+
198
+ # Serialize the XML object.
199
+ def self.load_from_xml(xml) # :nodoc:
200
+ new Serializer.new(xml).serialize
201
+ end
200
202
  end
201
203
  end
@@ -1,3 +1,3 @@
1
1
  module PagSeguro
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end