Class: Paypal::Masspay
- Inherits:
-
Object
show all
- Defined in:
- lib/paypal/masspay.rb,
lib/paypal/masspay/version.rb
Defined Under Namespace
Classes: Configuration, Error, LengthValidator, Recipient, ResponseParser
Constant Summary
collapse
- SANDBOX_API_URL =
'https://api-3t.sandbox.paypal.com'
- PRODUCTION_API_URL =
'https://api-3t.paypal.com'
- API_PATH =
'/nvp'
- API_VERSION =
'2.3'
- IDENTIFIER =
'EmailAddress'
- METHOD =
'MassPay'
- MAX_PER_REQUEST =
250
- DEFAULT_CURRENCY =
'USD'
- DEFAULT_SUBJECT =
'Paypal Masspay'
- CURRENCY_MAX_LENGTH =
3
- SUBJECT_MAX_LENGTH =
255
- VERSION =
'1.1.0'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Masspay
Returns a new instance of Masspay.
28
29
30
31
32
33
34
35
36
|
# File 'lib/paypal/masspay.rb', line 28
def initialize(options = {}, &block)
build_options(options)
@success = true
@delivered = false
@errors = []
yield(self) if block_given?
end
|
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
26
27
28
|
# File 'lib/paypal/masspay.rb', line 26
def errors
@errors
end
|
Instance Method Details
#add_recipient(recipient) ⇒ Object
38
39
40
|
# File 'lib/paypal/masspay.rb', line 38
def add_recipient(recipient)
@recipients << recipient
end
|
#deliver ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/paypal/masspay.rb', line 42
def deliver
validate
connection = create_connection
@recipients.each_slice(MAX_PER_REQUEST) do |recipients_slice|
response = connection.post(API_PATH, request_data(recipients_slice))
check_response(response)
end
@delivered = true
end
|
#delivered? ⇒ Boolean
59
60
61
|
# File 'lib/paypal/masspay.rb', line 59
def delivered?
@delivered
end
|
#successful? ⇒ Boolean
55
56
57
|
# File 'lib/paypal/masspay.rb', line 55
def successful?
@success
end
|