Class: PagSeguro::AuthorizationRequest

Inherits:
Object
  • Object
show all
Includes:
Extensions::Credentiable, Extensions::EnsureType, Extensions::MassAssignment
Defined in:
lib/pagseguro/authorization_request.rb,
lib/pagseguro/authorization_request/response.rb,
lib/pagseguro/authorization_request/request_serializer.rb,
lib/pagseguro/authorization_request/response_serializer.rb

Defined Under Namespace

Classes: RequestSerializer, Response, ResponseSerializer

Constant Summary collapse

PERMISSIONS =
{
  checkouts: 'CREATE_CHECKOUTS',
  notifications: 'RECEIVE_TRANSACTION_NOTIFICATIONS',
  searches: 'SEARCH_TRANSACTIONS',
  pre_approvals: 'MANAGE_PAYMENT_PRE_APPROVALS',
  payments: 'DIRECT_PAYMENT',
  refunds: 'REFUND_TRANSACTIONS',
  cancels: 'CANCEL_TRANSACTIONS'
}

Instance Attribute Summary collapse

Attributes included from Extensions::Credentiable

#credentials

Instance Method Summary collapse

Methods included from Extensions::EnsureType

#ensure_type

Methods included from Extensions::MassAssignment

#initialize

Instance Attribute Details

#accountObject

The account that can be passed to register suggestion



21
22
23
# File 'lib/pagseguro/authorization_request.rb', line 21

def 
  @account
end

#codeObject

The code used to confirm the authorization



24
25
26
# File 'lib/pagseguro/authorization_request.rb', line 24

def code
  @code
end

#dateObject

The date of authorization creation



27
28
29
# File 'lib/pagseguro/authorization_request.rb', line 27

def date
  @date
end

#errorsObject



61
62
63
# File 'lib/pagseguro/authorization_request.rb', line 61

def errors
  @errors ||= Errors.new
end

#notification_urlObject

The url which PagSeguro can send notifications



15
16
17
# File 'lib/pagseguro/authorization_request.rb', line 15

def notification_url
  @notification_url
end

#permissionsObject

The permissions given to the application Defaults to all permissions



9
10
11
# File 'lib/pagseguro/authorization_request.rb', line 9

def permissions
  @permissions
end

#redirect_urlObject

The url which the application is going to be redirected after the proccess



18
19
20
# File 'lib/pagseguro/authorization_request.rb', line 18

def redirect_url
  @redirect_url
end

#referenceObject

The seller reference (optional)



12
13
14
# File 'lib/pagseguro/authorization_request.rb', line 12

def reference
  @reference
end

Instance Method Details

#createObject

Post and create an Authorization. Return Boolean.



48
49
50
51
52
53
54
# File 'lib/pagseguro/authorization_request.rb', line 48

def create
  request = Request.post_xml('authorizations/request', api_version, credentials, xml)
  response = Response.new(request)
  update_attributes(response.serialize)

  response.success?
end

#urlObject

URL to confirm authorization after create one.



57
58
59
# File 'lib/pagseguro/authorization_request.rb', line 57

def url
  PagSeguro.site_url("#{api_version}/authorization/request.jhtml?code=#{code}") if code
end