pp-adaptive 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. data/.gitignore +6 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +4 -0
  4. data/README.md +54 -0
  5. data/Rakefile +8 -0
  6. data/lib/pp-adaptive/abstract_request.rb +44 -0
  7. data/lib/pp-adaptive/abstract_response.rb +46 -0
  8. data/lib/pp-adaptive/cancel_preapproval_request.rb +7 -0
  9. data/lib/pp-adaptive/cancel_preapproval_response.rb +7 -0
  10. data/lib/pp-adaptive/client.rb +56 -0
  11. data/lib/pp-adaptive/convert_currency_request.rb +33 -0
  12. data/lib/pp-adaptive/convert_currency_response.rb +11 -0
  13. data/lib/pp-adaptive/execute_payment_request.rb +9 -0
  14. data/lib/pp-adaptive/execute_payment_response.rb +12 -0
  15. data/lib/pp-adaptive/get_payment_options_request.rb +7 -0
  16. data/lib/pp-adaptive/get_payment_options_response.rb +32 -0
  17. data/lib/pp-adaptive/pay_request.rb +64 -0
  18. data/lib/pp-adaptive/pay_response.rb +29 -0
  19. data/lib/pp-adaptive/payment_details_request.rb +9 -0
  20. data/lib/pp-adaptive/payment_details_response.rb +53 -0
  21. data/lib/pp-adaptive/preapproval_details_request.rb +8 -0
  22. data/lib/pp-adaptive/preapproval_details_response.rb +35 -0
  23. data/lib/pp-adaptive/preapproval_request.rb +36 -0
  24. data/lib/pp-adaptive/preapproval_response.rb +7 -0
  25. data/lib/pp-adaptive/refund_request.rb +14 -0
  26. data/lib/pp-adaptive/refund_response.rb +12 -0
  27. data/lib/pp-adaptive/set_payment_options_request.rb +33 -0
  28. data/lib/pp-adaptive/set_payment_options_response.rb +7 -0
  29. data/lib/pp-adaptive/support/aliases.rb +33 -0
  30. data/lib/pp-adaptive/support/coerced_array.rb +52 -0
  31. data/lib/pp-adaptive/support/json_model.rb +140 -0
  32. data/lib/pp-adaptive/support/node.rb +45 -0
  33. data/lib/pp-adaptive/support/node_list.rb +45 -0
  34. data/lib/pp-adaptive/types/account_identifier.rb +6 -0
  35. data/lib/pp-adaptive/types/address.rb +17 -0
  36. data/lib/pp-adaptive/types/address_list.rb +5 -0
  37. data/lib/pp-adaptive/types/aliases/receiver_aliases.rb +15 -0
  38. data/lib/pp-adaptive/types/aliases/receiver_list_aliases.rb +32 -0
  39. data/lib/pp-adaptive/types/base_address.rb +11 -0
  40. data/lib/pp-adaptive/types/client_details_type.rb +12 -0
  41. data/lib/pp-adaptive/types/currency_code.rb +5 -0
  42. data/lib/pp-adaptive/types/currency_conversion.rb +17 -0
  43. data/lib/pp-adaptive/types/currency_conversion_list.rb +15 -0
  44. data/lib/pp-adaptive/types/currency_conversion_table.rb +5 -0
  45. data/lib/pp-adaptive/types/currency_list.rb +5 -0
  46. data/lib/pp-adaptive/types/currency_type.rb +6 -0
  47. data/lib/pp-adaptive/types/display_options.rb +8 -0
  48. data/lib/pp-adaptive/types/error_data.rb +11 -0
  49. data/lib/pp-adaptive/types/error_list.rb +5 -0
  50. data/lib/pp-adaptive/types/fault_message.rb +23 -0
  51. data/lib/pp-adaptive/types/funding_constraint.rb +5 -0
  52. data/lib/pp-adaptive/types/funding_plan.rb +28 -0
  53. data/lib/pp-adaptive/types/funding_plan_charge.rb +11 -0
  54. data/lib/pp-adaptive/types/funding_source.rb +9 -0
  55. data/lib/pp-adaptive/types/funding_type_info.rb +5 -0
  56. data/lib/pp-adaptive/types/funding_type_list.rb +5 -0
  57. data/lib/pp-adaptive/types/initiating_entity.rb +15 -0
  58. data/lib/pp-adaptive/types/institution_customer.rb +11 -0
  59. data/lib/pp-adaptive/types/invoice_data.rb +7 -0
  60. data/lib/pp-adaptive/types/invoice_item.rb +9 -0
  61. data/lib/pp-adaptive/types/pay_error.rb +18 -0
  62. data/lib/pp-adaptive/types/pay_error_list.rb +5 -0
  63. data/lib/pp-adaptive/types/payment_info.rb +16 -0
  64. data/lib/pp-adaptive/types/payment_info_list.rb +5 -0
  65. data/lib/pp-adaptive/types/phone_number_type.rb +7 -0
  66. data/lib/pp-adaptive/types/receiver.rb +17 -0
  67. data/lib/pp-adaptive/types/receiver_identifier.rb +12 -0
  68. data/lib/pp-adaptive/types/receiver_list.rb +5 -0
  69. data/lib/pp-adaptive/types/receiver_options.rb +21 -0
  70. data/lib/pp-adaptive/types/refund_info.rb +20 -0
  71. data/lib/pp-adaptive/types/refund_info_list.rb +5 -0
  72. data/lib/pp-adaptive/types/request_envelope.rb +6 -0
  73. data/lib/pp-adaptive/types/response_envelope.rb +13 -0
  74. data/lib/pp-adaptive/types/sender_identifier.rb +5 -0
  75. data/lib/pp-adaptive/types/sender_options.rb +5 -0
  76. data/lib/pp-adaptive/version.rb +3 -0
  77. data/lib/pp-adaptive.rb +75 -0
  78. data/pp-adaptive.gemspec +25 -0
  79. data/spec/public/cancel_preapproval_request_spec.rb +15 -0
  80. data/spec/public/cancel_preapproval_response_spec.rb +6 -0
  81. data/spec/public/client_spec.rb +85 -0
  82. data/spec/public/convert_currency_request_spec.rb +29 -0
  83. data/spec/public/convert_currency_response_spec.rb +62 -0
  84. data/spec/public/execute_payment_request_spec.rb +30 -0
  85. data/spec/public/execute_payment_response_spec.rb +66 -0
  86. data/spec/public/get_payment_options_request_spec.rb +15 -0
  87. data/spec/public/get_payment_options_response_spec.rb +141 -0
  88. data/spec/public/json_model_spec.rb +56 -0
  89. data/spec/public/node_list_spec.rb +58 -0
  90. data/spec/public/node_spec.rb +54 -0
  91. data/spec/public/pay_request_spec.rb +150 -0
  92. data/spec/public/pay_response_spec.rb +197 -0
  93. data/spec/public/payment_details_request_spec.rb +30 -0
  94. data/spec/public/payment_details_response_spec.rb +211 -0
  95. data/spec/public/preapproval_details_request_spec.rb +25 -0
  96. data/spec/public/preapproval_details_response_spec.rb +200 -0
  97. data/spec/public/preapproval_request_spec.rb +110 -0
  98. data/spec/public/preapproval_response_spec.rb +14 -0
  99. data/spec/public/refund_request_spec.rb +57 -0
  100. data/spec/public/refund_response_spec.rb +116 -0
  101. data/spec/public/set_payment_options_request_spec.rb +136 -0
  102. data/spec/public/set_payment_options_response_spec.rb +6 -0
  103. data/spec/shared/a_fault_message.rb +60 -0
  104. data/spec/shared/a_request_envelope.rb +14 -0
  105. data/spec/shared/a_response_envelope.rb +36 -0
  106. data/spec/spec_helper.rb +6 -0
  107. metadata +225 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ \#*
