Class: PayPal::AdaptivePayments::Payment

Inherits:
Base
  • Object
show all
Defined in:
lib/paypal/adaptive_payments/payment.rb

Direct Known Subclasses

Response::Details

Instance Attribute Summary collapse

Attributes inherited from Base

#request_envelope

Instance Method Summary collapse

Methods inherited from Base

#request

Methods included from Common::Base

#after_initialize, #build_datetime, #build_value, #camelize, #hash_keys, #initialize, #request, #to_hash, #to_json, #underscore

Instance Attribute Details

#action_typeObject

Returns the value of attribute action_type.



4
5
6
# File 'lib/paypal/adaptive_payments/payment.rb', line 4

def action_type
  @action_type
end

#cancel_urlObject

Returns the value of attribute cancel_url.



5
6
7
# File 'lib/paypal/adaptive_payments/payment.rb', line 5

def cancel_url
  @cancel_url
end

#client_detailsObject

Returns the value of attribute client_details.



6
7
8
# File 'lib/paypal/adaptive_payments/payment.rb', line 6

def client_details
  @client_details
end

#currency_codeObject

Returns the value of attribute currency_code.



7
8
9
# File 'lib/paypal/adaptive_payments/payment.rb', line 7

def currency_code
  @currency_code
end

#fees_payerObject

Returns the value of attribute fees_payer.



8
9
10
# File 'lib/paypal/adaptive_payments/payment.rb', line 8

def fees_payer
  @fees_payer
end

#funding_constraintObject

Returns the value of attribute funding_constraint.



9
10
11
# File 'lib/paypal/adaptive_payments/payment.rb', line 9

def funding_constraint
  @funding_constraint
end

#ipn_notification_urlObject

Returns the value of attribute ipn_notification_url.



10
11
12
# File 'lib/paypal/adaptive_payments/payment.rb', line 10

def ipn_notification_url
  @ipn_notification_url
end

#memoObject

Returns the value of attribute memo.



11
12
13
# File 'lib/paypal/adaptive_payments/payment.rb', line 11

def memo
  @memo
end

#pay_keyObject

Returns the value of attribute pay_key.



12
13
14
# File 'lib/paypal/adaptive_payments/payment.rb', line 12

def pay_key
  @pay_key
end

#payment_info_listObject

Returns the value of attribute payment_info_list.



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

def payment_info_list
  @payment_info_list
end

#pinObject

Returns the value of attribute pin.



13
14
15
# File 'lib/paypal/adaptive_payments/payment.rb', line 13

def pin
  @pin
end

#preapproval_keyObject

Returns the value of attribute preapproval_key.



14
15
16
# File 'lib/paypal/adaptive_payments/payment.rb', line 14

def preapproval_key
  @preapproval_key
end

#receiver_listObject

Returns the value of attribute receiver_list.



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

def receiver_list
  @receiver_list
end

#responseObject

Returns the value of attribute response.



25
26
27
# File 'lib/paypal/adaptive_payments/payment.rb', line 25

def response
  @response
end

#return_urlObject

Returns the value of attribute return_url.



16
17
18
# File 'lib/paypal/adaptive_payments/payment.rb', line 16

def return_url
  @return_url
end

#reverse_all_parallel_payments_on_errorObject

Returns the value of attribute reverse_all_parallel_payments_on_error.



17
18
19
# File 'lib/paypal/adaptive_payments/payment.rb', line 17

def reverse_all_parallel_payments_on_error
  @reverse_all_parallel_payments_on_error
end

#senderObject

Returns the value of attribute sender.



18
19
20
# File 'lib/paypal/adaptive_payments/payment.rb', line 18

def sender
  @sender
end

#sender_emailObject

Returns the value of attribute sender_email.



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

def sender_email
  @sender_email
end

#tracking_idObject

Returns the value of attribute tracking_id.



20
21
22
# File 'lib/paypal/adaptive_payments/payment.rb', line 20

def tracking_id
  @tracking_id
end

#transaction_idObject

Returns the value of attribute transaction_id.



21
22
23
# File 'lib/paypal/adaptive_payments/payment.rb', line 21

def transaction_id
  @transaction_id
end

Instance Method Details

#createObject



44
45
46
47
# File 'lib/paypal/adaptive_payments/payment.rb', line 44

def create
  self.action_type = 'CREATE'
  run_pay
end

#detailsObject



63
64
65
# File 'lib/paypal/adaptive_payments/payment.rb', line 63

def details
  Response.process(:payment_details, request.run(:payment_details, self.to_hash(:pay_key, :transaction_id, :tracking_id)))
end

#payObject



49
50
51
52
53
54
55
56
# File 'lib/paypal/adaptive_payments/payment.rb', line 49

def pay
  if self.pay_key
    run_execute
  else
    self.action_type = 'PAY'
    run_pay
  end
end

#pay_primaryObject



58
59
60
61
# File 'lib/paypal/adaptive_payments/payment.rb', line 58

def pay_primary
  self.action_type = 'PAY_PRIMARY'
  run_pay
end

#payment_urlObject



85
86
87
# File 'lib/paypal/adaptive_payments/payment.rb', line 85

def payment_url
  self.response && self.response.payment_url
end

#receiverObject



36
37
38
# File 'lib/paypal/adaptive_payments/payment.rb', line 36

def receiver
  self.receiver_list.first
end

#receiver=(receiver) ⇒ Object



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

def receiver=(receiver)
  self.receiver_list.only(receiver)
end

#refundObject



71
72
73
# File 'lib/paypal/adaptive_payments/payment.rb', line 71

def refund
  Response.process(:refund, request.run(:refund, self.to_hash))
end

#run_executeObject



75
76
77
# File 'lib/paypal/adaptive_payments/payment.rb', line 75

def run_execute
  Response.process(:execute_payment, request.run(:execute_payment, self.to_hash(:pay_key)))
end

#run_payObject



79
80
81
82
83
# File 'lib/paypal/adaptive_payments/payment.rb', line 79

def run_pay
  self.response = Response.process(:pay, request.run(:pay, self.to_hash))
  self.pay_key = self.response.pay_key
  self.response
end

#set_funding_constraint(value) ⇒ Object



89
90
91
# File 'lib/paypal/adaptive_payments/payment.rb', line 89

def set_funding_constraint(value)
  self.funding_constraint = build_value(FundingConstraint, value)
end

#set_payment_info_list(value) ⇒ Object



93
94
95
# File 'lib/paypal/adaptive_payments/payment.rb', line 93

def set_payment_info_list(value)
  self.payment_info_list = build_value(PaymentInfoList, value)
end

#set_receiver(value) ⇒ Object



101
102
103
# File 'lib/paypal/adaptive_payments/payment.rb', line 101

def set_receiver(value)
  self.receiver = build_value(Receiver, value)
end

#set_sender(value) ⇒ Object



97
98
99
# File 'lib/paypal/adaptive_payments/payment.rb', line 97

def set_sender(value)
  self.sender = build_value(SenderIdentifier, value)
end

#shipping_addressesObject



67
68
69
# File 'lib/paypal/adaptive_payments/payment.rb', line 67

def shipping_addresses
  Response.process(:shipping_addresses, request.run(:shipping_addresses, self.to_hash(:key)))
end