Class: PagSeguro::Payment

Inherits:
Request
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/pagseguro/payment.rb,
lib/pagseguro/payment/serializer.rb

Defined Under Namespace

Classes: Serializer

Constant Summary

Constants inherited from Request

Request::API_VERSIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#get, #post

Constructor Details

#initialize(options = {}) ⇒ Payment

Returns a new instance of Payment.



72
73
74
75
76
77
78
79
80
# File 'lib/pagseguro/payment.rb', line 72

def initialize(options = {})
  @currency = "BRL"
  @payment_mode = 'default'
  @notification_url = options[:notification_url]
  @payment_method = options[:payment_method]
  @reference = options[:reference] if options[:reference]
  @extra_amount = options[:extra_amount] if options[:extra_amount]
  @receiver_email = options[:receiver_email] if options[:receiver_email]
end

Instance Attribute Details

#bankObject

Set the bank name. Optional. Bank name should be used for eft payment method to specify which the buyer should be redirect.



46
47
48
# File 'lib/pagseguro/payment.rb', line 46

def bank
  @bank
end

#credit_cardObject

Get the payment sender.



39
40
41
# File 'lib/pagseguro/payment.rb', line 39

def credit_card
  @credit_card
end

#currencyObject

Set the payment currency. Defaults to BRL.



19
20
21
# File 'lib/pagseguro/payment.rb', line 19

def currency
  @currency
end

#extra_amountObject

Returns the value of attribute extra_amount.



50
51
52
# File 'lib/pagseguro/payment.rb', line 50

def extra_amount
  @extra_amount
end

#max_installment_no_interestObject

Set the max installment with no interest. Optional.



54
55
56
# File 'lib/pagseguro/payment.rb', line 54

def max_installment_no_interest
  @max_installment_no_interest
end

#notification_urlObject

Determines for which url PagSeguro will send the order related notifications codes. Optional. Any change happens in the transaction status, a new notification request will be send to this url. You can use that for update the related order.



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

def notification_url
  @notification_url
end

#payment_methodObject

Set the payment method. Payment method should be creditCard, boleto or eft.



23
24
25
# File 'lib/pagseguro/payment.rb', line 23

def payment_method
  @payment_method
end

#payment_modeObject

Set the payment mode



26
27
28
# File 'lib/pagseguro/payment.rb', line 26

def payment_mode
  @payment_mode
end

#receiver_emailObject

Returns the value of attribute receiver_email.



41
42
43
# File 'lib/pagseguro/payment.rb', line 41

def receiver_email
  @receiver_email
end

#referenceObject

Set the reference code. Optional. You can use the reference code to store an identifier so you can associate the PagSeguro transaction to a transaction in your system. Tipically this is the order id.



32
33
34
# File 'lib/pagseguro/payment.rb', line 32

def reference
  @reference
end

#senderObject

Get the payment sender.



35
36
37
# File 'lib/pagseguro/payment.rb', line 35

def sender
  @sender
end

#shippingObject

Returns the value of attribute shipping.



48
49
50
# File 'lib/pagseguro/payment.rb', line 48

def shipping
  @shipping
end

Instance Method Details

#itemsObject

Products/items in this payment request.



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

def items
  @items ||= Items.new
end

#items=(_items) ⇒ Object

Normalize the items list.



62
63
64
# File 'lib/pagseguro/payment.rb', line 62

def items=(_items)
  _items.each {|item| items << item }
end

#transaction(account = nil) ⇒ Object

Calls the PagSeguro web service and register this request for payment.



67
68
69
70
# File 'lib/pagseguro/payment.rb', line 67

def transaction( = nil)
  params = Serializer.new(self).to_params
  PagSeguro::Transaction.new post('/transactions', API_V2 ,, params).parsed_response
end