6
+ .\#*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pp-adaptive.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # A Ruby API for PayPal Adaptive Payments
2
+
3
+ - Current Status: Work-in-progress (don't use, API subject to major change)
4
+ - Working:
5
+ - setting up an explicit preapproval
6
+ - processing payments (for an explicit preapproval)
7
+ - Not working:
8
+ - executing pre-created payments
9
+ - changing options on a created payment
10
+ - refunds/cancellations
11
+ - minor things like currency conversion requests
12
+
13
+ This gem provides access to PayPal's Adaptive Payments API using easy-to-use
14
+ ruby classes. The internals are largely backed by
15
+ [Virtus](https://github.com/solnic/virtus) and
16
+ [RestClient](https://github.com/archiloque/rest-client), and so are easy to
17
+ work with.
18
+
19
+ ## Installing the Gem
20
+
21
+ Via rubygems:
22
+
23
+ gem install pp-adaptive
24
+
25
+ ## Setting up a Preapproval Agreement
26
+
27
+ ``` ruby
28
+ require 'pp-adaptive'
29
+
30
+ client = AdaptivePayments::Client.new(
31
+ :user_id => "your-api-user-id",
32
+ :password => "your-api-password",
33
+ :signature => "your-api-signature",
34
+ :app_id => "your-app-id",
35
+ :sandbox => false
36
+ )
37
+
38
+ response = client.execute(AdaptivePayments::PreapprovalRequest.new(
39
+ :ending_date => DateTime.now.next_year,
40
+ :starting_date => DateTime.now,
41
+ :max_total_amount => BigDecimal("950.00"),
42
+ :currency_code => "USD",
43
+ :cancel_url => "http://site.com/cancelled",
44
+ :return_url => "http://site.com/completed"
45
+ ))
46
+
47
+ if response.success?
48
+ puts "Preapproval key: #{response.preapproval_key}"
49
+ else
50
+ puts "#{response.ack_code}: #{response.error_message}"
51
+ end
52
+ ```
53
+
54
+ (Work in progress...)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ task :default => :spec
5
+
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.pattern = 'spec/**/*_spec.rb'
8
+ end
@@ -0,0 +1,44 @@
1
+ module AdaptivePayments
2
+ # AbstractRequest is a JsonModel that defines some default behaviour for all requests
3
+ #
4
+ # A request defines the operation it executes and provides a method for building the corresponding response.
5
+ # All requests provide a RequestEnvelope by default. There is no need to re-define it in descendants.
6
+ class AbstractRequest < JsonModel
7
+ # The RequestEnvelope, providing the detail_level and error_language.
8
+ #
9
+ # Aliases are defined for #detail_level and #error_language. They do not need to be accessed through the
10
+ # request_envelope.
11
+ attribute :request_envelope, Node[RequestEnvelope], :param => "requestEnvelope"
12
+
13
+ alias_params :request_envelope, {
14
+ :detail_level => :detail_level,
15
+ :error_language => :error_language
16
+ }
17
+
18
+ class << self
19
+ # Set or get the API operation for the request class
20
+ #
21
+ # @param [Symbol] name
22
+ # the name of the operation defined in the Adaptive Payments API, optional
23
+ #
24
+ # @return [Symbol]
25
+ # the name of the operation defined in the Adaptive Payments API
26
+ def operation(name = nil)
27
+ @operation = name unless name.nil?
28
+ @operation
29
+ end
30
+
31
+ # Given a JSON string, return the corresponding response.
32
+ #
33
+ # @param [String] json
34
+ # the raw JSON string as returned by the API
35
+ #
36
+ # @return [AbstractResponse]
37
+ # the corresponding response for the JSON
38
+ def build_response(json)
39
+ klass = AdaptivePayments.const_get(operation.to_s + "Response")
40
+ klass.from_json(json.to_s)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,46 @@
1
+ module AdaptivePayments
2
+ # AbstractResponse provides a JsonModel with the default behaviour for all responses
3
+ #
4
+ # The ResponseEnvelope is already included by default. It does not need to be redeclared in descendants.
5
+ #
6
+ # All responses have FaultMessage behaviour mixed in, so will behave as a FaultMessage if the API returns one.
7
+ class AbstractResponse < JsonModel
8
+ include FaultMessage
9
+
10
+ # The ResponseEnvelope, encapsulating common information about the response
11
+ #
12
+ # All attributes #ack_code, #build, #correlation_id and #time are aliased as top-level attributes,
13
+ # so you do not need to access #response_envelope directly.
14
+ #
15
+ # @see #success?, #failure?, #warning?, #success_with_warning?, #failure_with_warning?
16
+ attribute :response_envelope, Node[ResponseEnvelope], :param => "responseEnvelope"
17
+
18
+ alias_params :response_envelope, {
19
+ :ack_code => :ack_code,
20
+ :build => :build,
21
+ :correlation_id => :correlation_id,
22
+ :time => :time
23
+ }
24
+
25
+ class << self
26
+ # Set or get the API operation
27
+ #
28
+ # This method should be called in descendants, but is not currently used.
29
+ #
30
+ # @param [Symbol] name
31
+ # the name of the API operation as defined by PayPal, optional
32
+ #
33
+ # @return [Symbol]
34
+ # the name of the API operation as defined by PayPal
35
+ def operation(name = nil)
36
+ @operation = name unless name.nil?
37
+ @operation
38
+ end
39
+ end
40
+
41
+ # Provide status predicates for the possible response ack codes
42
+ %w{success? failure? warning? success_with_warning? failure_with_warning?}.each do |method|
43
+ define_method(method) { response_envelope.send(method) }
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,7 @@
1
+ module AdaptivePayments
2
+ class CancelPreapprovalRequest < AbstractRequest
3
+ operation :CancelPreapproval
4
+
5
+ attribute :preapproval_key, String, :param => "preapprovalKey"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module AdaptivePayments
2
+ class CancelPreapprovalResponse < AbstractResponse
3
+ operation :CancelPreapproval
4
+
5
+ # no fields to define
6
+ end
7
+ end
@@ -0,0 +1,56 @@
1
+ require "rest-client"
2
+ require "virtus"
3
+
4
+ module AdaptivePayments
5
+ class Client
6
+ include Virtus
7
+
8
+ attribute :user_id, String, :header => "X-PAYPAL-SECURITY-USERID"
9
+ attribute :password, String, :header => "X-PAYPAL-SECURITY-PASSWORD"
10
+ attribute :signature, String, :header => "X-PAYPAL-SECURITY-SIGNATURE"
11
+ attribute :app_id, String, :header => "X-PAYPAL-APPLICATION-ID"
12
+ attribute :device_ip, String, :header => "X-PAYPAL-DEVICE-IPADDRESS"
13
+
14
+ def initialize(options = {})
15
+ super
16
+ self.sandbox = options[:sandbox]
17
+ end
18
+
19
+ def sandbox=(flag)
20
+ @sandbox = !!flag
21
+ end
22
+
23
+ def sandbox?
24
+ !!@sandbox
25
+ end
26
+
27
+ def execute(request)
28
+ base_url = if sandbox?
29
+ "https://svcs.sandbox.paypal.com/AdaptivePayments"
30
+ else
31
+ "https://svcs.paypal.com/AdaptivePayments"
32
+ end
33
+
34
+ resource = RestClient::Resource.new(base_url, :headers => headers)
35
+ response = resource[request.class.operation.to_s].post(
36
+ request.to_json,
37
+ :content_type => :json,
38
+ :accept => :json
39
+ )
40
+ request.class.build_response(response)
41
+ end
42
+
43
+ private
44
+
45
+ def headers
46
+ base_headers = {
47
+ "X-PAYPAL-RESPONSE-DATA-FORMAT" => "JSON",
48
+ "X-PAYPAL-REQUEST-DATA-FORMAT" => "JSON"
49
+ }
50
+ attributes.inject(base_headers) do |hash, (attr, value)|
51
+ next hash if value.nil?
52
+ hash.merge(self.class.attributes[attr].options[:header] => value)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,33 @@
1
+ module AdaptivePayments
2
+ class ConvertCurrencyRequest < AbstractRequest
3
+ operation :ConvertCurrency
4
+
5
+ attribute :base_amount_list, Node[CurrencyList], :param => "baseAmountList"
6
+ attribute :convert_to_currency_list, NodeList[CurrencyCode], :param => "convertToCurrencyList"
7
+ attribute :country_code, String, :param => "countryCode"
8
+ attribute :conversion_type, String, :param => "conversionType"
9
+
10
+ alias_params :base_amount_list, {
11
+ :currencies => :currencies
12
+ }
13
+
14
+ alias_params :first_currency, {
15
+ :amount => :amount,
16
+ :code => :code
17
+ }
18
+
19
+ def convert_to_currencies
20
+ convert_to_currency_list.collect { |info| info[:code] }
21
+ end
22
+
23
+ def convert_to_currencies=(list_of_currencies)
24
+ self.convert_to_currency_list = list_of_currencies.map { |t| { :code => t } }
25
+ end
26
+
27
+ private
28
+
29
+ def first_currency
30
+ currencies[0] ||= CurrencyList.new
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ module AdaptivePayments
2
+ class ConvertCurrencyResponse < AbstractResponse
3
+ operation :ConvertCurrency
4
+
5
+ attribute :estimated_amount_table, Node[CurrencyConversionTable], :param => "estimatedAmountTable"
6
+
7
+ alias_params :estimated_amount_table, {
8
+ :currency_conversions => :currency_conversion_list
9
+ }
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module AdaptivePayments
2
+ class ExecutePaymentRequest < AbstractRequest
3
+ operation :ExecutePayment
4
+
5
+ attribute :pay_key, String, :param => "payKey"
6
+ attribute :action_type, String, :param => "actionType"
7
+ attribute :funding_plan_id, String, :param => "fundingPlanId"
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module AdaptivePayments
2
+ class ExecutePaymentResponse < AbstractResponse
3
+ operation :ExecutePayment
4
+
5
+ attribute :payment_exec_status, String, :param => "paymentExecStatus"
6
+ attribute :pay_error_list, Node[PayErrorList], :param => "payErrorList"
7
+
8
+ alias_params :pay_error_list, {
9
+ :pay_errors => :pay_errors
10
+ }
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ module AdaptivePayments
2
+ class GetPaymentOptionsRequest < AbstractRequest
3
+ operation :GetPaymentOptions
4
+
5
+ attribute :pay_key, String, :param => "payKey"
6
+ end
7
+ end
@@ -0,0 +1,32 @@
1
+ module AdaptivePayments
2
+ class GetPaymentOptionsResponse < AbstractResponse
3
+ operation :GetPaymentOptions
4
+
5
+ attribute :initiating_entity, Node[InitiatingEntity], :param => "initiatingEntity"
6
+ attribute :display_options, Node[DisplayOptions], :param => "displayOptions"
7
+ attribute :shipping_address_id, String, :param => "shippingAddressId"
8
+ attribute :sender_options, Node[SenderOptions], :param => "senderOptions"
9
+ attribute :receiver_options, NodeList[ReceiverOptions], :param => "receiverOptions"
10
+
11
+ alias_params :initiating_entity, {
12
+ :institution_id => :institution_id,
13
+ :customer_first_name => :customer_first_name,
14
+ :customer_last_name => :customer_last_name,
15
+ :customer_display_name => :customer_display_name,
16
+ :institution_customer_id => :institution_customer_id,
17
+ :customer_country_code => :customer_country_code,
18
+ :customer_email => :customer_email
19
+ }
20
+
21
+ alias_params :display_options, {
22
+ :email_header_image_url => :email_header_image_url,
23
+ :email_marketing_image_url => :email_marketing_image_url,
24
+ :header_image_url => :header_image_url,
25
+ :business_name => :business_name
26
+ }
27
+
28
+ alias_params :sender_options, {
29
+ :require_shipping_address_selection => :require_shipping_address_selection
30
+ }
31
+ end
32
+ end
@@ -0,0 +1,64 @@
1
+ module AdaptivePayments
2
+ class PayRequest < AbstractRequest
3
+ operation :Pay
4
+
5
+ attribute :receiver_list, Node[ReceiverList], :param => "receiverList"
6
+ attribute :action_type, String, :param => "actionType"
7
+ attribute :currency_code, String, :param => "currencyCode"
8
+ attribute :cancel_url, String, :param => "cancelUrl"
9
+ attribute :return_url, String, :param => "returnUrl"
10
+ attribute :ipn_notification_url, String, :param => "ipnNotificationUrl"
11
+ attribute :sender, Node[SenderIdentifier]
12
+ attribute :preapproval_key, String, :param => "preapprovalKey"
13
+ attribute :pin, String
14
+ attribute :reverse_parallel_payments_on_error, Boolean, :param => "reverseAllParallelPaymentsOnError"
15
+ attribute :tracking_id, String, :param => "trackingId"
16
+ attribute :memo, String
17
+ attribute :funding_constraint, Node[FundingConstraint], :param => "fundingConstraint"
18
+ attribute :client_details, Node[ClientDetailsType], :param => "clientDetails"
19
+
20
+ include ReceiverListAliases
21
+
22
+ alias_params :client_details, {
23
+ :client_ip_address => :ip_address,
24
+ :client_device_id => :device_id,
25
+ :client_application_id => :application_id,
26
+ :client_model => :model,
27
+ :client_geo_location => :geo_location,
28
+ :client_customer_type => :customer_type,
29
+ :client_partner_name => :partner_name,
30
+ :client_customer_id => :customer_id
31
+ }
32
+
33
+ alias_params :sender, {
34
+ :sender_email => :email,
35
+ :sender_phone => :phone,
36
+ :use_sender_credentials => :use_credentials
37
+ }
38
+
39
+ alias_params :sender_phone, {
40
+ :sender_phone_country_code => :country_code,
41
+ :sender_phone_number => :phone_number,
42
+ :sender_phone_extension => :extension
43
+ }
44
+
45
+ alias_params :funding_constraint, {
46
+ :allowed_funding_type => :allowed_funding_type
47
+ }
48
+
49
+ alias_params :allowed_funding_type, {
50
+ :allowed_funding_type_info => :funding_type_info
51
+ }
52
+
53
+ def allowed_funding_types
54
+ allowed_funding_type_info.collect { |info| info[:funding_type] }
55
+ end
56
+
57
+ def allowed_funding_types=(list_of_types)
58
+ self.allowed_funding_type_info = list_of_types.map { |t| { :funding_type => t } }
59
+ end
60
+
61
+ # For explicit approval, redirect the user to https://www.paypal.com/webscr?cmd=_ap-payment&paykey=value
62
+ # When paying for DIGITALGOODS, use https://paypal.com/webapps/adaptivepayment/flow/pay?paykey=
63
+ end
64
+ end
@@ -0,0 +1,29 @@
1
+ module AdaptivePayments
2
+ class PayResponse < AbstractResponse
3
+ operation :Pay
4
+
5
+ attribute :pay_key, String, :param => "payKey"
6
+ attribute :payment_exec_status, String, :param => "paymentExecStatus"
7
+ attribute :default_funding_plan, Node[FundingPlan], :param => "defaultFundingPlan"
8
+ attribute :pay_error_list, Node[PayErrorList], :param => "payErrorList"
9
+
10
+ alias_params :default_funding_plan, {
11
+ :funding_plan_id => :id,
12
+ :funding_amount => :amount,
13
+ :funding_currency_code => :currency_code,
14
+ :backup_funding_source => :backup_funding_source,
15
+ :sender_fees_amount => :sender_fees_amount,
16
+ :sender_fees_currency_code => :sender_fees_currency_code,
17
+ :from_currency_amount => :from_currency_amount,
18
+ :from_currency_code => :from_currency_code,
19
+ :to_currency_amount => :to_currency_amount,
20
+ :to_currency_code => :to_currency_code,
21
+ :exchange_rate => :exchange_rate,
22
+ :charges => :charges
23
+ }
24
+
25
+ alias_params :pay_error_list, {
26
+ :pay_errors => :pay_errors
27
+ }
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ module AdaptivePayments
2
+ class PaymentDetailsRequest < AbstractRequest
3
+ operation :PaymentDetails
4
+
5
+ attribute :pay_key, String, :param => "payKey"
6
+ attribute :transaction_id, String, :param => "transactionId"
7
+ attribute :tracking_id, String, :param => "trackingId"
8
+ end
9
+ end
@@ -0,0 +1,53 @@
1
+ module AdaptivePayments
2
+ class PaymentDetailsResponse < AbstractResponse
3
+ operation :PaymentDetails
4
+
5
+ attribute :cancel_url, String, :param => "cancelUrl"
6
+ attribute :ipn_notification_url, String, :param => "ipnNotificationUrl"
7
+ attribute :return_url, String, :param => "returnUrl"
8
+ attribute :memo, String
9
+ attribute :currency_code, String, :param => "currencyCode"
10
+ attribute :payment_info_list, Node[PaymentInfoList], :param => "paymentInfoList"
11
+ attribute :status, String
12
+ attribute :tracking_id, String, :param => "trackingId"
13
+ attribute :pay_key, String, :param => "payKey"
14
+ attribute :action_type, String, :param => "actionType"
15
+ attribute :fees_payer, String, :param => "feesPayer"
16
+ attribute :reverse_parallel_payments_on_error, Boolean, :param => "reverseAllParallelPaymentsOnError"
17
+ attribute :preapproval_key, String, :param => "preapprovalKey"
18
+ attribute :funding_constraint, Node[FundingConstraint], :param => "fundingConstraint"
19
+ attribute :sender, Node[SenderIdentifier]
20
+
21
+ alias_params :sender, {
22
+ :sender_email => :email,
23
+ :sender_phone => :phone,
24
+ :use_sender_credentials => :use_credentials
25
+ }
26
+
27
+ alias_params :sender_phone, {
28
+ :sender_phone_country_code => :country_code,
29
+ :sender_phone_number => :phone_number,
30
+ :sender_phone_extension => :extension
31
+ }
32
+
33
+ alias_params :funding_constraint, {
34
+ :allowed_funding_type => :allowed_funding_type
35
+ }
36
+
37
+ alias_params :allowed_funding_type, {
38
+ :allowed_funding_type_info => :funding_type_info
39
+ }
40
+
41
+ alias_params :payment_info_list, {
42
+ :payments => :payment_info
43
+ }
44
+
45
+ def allowed_funding_types
46
+ allowed_funding_type_info.collect { |info| info[:funding_type] }
47
+ end
48
+
49
+ def receivers
50
+ payments.collect { |info| info[:receiver] }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,8 @@
1
+ module AdaptivePayments
2
+ class PreapprovalDetailsRequest < AbstractRequest
3
+ operation :PreapprovalDetails
4
+
5
+ attribute :preapproval_key, String, :param => "preapprovalKey"
6
+ attribute :get_billing_address, Boolean, :param => "getBillingAddress"
7
+ end
8
+ end
@@ -0,0 +1,35 @@
1
+ module AdaptivePayments
2
+ class PreapprovalDetailsResponse < AbstractResponse
3
+ operation :PreapprovalDetails
4
+
5
+ attribute :approved, Boolean
6
+ attribute :cancel_url, String, :param => "cancelUrl"
7
+ attribute :return_url, String, :param => "returnUrl"
8
+ attribute :ipn_notification_url, String, :param => "ipnNotificationUrl"
9
+ attribute :currency_code, String, :param => "currencyCode"
10
+ attribute :max_total_amount, Decimal, :param => "maxTotalAmountOfAllPayments"
11
+ attribute :starting_date, DateTime, :param => "startingDate"
12
+ attribute :ending_date, DateTime, :param => "endingDate"
13
+ attribute :max_amount_per_payment, Decimal, :param => "maxAmountPerPayment"
14
+ attribute :max_payments, Integer, :param => "maxNumberOfPayments"
15
+ attribute :max_payments_per_period, Integer, :param => "maxNumberOfPaymentsPerPeriod"
16
+ attribute :payment_period, String, :param => "paymentPeriod"
17
+ attribute :current_payments, Integer, :param => "curPayments"
18
+ attribute :current_payments_amount, Decimal, :param => "curPaymentsAmount"
19
+ attribute :current_period_attempts, Integer, :param => "curPeriodAttempts"
20
+ attribute :current_period_ending_date, DateTime, :param => "curPeriodEndingDate"
21
+ attribute :date_of_month, Integer, :param => "dateOfMonth"
22
+ attribute :day_of_week, String, :param => "dayOfWeek"
23
+ attribute :pin_type, String, :param => "pinType"
24
+ attribute :sender_email, String, :param => "senderEmail"
25
+ attribute :memo, String
26
+ attribute :status, String
27
+ attribute :fees_payer, String, :param => "feesPayer"
28
+ attribute :display_max_total_amount, Boolean, :param => "displayMaxTotalAmount"
29
+ attribute :address_list, Node[AddressList], :param => "addressList"
30
+
31
+ alias_params :address_list, {
32
+ :addresses => :addresses
33
+ }
34
+ end
35
+ end
@@ -0,0 +1,36 @@
1
+ module AdaptivePayments
2
+ class PreapprovalRequest < AbstractRequest
3
+ operation :Preapproval
4
+
5
+ attribute :client_details, Node[ClientDetailsType], :param => "clientDetails"
6
+ attribute :ending_date, DateTime, :param => "endingDate"
7
+ attribute :starting_date, DateTime, :param => "startingDate"
8
+ attribute :max_total_amount, Decimal, :param => "maxTotalAmountOfAllPayments"
9
+ attribute :currency_code, String, :param => "currencyCode"
10
+ attribute :cancel_url, String, :param => "cancelUrl"
11
+ attribute :return_url, String, :param => "returnUrl"
12
+ attribute :ipn_notification_url, String, :param => "ipnNotificationUrl"
13
+ attribute :date_of_month, Integer, :param => "dateOfMonth"
14
+ attribute :day_of_week, String, :param => "dayOfWeek"
15
+ attribute :max_amount_per_payment, Decimal, :param => "maxAmountPerPayment"
16
+ attribute :max_payments, Integer, :param => "maxNumberOfPayments"
17
+ attribute :max_payments_per_period, Integer, :param => "maxNumberOfPaymentsPerPeriod"
18
+ attribute :payment_period, String, :param => "paymentPeriod"
19
+ attribute :memo, String
20
+ attribute :sender_email, String, :param => "senderEmail"
21
+ attribute :pin_type, String, :param => "pinType"
22
+ attribute :fees_payer, String, :param => "feesPayer"
23
+ attribute :display_max_total_amount, Boolean, :param => "displayMaxTotalAmount"
24
+
25
+ alias_params :client_details, {
26
+ :client_ip_address => :ip_address,
27
+ :client_device_id => :device_id,
28
+ :client_application_id => :application_id,
29
+ :client_model => :model,
30
+ :client_geo_location => :geo_location,
31
+ :client_customer_type => :customer_type,
32
+ :client_partner_name => :partner_name,
33
+ :client_customer_id => :customer_id
34
+ }
35
+ end
36
+ end
@@ -0,0 +1,7 @@
1
+ module AdaptivePayments
2
+ class PreapprovalResponse < AbstractResponse
3
+ operation :Preapproval
4
+
5
+ attribute :preapproval_key, String, :param => "preapprovalKey"
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ module AdaptivePayments
2
+ class RefundRequest < AbstractRequest
3
+ operation :Refund
4
+
5
+ attribute :currency_code, String, :param => "currencyCode"
6
+ attribute :pay_key, String, :param => "payKey"
7
+ attribute :tracking_id, String, :param => "trackingId"
8
+ attribute :transaction_id, String, :param => "transactionId"
9
+ attribute :receiver_list, Node[ReceiverList], :param => "receiverList"
10
+ attribute :ipn_notification_url, String, :param => "ipnNotificationUrl"
11
+
12
+ include ReceiverListAliases
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module AdaptivePayments
2
+ class RefundResponse < AbstractResponse
3
+ operation :Refund
4
+
5
+ attribute :currency_code, String, :param => "currencyCode"
6
+ attribute :refund_info_list, Node[RefundInfoList], :param => "refundInfoList"
7
+
8
+ alias_params :refund_info_list, {
9
+ :refund_info => :refund_info
10
+ }
11
+ end
12
+ end