paypal-sdk-rest 1.7.3 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +5 -14
  3. data/README.md +48 -243
  4. data/lib/lib.rb +95 -0
  5. data/lib/paypal-sdk-rest.rb +1 -2
  6. data/lib/paypal/core/access_token.rb +20 -0
  7. data/lib/paypal/core/paypal_environment.rb +38 -0
  8. data/lib/paypal/core/paypal_http_client.rb +52 -0
  9. data/lib/paypal/core/token_requests.rb +40 -0
  10. data/lib/paypal/core/version.rb +3 -0
  11. data/lib/v1/billing_agreements/agreement_bill_balance_request.rb +35 -0
  12. data/lib/v1/billing_agreements/agreement_cancel_request.rb +35 -0
  13. data/lib/v1/billing_agreements/agreement_create_request.rb +33 -0
  14. data/lib/v1/billing_agreements/agreement_execute_request.rb +31 -0
  15. data/lib/v1/billing_agreements/agreement_get_request.rb +31 -0
  16. data/lib/v1/billing_agreements/agreement_re_activate_request.rb +35 -0
  17. data/lib/v1/billing_agreements/agreement_set_balance_request.rb +35 -0
  18. data/lib/v1/billing_agreements/agreement_suspend_request.rb +35 -0
  19. data/lib/v1/billing_agreements/agreement_transactions_request.rb +41 -0
  20. data/lib/v1/billing_agreements/agreement_update_request.rb +35 -0
  21. data/lib/v1/billing_plans/plan_create_request.rb +33 -0
  22. data/lib/v1/billing_plans/plan_get_request.rb +31 -0
  23. data/lib/v1/billing_plans/plan_list_request.rb +49 -0
  24. data/lib/v1/billing_plans/plan_update_request.rb +35 -0
  25. data/lib/v1/customer_disputes/dispute_accept_claim_request.rb +35 -0
  26. data/lib/v1/customer_disputes/dispute_adjudicate_request.rb +35 -0
  27. data/lib/v1/customer_disputes/dispute_appeal_request.rb +35 -0
  28. data/lib/v1/customer_disputes/dispute_get_request.rb +31 -0
  29. data/lib/v1/customer_disputes/dispute_list_request.rb +59 -0
  30. data/lib/v1/customer_disputes/dispute_provide_evidence_request.rb +35 -0
  31. data/lib/v1/customer_disputes/dispute_require_evidence_request.rb +35 -0
  32. data/lib/v1/identity/user_consent.rb +45 -0
  33. data/lib/v1/identity/userinfo_get_request.rb +33 -0
  34. data/lib/v1/invoices/invoice_cancel_request.rb +35 -0
  35. data/lib/v1/invoices/invoice_create_request.rb +33 -0
  36. data/lib/v1/invoices/invoice_delete_external_payment_request.rb +33 -0
  37. data/lib/v1/invoices/invoice_delete_external_refund_request.rb +33 -0
  38. data/lib/v1/invoices/invoice_delete_request.rb +31 -0
  39. data/lib/v1/invoices/invoice_get_request.rb +31 -0
  40. data/lib/v1/invoices/invoice_list_request.rb +44 -0
  41. data/lib/v1/invoices/invoice_next_invoice_number_request.rb +29 -0
  42. data/lib/v1/invoices/invoice_qr_code_request.rb +46 -0
  43. data/lib/v1/invoices/invoice_record_payment_request.rb +35 -0
  44. data/lib/v1/invoices/invoice_record_refund_request.rb +35 -0
  45. data/lib/v1/invoices/invoice_remind_request.rb +35 -0
  46. data/lib/v1/invoices/invoice_search_request.rb +33 -0
  47. data/lib/v1/invoices/invoice_send_request.rb +36 -0
  48. data/lib/v1/invoices/invoice_update_request.rb +40 -0
  49. data/lib/v1/invoices/template_create_request.rb +33 -0
  50. data/lib/v1/invoices/template_delete_request.rb +31 -0
  51. data/lib/v1/invoices/template_get_request.rb +31 -0
  52. data/lib/v1/invoices/template_list_request.rb +34 -0
  53. data/lib/v1/invoices/template_update_request.rb +35 -0
  54. data/lib/v1/orders/orders_cancel_request.rb +31 -0
  55. data/lib/v1/orders/orders_create_request.rb +33 -0
  56. data/lib/v1/orders/orders_get_request.rb +31 -0
  57. data/lib/v1/orders/orders_pay_request.rb +35 -0
  58. data/lib/v1/payment_experience/web_profile_create_request.rb +33 -0
  59. data/lib/v1/payment_experience/web_profile_delete_request.rb +31 -0
  60. data/lib/v1/payment_experience/web_profile_get_request.rb +31 -0
  61. data/lib/v1/payment_experience/web_profile_list_request.rb +29 -0
  62. data/lib/v1/payment_experience/web_profile_partial_update_request.rb +35 -0
  63. data/lib/v1/payment_experience/web_profile_update_request.rb +35 -0
  64. data/lib/v1/payments/authorization_capture_request.rb +35 -0
  65. data/lib/v1/payments/authorization_get_request.rb +31 -0
  66. data/lib/v1/payments/authorization_reauthorize_request.rb +35 -0
  67. data/lib/v1/payments/authorization_void_request.rb +35 -0
  68. data/lib/v1/payments/capture_get_request.rb +31 -0
  69. data/lib/v1/payments/capture_refund_request.rb +39 -0
  70. data/lib/v1/payments/order_authorize_request.rb +35 -0
  71. data/lib/v1/payments/order_capture_request.rb +35 -0
  72. data/lib/v1/payments/order_get_request.rb +31 -0
  73. data/lib/v1/payments/order_void_request.rb +35 -0
  74. data/lib/v1/payments/payment_create_request.rb +37 -0
  75. data/lib/v1/payments/payment_execute_request.rb +43 -0
  76. data/lib/v1/payments/payment_get_request.rb +31 -0
  77. data/lib/v1/payments/payment_list_request.rb +69 -0
  78. data/lib/v1/payments/payment_update_request.rb +35 -0
  79. data/lib/v1/payments/refund_get_request.rb +31 -0
  80. data/lib/v1/payments/sale_get_request.rb +31 -0
  81. data/lib/v1/payments/sale_refund_request.rb +39 -0
  82. data/lib/v1/sync/search_get_request.rb +99 -0
  83. data/lib/v1/vault/credit_card_create_request.rb +33 -0
  84. data/lib/v1/vault/credit_card_delete_request.rb +31 -0
  85. data/lib/v1/vault/credit_card_get_request.rb +31 -0
  86. data/lib/v1/vault/credit_card_list_request.rb +79 -0
  87. data/lib/v1/vault/credit_card_update_request.rb +35 -0
  88. data/lib/v1/webhooks/available_event_type_list_request.rb +29 -0
  89. data/lib/v1/webhooks/event_get_request.rb +31 -0
  90. data/lib/v1/webhooks/event_list_request.rb +54 -0
  91. data/lib/v1/webhooks/event_resend_request.rb +35 -0
  92. data/lib/v1/webhooks/simulate_event_request.rb +33 -0
  93. data/lib/v1/webhooks/webhook_create_request.rb +33 -0
  94. data/lib/v1/webhooks/webhook_delete_request.rb +31 -0
  95. data/lib/v1/webhooks/webhook_get_request.rb +31 -0
  96. data/lib/v1/webhooks/webhook_list_event_subscriptions_request.rb +31 -0
  97. data/lib/v1/webhooks/webhook_list_request.rb +34 -0
  98. data/lib/v1/webhooks/webhook_update_request.rb +35 -0
  99. data/lib/v1/webhooks/webhook_verify_signature_request.rb +33 -0
  100. data/spec/integration/test_harness.rb +25 -0
  101. data/spec/integration/v1/billing_agreements/agreement_create_spec.rb +69 -0
  102. data/spec/integration/v1/billing_plans/plan_create_spec.rb +12 -0
  103. data/spec/integration/v1/billing_plans/plan_get_spec.rb +16 -0
  104. data/spec/integration/v1/billing_plans/plan_helper.rb +71 -0
  105. data/spec/integration/v1/billing_plans/plan_list_spec.rb +16 -0
  106. data/spec/integration/v1/billing_plans/plan_update_spec.rb +19 -0
  107. data/spec/integration/v1/customer_disputes/dispute_accept_claim_spec.rb +26 -0
  108. data/spec/integration/v1/customer_disputes/dispute_adjudicate_spec.rb +24 -0
  109. data/spec/integration/v1/customer_disputes/dispute_appeal_spec.rb +33 -0
  110. data/spec/integration/v1/customer_disputes/dispute_get_spec.rb +19 -0
  111. data/spec/integration/v1/customer_disputes/dispute_list_spec.rb +17 -0
  112. data/spec/integration/v1/customer_disputes/dispute_provide_evidence_spec.rb +32 -0
  113. data/spec/integration/v1/customer_disputes/dispute_require_evidence_spec.rb +24 -0
  114. data/spec/integration/v1/customer_disputes/test_image.png +0 -0
  115. data/spec/integration/v1/identity/userinfo_get_spec.rb +65 -0
  116. data/spec/integration/v1/invoices/invoice_cancel_spec.rb +23 -0
  117. data/spec/integration/v1/invoices/invoice_create_spec.rb +15 -0
  118. data/spec/integration/v1/invoices/invoice_delete_external_payment_spec.rb +23 -0
  119. data/spec/integration/v1/invoices/invoice_delete_external_refund_spec.rb +21 -0
  120. data/spec/integration/v1/invoices/invoice_delete_spec.rb +16 -0
  121. data/spec/integration/v1/invoices/invoice_get_spec.rb +18 -0
  122. data/spec/integration/v1/invoices/invoice_helper.rb +171 -0
  123. data/spec/integration/v1/invoices/invoice_list_spec.rb +20 -0
  124. data/spec/integration/v1/invoices/invoice_next_invoice_number_spec.rb +14 -0
  125. data/spec/integration/v1/invoices/invoice_qr_code_spec.rb +18 -0
  126. data/spec/integration/v1/invoices/invoice_record_payment_spec.rb +14 -0
  127. data/spec/integration/v1/invoices/invoice_record_refund_spec.rb +14 -0
  128. data/spec/integration/v1/invoices/invoice_remind_spec.rb +22 -0
  129. data/spec/integration/v1/invoices/invoice_search_spec.rb +20 -0
  130. data/spec/integration/v1/invoices/invoice_send_spec.rb +15 -0
  131. data/spec/integration/v1/invoices/invoice_update_spec.rb +26 -0
  132. data/spec/integration/v1/invoices/template_create_spec.rb +14 -0
  133. data/spec/integration/v1/invoices/template_delete_spec.rb +15 -0
  134. data/spec/integration/v1/invoices/template_get_spec.rb +18 -0
  135. data/spec/integration/v1/invoices/template_list_spec.rb +15 -0
  136. data/spec/integration/v1/invoices/template_update_spec.rb +62 -0
  137. data/spec/integration/v1/orders/orders_cancel_spec.rb +15 -0
  138. data/spec/integration/v1/orders/orders_create_spec.rb +17 -0
  139. data/spec/integration/v1/orders/orders_get_spec.rb +18 -0
  140. data/spec/integration/v1/orders/orders_helper.rb +36 -0
  141. data/spec/integration/v1/orders/orders_pay_spec.rb +19 -0
  142. data/spec/integration/v1/payment_experience/pe_helper.rb +35 -0
  143. data/spec/integration/v1/payment_experience/web_profile_create_spec.rb +20 -0
  144. data/spec/integration/v1/payment_experience/web_profile_delete_spec.rb +15 -0
  145. data/spec/integration/v1/payment_experience/web_profile_get_spec.rb +17 -0
  146. data/spec/integration/v1/payment_experience/web_profile_list_spec.rb +18 -0
  147. data/spec/integration/v1/payment_experience/web_profile_partial_update_spec.rb +32 -0
  148. data/spec/integration/v1/payment_experience/web_profile_update_spec.rb +44 -0
  149. data/spec/integration/v1/payments/authorization_capture_spec.rb +17 -0
  150. data/spec/integration/v1/payments/authorization_get_spec.rb +18 -0
  151. data/spec/integration/v1/payments/authorization_reauthorize_spec.rb +26 -0
  152. data/spec/integration/v1/payments/authorization_void_spec.rb +19 -0
  153. data/spec/integration/v1/payments/capture_get_spec.rb +20 -0
  154. data/spec/integration/v1/payments/capture_refund_spec.rb +27 -0
  155. data/spec/integration/v1/payments/order_authorize_spec.rb +20 -0
  156. data/spec/integration/v1/payments/order_capture_spec.rb +21 -0
  157. data/spec/integration/v1/payments/order_get_spec.rb +14 -0
  158. data/spec/integration/v1/payments/order_void_spec.rb +14 -0
  159. data/spec/integration/v1/payments/payment_create_spec.rb +13 -0
  160. data/spec/integration/v1/payments/payment_execute_spec.rb +19 -0
  161. data/spec/integration/v1/payments/payment_get_spec.rb +17 -0
  162. data/spec/integration/v1/payments/payment_list_spec.rb +16 -0
  163. data/spec/integration/v1/payments/payment_update_spec.rb +28 -0
  164. data/spec/integration/v1/payments/payments_helper.rb +78 -0
  165. data/spec/integration/v1/payments/refund_get_spec.rb +19 -0
  166. data/spec/integration/v1/payments/sale_get_spec.rb +18 -0
  167. data/spec/integration/v1/payments/sale_refund_spec.rb +18 -0
  168. data/spec/integration/v1/sync/search_get_spec.rb +34 -0
  169. data/spec/integration/v1/vault/credit_card_create_spec.rb +16 -0
  170. data/spec/integration/v1/vault/credit_card_delete_spec.rb +16 -0
  171. data/spec/integration/v1/vault/credit_card_get_spec.rb +17 -0
  172. data/spec/integration/v1/vault/credit_card_list_spec.rb +18 -0
  173. data/spec/integration/v1/vault/credit_card_update_spec.rb +26 -0
  174. data/spec/integration/v1/vault/vault_helper.rb +28 -0
  175. data/spec/integration/v1/webhooks/available_event_type_list_spec.rb +16 -0
  176. data/spec/integration/v1/webhooks/webhook_create_spec.rb +12 -0
  177. data/spec/integration/v1/webhooks/webhook_delete_spec.rb +13 -0
  178. data/spec/integration/v1/webhooks/webhook_get_spec.rb +16 -0
  179. data/spec/integration/v1/webhooks/webhook_helper.rb +42 -0
  180. data/spec/integration/v1/webhooks/webhook_list_event_subscriptions_spec.rb +16 -0
  181. data/spec/integration/v1/webhooks/webhook_list_spec.rb +15 -0
  182. data/spec/integration/v1/webhooks/webhook_update_spec.rb +29 -0
  183. data/spec/integration/v1/webhooks/webhook_verify_signature_spec.rb +20 -0
  184. data/spec/log/http.log +0 -0
  185. data/spec/log/rest_http.log +0 -0
  186. data/spec/spec_helper.rb +98 -26
  187. data/spec/unit/paypal_http_client_spec.rb +272 -0
  188. metadata +277 -119
  189. data/Rakefile +0 -15
  190. data/data/DigiCertHighAssuranceEVRootCA.pem +0 -23
  191. data/data/DigiCertSHA2ExtendedValidationServerCA.pem +0 -28
  192. data/data/paypal.crt +0 -171
  193. data/lib/generators/paypal/sdk/USAGE +0 -3
  194. data/lib/generators/paypal/sdk/install_generator.rb +0 -17
  195. data/lib/generators/paypal/sdk/templates/paypal.rb +0 -2
  196. data/lib/generators/paypal/sdk/templates/paypal.yml +0 -29
  197. data/lib/paypal-sdk-core.rb +0 -38
  198. data/lib/paypal-sdk/core/api.rb +0 -20
  199. data/lib/paypal-sdk/core/api/base.rb +0 -169
  200. data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +0 -44
  201. data/lib/paypal-sdk/core/api/data_types/base.rb +0 -225
  202. data/lib/paypal-sdk/core/api/data_types/enum.rb +0 -26
  203. data/lib/paypal-sdk/core/api/data_types/simple_types.rb +0 -52
  204. data/lib/paypal-sdk/core/api/ipn.rb +0 -66
  205. data/lib/paypal-sdk/core/api/rest.rb +0 -177
  206. data/lib/paypal-sdk/core/authentication.rb +0 -66
  207. data/lib/paypal-sdk/core/config.rb +0 -253
  208. data/lib/paypal-sdk/core/credential.rb +0 -16
  209. data/lib/paypal-sdk/core/credential/base.rb +0 -27
  210. data/lib/paypal-sdk/core/credential/certificate.rb +0 -32
  211. data/lib/paypal-sdk/core/credential/signature.rb +0 -22
  212. data/lib/paypal-sdk/core/credential/third_party/subject.rb +0 -25
  213. data/lib/paypal-sdk/core/credential/third_party/token.rb +0 -39
  214. data/lib/paypal-sdk/core/exceptions.rb +0 -112
  215. data/lib/paypal-sdk/core/logging.rb +0 -50
  216. data/lib/paypal-sdk/core/openid_connect.rb +0 -140
  217. data/lib/paypal-sdk/core/openid_connect/api.rb +0 -50
  218. data/lib/paypal-sdk/core/openid_connect/data_types.rb +0 -73
  219. data/lib/paypal-sdk/core/openid_connect/get_api.rb +0 -28
  220. data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +0 -52
  221. data/lib/paypal-sdk/core/openid_connect/set_api.rb +0 -36
  222. data/lib/paypal-sdk/core/util.rb +0 -11
  223. data/lib/paypal-sdk/core/util/http_helper.rb +0 -171
  224. data/lib/paypal-sdk/core/util/oauth_signature.rb +0 -64
  225. data/lib/paypal-sdk/core/util/ordered_hash.rb +0 -165
  226. data/lib/paypal-sdk/rest.rb +0 -39
  227. data/lib/paypal-sdk/rest/api.rb +0 -23
  228. data/lib/paypal-sdk/rest/data_types.rb +0 -2596
  229. data/lib/paypal-sdk/rest/error_hash.rb +0 -39
  230. data/lib/paypal-sdk/rest/get_api.rb +0 -20
  231. data/lib/paypal-sdk/rest/request_data_type.rb +0 -53
  232. data/lib/paypal-sdk/rest/set_api.rb +0 -42
  233. data/lib/paypal-sdk/rest/version.rb +0 -7
  234. data/spec/README.md +0 -22
  235. data/spec/config/cacert.pem +0 -171
  236. data/spec/config/cert_key.pem +0 -33
  237. data/spec/config/paypal.yml +0 -35
  238. data/spec/config/sample_data.yml +0 -3
  239. data/spec/core/api/data_type_spec.rb +0 -289
  240. data/spec/core/api/rest_spec.rb +0 -211
  241. data/spec/core/config_spec.rb +0 -192
  242. data/spec/core/logging_spec.rb +0 -28
  243. data/spec/core/openid_connect_spec.rb +0 -153
  244. data/spec/invoice_examples_spec.rb +0 -38
  245. data/spec/payments_examples_spec.rb +0 -437
  246. data/spec/payouts_examples_spec.rb +0 -49
  247. data/spec/rest/data_types_spec.rb +0 -62
  248. data/spec/rest/error_hash_spec.rb +0 -83
  249. data/spec/subscription_examples_spec.rb +0 -227
  250. data/spec/support/sample_data.rb +0 -5
  251. data/spec/web_profile_examples_spec.rb +0 -106
  252. data/spec/webhooks_examples_spec.rb +0 -93
@@ -1,39 +0,0 @@
1
- require 'paypal-sdk-core'
2
-
3
- module PayPal
4
- module SDK
5
- module REST
6
- autoload :VERSION, "paypal-sdk/rest/version"
7
- autoload :DataTypes, "paypal-sdk/rest/data_types"
8
- autoload :API, "paypal-sdk/rest/api"
9
- autoload :RequestDataType, "paypal-sdk/rest/request_data_type"
10
- autoload :SetAPI, "paypal-sdk/rest/set_api"
11
- autoload :GetAPI, "paypal-sdk/rest/get_api"
12
- autoload :ErrorHash, "paypal-sdk/rest/error_hash"
13
-
14
- include DataTypes
15
- include Core::Exceptions
16
-
17
- module ClassMethods
18
- def method_missing(name, *args)
19
- RequestDataType.send(name, *args)
20
- end
21
- end
22
-
23
- class << self
24
- def new(*args)
25
- API.new(*args)
26
- end
27
-
28
- include ClassMethods
29
-
30
- def included(klass)
31
- if klass.is_a? Module
32
- klass.extend(ClassMethods)
33
- end
34
- end
35
- end
36
-
37
- end
38
- end
39
- end
@@ -1,23 +0,0 @@
1
- require 'paypal-sdk-core'
2
- require 'paypal-sdk/rest/version'
3
-
4
- module PayPal
5
- module SDK
6
- module REST
7
- class API < Core::API::REST
8
- # include Services
9
-
10
- def initialize(environment = nil, options = {})
11
- super("", environment, options)
12
- end
13
-
14
- class << self
15
- def user_agent
16
- @user_agent ||= "PayPalSDK/PayPal-Ruby-SDK #{PayPal::SDK::REST::VERSION} (#{sdk_library_details})"
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
-
@@ -1,2596 +0,0 @@
1
- require 'paypal-sdk-core'
2
- require 'securerandom'
3
- require 'multi_json'
4
- require 'zlib'
5
- require "base64"
6
- require 'net/http'
7
-
8
- module PayPal::SDK
9
- module REST
10
- module DataTypes
11
- class Base < Core::API::DataTypes::Base
12
- attr_accessor :error
13
- attr_writer :header, :request_id
14
-
15
- def header
16
- @header ||= {}
17
- end
18
-
19
- def request_id
20
- @request_id ||= SecureRandom.uuid
21
- end
22
-
23
- def http_header
24
- { "PayPal-Request-Id" => request_id.to_s }.merge(header)
25
- end
26
-
27
- def success?
28
- @error.nil?
29
- end
30
-
31
- def merge!(values)
32
- @error = nil
33
- super
34
- end
35
-
36
- def raise_error!
37
- raise Core::Exceptions::UnsuccessfulApiCall, error if error
38
- end
39
-
40
- def self.load_members
41
- end
42
-
43
- def self.raise_on_api_error(*methods)
44
- methods.each do |symbol|
45
- define_method("#{symbol}!") {|*arg|
46
- raise_error! unless send(symbol, *arg)
47
- }
48
- end
49
- end
50
-
51
- class Number < Float
52
- end
53
- end
54
-
55
- class Payment < Base
56
- def self.load_members
57
- object_of :id, String
58
- object_of :intent, String
59
- object_of :payer, Payer
60
- object_of :payee, Payee
61
- object_of :cart, String
62
- array_of :transactions, Transaction
63
- array_of :failed_transactions, Error
64
- object_of :payment_instruction, PaymentInstruction
65
- object_of :state, String
66
- object_of :experience_profile_id, String
67
- object_of :note_to_payer, String
68
- object_of :redirect_urls, RedirectUrls
69
- object_of :failure_reason, String
70
- object_of :create_time, String
71
- object_of :update_time, String
72
- array_of :links, Links
73
- object_of :note_to_payer, String
74
- array_of :billing_agreement_tokens, String
75
- object_of :potential_payer_info, PotentialPayerInfo
76
- object_of :credit_financing_offered, CreditFinancingOffered
77
- object_of :failure_reason, String
78
- end
79
-
80
- include RequestDataType
81
-
82
- def create()
83
- path = "v1/payments/payment"
84
- response = api.post(path, self.to_hash, http_header)
85
- self.merge!(response)
86
- success?
87
- end
88
-
89
- def update(patch_requests)
90
- patch_request_array = []
91
- patch_requests.each do |patch_request|
92
- patch_request = Patch.new(patch_request) unless patch_request.is_a? Patch
93
- patch_request_array << patch_request.to_hash
94
- end
95
- path = "v1/payments/payment/#{self.id}"
96
- response = api.patch(path, patch_request_array, http_header)
97
- self.merge!(response)
98
- success?
99
- end
100
-
101
- def execute(payment_execution)
102
- payment_execution = PaymentExecution.new(payment_execution) unless payment_execution.is_a? PaymentExecution
103
- path = "v1/payments/payment/#{self.id}/execute"
104
- response = api.post(path, payment_execution.to_hash, http_header)
105
- self.merge!(response)
106
- success?
107
- end
108
-
109
- raise_on_api_error :create, :update, :execute
110
-
111
- def approval_url(immediate = false)
112
- link = links.detect { |l| l.rel == 'approval_url' }
113
- return nil unless link
114
- link.href + (immediate ? '&useraction=commit' : '')
115
- end
116
-
117
- def token
118
- url = approval_url
119
- return nil unless url
120
- CGI.parse(URI.parse(url).query)['token'].first
121
- end
122
-
123
- class << self
124
- def find(resource_id)
125
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
126
- path = "v1/payments/payment/#{resource_id}"
127
- self.new(api.get(path))
128
- end
129
-
130
- def all(options = {})
131
- path = "v1/payments/payment"
132
- PaymentHistory.new(api.get(path, options))
133
- end
134
- end
135
- end
136
-
137
- class PotentialPayerInfo < Base
138
- def self.load_members
139
- object_of :email, String
140
- object_of :external_remember_me_id, String
141
- object_of :billing_address, Address
142
- end
143
-
144
- include RequestDataType
145
- end
146
-
147
- class ProcessorResponse < Base
148
- def self.load_members
149
- object_of :response_code, String
150
- object_of :avs_code, String
151
- object_of :cvv_code, Address
152
- object_of :advice_code, String
153
- object_of :eci_submitted, String
154
- object_of :vpas, String
155
- end
156
-
157
- include RequestDataType
158
- end
159
-
160
- class AlternatePayment < Base
161
- def self.load_members
162
- object_of :alternate_payment_account_id, String
163
- object_of :external_customer_id, String
164
- object_of :alternate_payment_provider_id, String
165
- end
166
-
167
- include RequestDataType
168
- end
169
-
170
- class Billing < Base
171
- def self.load_members
172
- object_of :billing_agreement_id, String
173
- object_of :selected_installment_option, InstallmentOption
174
- end
175
-
176
- include RequestDataType
177
- end
178
-
179
- class BillingAgreementToken < Base
180
- def self.load_members
181
- end
182
-
183
- include RequestDataType
184
- end
185
-
186
- class CountryCode < Base
187
- def self.load_members
188
- object_of :country_code, String
189
- end
190
-
191
- include RequestDataType
192
- end
193
-
194
- class CreditFinancingOffered < Base
195
- def self.load_members
196
- object_of :total_cost, Currency
197
- object_of :term, Number
198
- object_of :monthly_payment, Currency
199
- object_of :total_interest, Currency
200
- object_of :payer_acceptance, Boolean
201
- object_of :cart_amount_immutable, Boolean
202
- end
203
-
204
- include RequestDataType
205
- end
206
-
207
- class ExternalFunding < Base
208
- def self.load_members
209
- object_of :reference_id, String
210
- object_of :code, String
211
- object_of :funding_account_id, String
212
- object_of :display_text, String
213
- object_of :amount, Currency
214
- object_of :funding_instruction, String
215
- end
216
-
217
- include RequestDataType
218
- end
219
-
220
- class PotentialPayerInfo < Base
221
- def self.load_members
222
- object_of :email, String
223
- object_of :external_remember_me_id, String
224
- object_of :billing_address, Address
225
- end
226
-
227
- include RequestDataType
228
- end
229
-
230
- class PrivateLabelCard < Base
231
- def self.load_members
232
- object_of :id, String
233
- object_of :card_number, String
234
- object_of :issuer_id, Address
235
- object_of :issuer_name, Address
236
- object_of :image_key, Address
237
- end
238
-
239
- include RequestDataType
240
- end
241
-
242
- class ProcessorResponse < Base
243
- def self.load_members
244
- object_of :response_code, String
245
- object_of :avs_code, String
246
- object_of :cvv_code, String
247
- object_of :advice_code, String
248
- object_of :eci_submitted, String
249
- object_of :vpas, String
250
- end
251
-
252
- include RequestDataType
253
- end
254
-
255
-
256
-
257
-
258
- class FuturePayment < Payment
259
-
260
- def create(correlation_id=nil)
261
- path = "v1/payments/payment"
262
- if correlation_id != nil
263
- header = http_header
264
- header = header.merge({
265
- "PAYPAL-CLIENT-METADATA-ID" => correlation_id})
266
- end
267
- response = api.post(path, self.to_hash, http_header)
268
- self.merge!(response)
269
- success?
270
- end
271
-
272
- raise_on_api_error :create
273
-
274
- class << self
275
-
276
- def exch_token(auth_code)
277
- if auth_code
278
- PayPal::SDK::OpenIDConnect::DataTypes::Tokeninfo.token_hash(auth_code)
279
- else
280
- raise ArgumentError.new("authorization code required") if auth_code.to_s.strip.empty?
281
- end
282
- end
283
-
284
- end
285
- end
286
-
287
- class Payer < Base
288
- def self.load_members
289
- object_of :payment_method, String
290
- object_of :status, String
291
- object_of :account_type, String
292
- object_of :account_age, String
293
- array_of :funding_instruments, FundingInstrument
294
- object_of :funding_option_id, String
295
- object_of :funding_option, FundingOption
296
- object_of :external_selected_funding_instrument_type, String
297
- object_of :related_funding_option, FundingOption
298
- object_of :payer_info, PayerInfo
299
- object_of :billing, Billing
300
- end
301
- end
302
-
303
- class FundingInstrument < Base
304
- def self.load_members
305
- object_of :credit_card, CreditCard
306
- object_of :credit_card_token, CreditCardToken
307
- end
308
- end
309
-
310
- class CreditCard < Base
311
- def self.load_members
312
- object_of :id, String
313
- object_of :number, String
314
- object_of :type, String
315
- object_of :expire_month, Integer
316
- object_of :expire_year, Integer
317
- object_of :cvv2, String
318
- object_of :first_name, String
319
- object_of :last_name, String
320
- object_of :billing_address, Address
321
- object_of :external_customer_id, String
322
- object_of :state, String
323
- object_of :valid_until, String
324
- object_of :create_time, String
325
- object_of :update_time, String
326
- array_of :links, Links
327
- end
328
-
329
- include RequestDataType
330
-
331
- def create()
332
- path = "v1/vault/credit-cards"
333
- response = api.post(path, self.to_hash, http_header)
334
- self.merge!(response)
335
- success?
336
- end
337
-
338
- class << self
339
- def find(resource_id)
340
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
341
- path = "v1/vault/credit-cards/#{resource_id}"
342
- self.new(api.get(path))
343
- end
344
- end
345
-
346
- def delete()
347
- path = "v1/vault/credit-cards/#{self.id}"
348
- response = api.delete(path, {})
349
- self.merge!(response)
350
- success?
351
- end
352
-
353
- def update(patch_requests)
354
- patch_request_array = []
355
- patch_requests.each do |patch_request|
356
- patch_request = Patch.new(patch_request) unless patch_request.is_a? Patch
357
- patch_request_array << patch_request.to_hash
358
- end
359
- path = "v1/vault/credit-cards/#{self.id}"
360
- response = api.patch(path, patch_request_array, http_header)
361
- self.merge!(response)
362
- success?
363
- end
364
-
365
- raise_on_api_error :create, :update, :delete
366
- end
367
-
368
- class BaseAddress < Base
369
- def self.load_members
370
- object_of :line1, String
371
- object_of :line2, String
372
- object_of :city, String
373
- object_of :country_code, String
374
- object_of :postal_code, String
375
- object_of :state, String
376
- object_of :normalization_status, String
377
- object_of :status, String
378
- object_of :type, String
379
- end
380
- end
381
-
382
- class Address < BaseAddress
383
- def self.load_members
384
- object_of :phone, String
385
- end
386
- end
387
-
388
- class InvoiceAddress < BaseAddress
389
- def self.load_members
390
- object_of :phone, Phone
391
- end
392
- end
393
-
394
- class OneOf < Base
395
- def self.load_members
396
- object_of :phone, Phone
397
- end
398
- end
399
-
400
- class CreditCardToken < Base
401
- def self.load_members
402
- object_of :credit_card_id, String
403
- object_of :payer_id, String
404
- object_of :last4, String
405
- object_of :type, String
406
- object_of :expire_month, Integer
407
- object_of :expire_year, Integer
408
- end
409
- end
410
-
411
- class PaymentCard < Base
412
- def self.load_members
413
- object_of :id, String
414
- object_of :number, String
415
- object_of :type, String
416
- object_of :expire_month, Integer
417
- object_of :expire_year, Integer
418
- object_of :start_month, String
419
- object_of :start_year, String
420
- object_of :cvv2, String
421
- object_of :first_name, String
422
- object_of :last_name, String
423
- object_of :billing_country, String
424
- object_of :billing_address, Address
425
- object_of :external_customer_id, String
426
- object_of :status, String
427
- object_of :card_product_class, String
428
- object_of :valid_until, String
429
- object_of :issue_number, String
430
- end
431
- end
432
-
433
- class BankAccount < Base
434
- def self.load_members
435
- object_of :id, String
436
- object_of :account_number, String
437
- object_of :account_number_type, String
438
- object_of :routing_number, String
439
- object_of :account_type, String
440
- object_of :account_name, String
441
- object_of :check_type, String
442
- object_of :auth_type, String
443
- object_of :auth_capture_timestamp, String
444
- object_of :bank_name, String
445
- object_of :country_code, String
446
- object_of :first_name, String
447
- object_of :last_name, String
448
- object_of :birth_date, String
449
- object_of :billing_address, Address
450
- object_of :state, String
451
- object_of :confirmation_status, String
452
- object_of :payer_id, String
453
- object_of :external_customer_id, String
454
- object_of :merchant_id, String
455
- object_of :create_time, String
456
- object_of :update_time, String
457
- object_of :valid_until, String
458
- end
459
-
460
- include RequestDataType
461
-
462
- def create()
463
- path = "v1/vault/bank-accounts"
464
- response = api.post(path, self.to_hash, http_header)
465
- self.merge!(response)
466
- success?
467
- end
468
-
469
- class << self
470
- def find(resource_id)
471
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
472
- path = "v1/vault/bank-accounts/#{resource_id}"
473
- self.new(api.get(path))
474
- end
475
- end
476
-
477
- def delete()
478
- path = "v1/vault/bank-accounts/#{self.id}"
479
- response = api.delete(path, {})
480
- self.merge!(response)
481
- success?
482
- end
483
-
484
- def update(patch_request)
485
- patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
486
- path = "v1/vault/bank-accounts/#{self.id}"
487
- response = api.patch(path, patch_request.to_hash, http_header)
488
- self.merge!(response)
489
- success?
490
- end
491
-
492
- raise_on_api_error :create, :update, :delete
493
- end
494
-
495
- class ExtendedBankAccount < BankAccount
496
- def self.load_members
497
- object_of :mandate_reference_number, String
498
- end
499
- end
500
-
501
- class BankToken < Base
502
- def self.load_members
503
- object_of :bank_id, String
504
- object_of :external_customer_id, String
505
- object_of :mandate_reference_number, String
506
- end
507
- end
508
-
509
- class Credit < Base
510
- def self.load_members
511
- object_of :id, String
512
- object_of :type, String
513
- end
514
- end
515
-
516
- class Incentive < Base
517
- def self.load_members
518
- object_of :id, String
519
- object_of :code, String
520
- object_of :name, String
521
- object_of :description, String
522
- object_of :minimum_purchase_amount, Currency
523
- object_of :logo_image_url, String
524
- object_of :expiry_date, String
525
- object_of :type, String
526
- object_of :terms, String
527
- end
528
- end
529
-
530
- class Currency < Base
531
- def self.load_members
532
- object_of :currency, String
533
- object_of :value, String
534
- end
535
- end
536
-
537
- class CarrierAccountToken < Base
538
- def self.load_members
539
- object_of :carrier_account_id, String
540
- object_of :external_customer_id, String
541
- end
542
- end
543
-
544
- class FundingOption < Base
545
- def self.load_members
546
- object_of :id, String
547
- array_of :funding_sources, FundingSource
548
- object_of :backup_funding_instrument, FundingInstrument
549
- object_of :currency_conversion, CurrencyConversion
550
- object_of :installment_info, InstallmentInfo
551
- end
552
- end
553
-
554
- class FundingSource < Base
555
- def self.load_members
556
- object_of :funding_mode, String
557
- object_of :funding_instrument_type, String
558
- object_of :soft_descriptor, String
559
- object_of :amount, Currency
560
- object_of :negative_balance_amount, Currency
561
- object_of :legal_text, String
562
- object_of :terms, String
563
- object_of :funding_detail, FundingDetail
564
- object_of :additional_text, String
565
- object_of :extends, FundingInstrument
566
- object_of :negative_balance_amount, Currency
567
- object_of :links, Links
568
- end
569
- end
570
-
571
- class FundingDetail < Base
572
- def self.load_members
573
- object_of :clearing_time, String
574
- object_of :payment_hold_date, String
575
- object_of :payment_debit_date, String
576
- object_of :processing_type, String
577
- end
578
- end
579
-
580
- class CurrencyConversion < Base
581
- def self.load_members
582
- object_of :conversion_date, String
583
- object_of :from_currency, String
584
- object_of :from_amount, Number
585
- object_of :to_currency, String
586
- object_of :to_amount, Number
587
- object_of :conversion_type, String
588
- object_of :conversion_type_changeable, Boolean
589
- object_of :web_url, String
590
- end
591
- end
592
-
593
- class InstallmentInfo < Base
594
- def self.load_members
595
- object_of :installment_id, String
596
- object_of :network, String
597
- object_of :issuer, String
598
- array_of :installment_options, InstallmentOption
599
- end
600
- end
601
-
602
- class InstallmentOption < Base
603
- def self.load_members
604
- object_of :term, Integer
605
- object_of :monthly_payment, Currency
606
- object_of :discount_amount, Currency
607
- object_of :discount_percentage, Percentage
608
- end
609
- end
610
-
611
- class Percentage < Base
612
- def self.load_members
613
- end
614
- end
615
-
616
- class PayerInfo < Base
617
- def self.load_members
618
- object_of :email, String
619
- object_of :external_remember_me_id, String
620
- object_of :buyer_account_number, String
621
- object_of :salutation, String
622
- object_of :first_name, String
623
- object_of :middle_name, String
624
- object_of :last_name, String
625
- object_of :suffix, String
626
- object_of :payer_id, String
627
- object_of :phone, String
628
- object_of :phone_type, String
629
- object_of :birth_date, String
630
- object_of :tax_id, String
631
- object_of :tax_id_type, String
632
- object_of :country_code, String
633
- object_of :billing_address, Address
634
- object_of :shipping_address, ShippingAddress
635
- end
636
- end
637
-
638
- class ShippingAddress < Base
639
- def self.load_members
640
- object_of :line1, String
641
- object_of :line2, String
642
- object_of :city, String
643
- object_of :state, String
644
- object_of :postal_code, String
645
- object_of :country_code, String
646
- object_of :phone, String
647
- object_of :normalization_status, String
648
- object_of :id, String
649
- object_of :recipient_name, String
650
- end
651
- end
652
-
653
- class AllOf < Base
654
- def self.load_members
655
- array_of :related_resources, RelatedResources
656
- end
657
- end
658
-
659
- class Transaction < Base
660
- def self.load_members
661
- object_of :amount, Amount
662
- object_of :payee, Payee
663
- object_of :description, String
664
- object_of :invoice_number, String
665
- object_of :custom, String
666
- object_of :soft_descriptor, String
667
- object_of :item_list, ItemList
668
- object_of :notify_url, String
669
- object_of :purchase_unit_reference_id, String
670
- array_of :related_resources, RelatedResources
671
- array_of :transactions, Transaction
672
- object_of :payment_options, PaymentOptions
673
- end
674
- end
675
-
676
- class CartBase < Base
677
- def self.load_members
678
- object_of :amount, Amount
679
- object_of :payee, Payee
680
- object_of :description, String
681
- object_of :note_to_payee, String
682
- object_of :custom, String
683
- object_of :invoice_number, String
684
- object_of :soft_descriptor, String
685
- object_of :payment_options, PaymentOptions
686
- object_of :item_list, ItemList
687
- object_of :notify_url, String
688
- object_of :order_url, String
689
- object_of :reference_id, String
690
- end
691
- end
692
-
693
- class Amount < Base
694
- def self.load_members
695
- object_of :currency, String
696
- object_of :total, String
697
- object_of :details, Details
698
- end
699
- end
700
-
701
- class Details < Base
702
- def self.load_members
703
- object_of :subtotal, String
704
- object_of :shipping, String
705
- object_of :tax, String
706
- object_of :fee, String
707
- object_of :handling_fee, String
708
- object_of :shipping_discount, String
709
- object_of :insurance, String
710
- object_of :gift_wrap, String
711
- end
712
- end
713
-
714
- class Payee < Base
715
- def self.load_members
716
- object_of :email, String
717
- object_of :merchant_id, String
718
- object_of :phone, Phone
719
- end
720
- end
721
-
722
- class Phone < Base
723
- def self.load_members
724
- object_of :country_code, String
725
- object_of :national_number, String
726
- object_of :extension, String
727
- end
728
- end
729
-
730
- class PaymentOptions < Base
731
- def self.load_members
732
- object_of :allowed_payment_method, String
733
- end
734
- end
735
-
736
- class Item < Base
737
- def self.load_members
738
- object_of :sku, String
739
- object_of :name, String
740
- object_of :description, String
741
- object_of :quantity, String
742
- object_of :price, String
743
- object_of :currency, String
744
- object_of :tax, String
745
- object_of :url, String
746
- object_of :category, String
747
- object_of :weight, Measurement
748
- object_of :length, Measurement
749
- object_of :height, Measurement
750
- object_of :width, Measurement
751
- array_of :supplementary_data, NameValuePair
752
- array_of :postback_data, NameValuePair
753
- end
754
- end
755
-
756
- class Measurement < Base
757
- def self.load_members
758
- object_of :value, String
759
- object_of :unit, String
760
- end
761
- end
762
-
763
- class NameValuePair < Base
764
- def self.load_members
765
- object_of :name, String
766
- object_of :value, String
767
- end
768
- end
769
-
770
- class ItemList < Base
771
- def self.load_members
772
- array_of :items, Item
773
- object_of :shipping_address, ShippingAddress
774
- object_of :shipping_method, String
775
- object_of :shipping_phone_number, String
776
- end
777
- end
778
-
779
- class RelatedResources < Base
780
- def self.load_members
781
- object_of :sale, Sale
782
- object_of :authorization, Authorization
783
- object_of :order, Order
784
- object_of :capture, Capture
785
- object_of :refund, Refund
786
- end
787
- end
788
-
789
- class Sale < Base
790
- def self.load_members
791
- object_of :id, String
792
- object_of :purchase_unit_reference_id, String
793
- object_of :amount, Amount
794
- object_of :payment_mode, String
795
- object_of :state, String
796
- object_of :reason_code, String
797
- object_of :protection_eligibility, String
798
- object_of :protection_eligibility_type, String
799
- object_of :clearing_time, String
800
- object_of :recipient_fund_status, String
801
- object_of :payment_hold_status, String
802
- object_of :hold_reason, String
803
- object_of :transaction_fee, Currency
804
- object_of :receivable_amount, Currency
805
- object_of :exchange_rate, String
806
- object_of :fmf_details, FmfDetails
807
- object_of :receipt_id, String
808
- object_of :parent_payment, String
809
- object_of :create_time, String
810
- object_of :update_time, String
811
- array_of :links, Links
812
- object_of :billing_agreement_id, String
813
- object_of :payment_hold_reasons, String
814
- object_of :processor_response, ProcessorResponse
815
- end
816
-
817
- include RequestDataType
818
-
819
- class << self
820
- def find(resource_id)
821
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
822
- path = "v1/payments/sale/#{resource_id}"
823
- self.new(api.get(path))
824
- end
825
- end
826
-
827
- def refund(refund)
828
- refund = Refund.new(refund) unless refund.is_a? Refund
829
- path = "v1/payments/sale/#{self.id}/refund"
830
- response = api.post(path, refund.to_hash, http_header)
831
- Refund.new(response)
832
- end
833
-
834
- def refund_request(refund_request)
835
- refund_request = RefundRequest.new(refund_request) unless refund_request.is_a? RefundRequest
836
- path = "v1/payments/sale/#{self.id}/refund"
837
- response = api.post(path, refund_request.to_hash, http_header)
838
- DetailedRefund.new(response)
839
- end
840
-
841
- end
842
-
843
- class AnyOf < Base
844
- def self.load_members
845
- object_of :refund, Refund
846
- end
847
- end
848
-
849
- class Authorization < Base
850
- def self.load_members
851
- object_of :id, String
852
- object_of :amount, Amount
853
- object_of :payment_mode, String
854
- object_of :state, String
855
- object_of :reason_code, String
856
- object_of :protection_eligibility, String
857
- object_of :protection_eligibility_type, String
858
- object_of :fmf_details, FmfDetails
859
- object_of :parent_payment, String
860
- object_of :valid_until, String
861
- object_of :create_time, String
862
- object_of :update_time, String
863
- object_of :reference_id, String
864
- object_of :receipt_id, String
865
- array_of :links, Links
866
- end
867
-
868
- include RequestDataType
869
-
870
- class << self
871
- def find(resource_id)
872
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
873
- path = "v1/payments/authorization/#{resource_id}"
874
- self.new(api.get(path))
875
- end
876
- end
877
-
878
- def capture(capture)
879
- capture = Capture.new(capture) unless capture.is_a? Capture
880
- path = "v1/payments/authorization/#{self.id}/capture"
881
- response = api.post(path, capture.to_hash, http_header)
882
- Capture.new(response)
883
- end
884
-
885
- def void()
886
- path = "v1/payments/authorization/#{self.id}/void"
887
- response = api.post(path, {}, http_header)
888
- self.merge!(response)
889
- success?
890
- end
891
-
892
- def reauthorize()
893
- path = "v1/payments/authorization/#{self.id}/reauthorize"
894
- response = api.post(path, self.to_hash, http_header)
895
- self.merge!(response)
896
- success?
897
- end
898
-
899
- raise_on_api_error :capture, :void, :reauthorize
900
- end
901
-
902
- class Order < Base
903
- def self.load_members
904
- object_of :id, String
905
- object_of :purchase_unit_reference_id, String # Deprecated - use :reference_id instead
906
- object_of :reference_id, String
907
- object_of :amount, Amount
908
- object_of :payment_mode, String
909
- object_of :state, String
910
- object_of :reason_code, String
911
- object_of :pending_reason, String
912
- object_of :protection_eligibility, String
913
- object_of :protection_eligibility_type, String
914
- object_of :parent_payment, String
915
- object_of :fmf_details, FmfDetails
916
- object_of :create_time, String
917
- object_of :update_time, String
918
- array_of :links, Links
919
- end
920
-
921
- include RequestDataType
922
-
923
- class << self
924
- def find(resource_id)
925
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
926
- path = "v1/payments/orders/#{resource_id}"
927
- self.new(api.get(path))
928
- end
929
- end
930
-
931
- def capture(capture)
932
- capture = Capture.new(capture) unless capture.is_a? Capture
933
- path = "v1/payments/orders/#{self.id}/capture"
934
- response = api.post(path, capture.to_hash, http_header)
935
- Capture.new(response)
936
- end
937
-
938
- def void()
939
- path = "v1/payments/orders/#{self.id}/do-void"
940
- response = api.post(path, {}, http_header)
941
- self.merge!(response)
942
- success?
943
- end
944
-
945
- def authorize()
946
- path = "v1/payments/orders/#{self.id}/authorize"
947
- response = api.post(path, self.to_hash, http_header)
948
- Authorization.new(response)
949
- end
950
-
951
- raise_on_api_error :capture, :void, :authorize
952
- end
953
-
954
- class Capture < Base
955
- def self.load_members
956
- object_of :id, String
957
- object_of :amount, Amount
958
- object_of :is_final_capture, Boolean
959
- object_of :state, String
960
- object_of :reason_code, String
961
- object_of :parent_payment, String
962
- object_of :invoice_number, String
963
- object_of :transaction_fee, Currency
964
- object_of :create_time, String
965
- object_of :update_time, String
966
- array_of :links, Links
967
- end
968
-
969
- include RequestDataType
970
-
971
- class << self
972
- def find(resource_id)
973
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
974
- path = "v1/payments/capture/#{resource_id}"
975
- self.new(api.get(path))
976
- end
977
- end
978
-
979
- # Deprecated - please use refund_request
980
- def refund(refund)
981
- refund = Refund.new(refund) unless refund.is_a? Refund
982
- path = "v1/payments/capture/#{self.id}/refund"
983
- response = api.post(path, refund.to_hash, http_header)
984
- Refund.new(response)
985
- end
986
-
987
- def refund_request(refund_request)
988
- refund_request = RefundRequest.new(refund_request) unless refund_request.is_a? RefundRequest
989
- path = "v1/payments/capture/#{self.id}/refund"
990
- response = api.post(path, refund_request.to_hash, http_header)
991
- DetailedRefund.new(response)
992
- end
993
- end
994
-
995
- class Refund < Base
996
- def self.load_members
997
- object_of :id, String
998
- object_of :amount, Amount
999
- object_of :state, String
1000
- object_of :reason, String
1001
- object_of :invoice_number, String
1002
- object_of :sale_id, String
1003
- object_of :capture_id, String
1004
- object_of :parent_payment, String
1005
- object_of :description, String
1006
- object_of :create_time, String
1007
- object_of :update_time, String
1008
- object_of :reason_code, String
1009
- array_of :links, Links
1010
- end
1011
-
1012
- include RequestDataType
1013
-
1014
- class << self
1015
- def find(resource_id)
1016
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
1017
- path = "v1/payments/refund/#{resource_id}"
1018
- self.new(api.get(path))
1019
- end
1020
- end
1021
- end
1022
-
1023
- class RefundRequest < Base
1024
- def self.load_members
1025
- object_of :amount, Amount
1026
- object_of :description, String
1027
- object_of :refund_type, String
1028
- object_of :refund_source, String
1029
- object_of :reason, String
1030
- object_of :invoice_number, String
1031
- object_of :refund_advice, Boolean
1032
- object_of :is_non_platform_transaction, String
1033
- end
1034
- end
1035
-
1036
- class DetailedRefund < Refund
1037
- def self.load_members
1038
- object_of :custom, String
1039
- object_of :invoice_number, String
1040
- object_of :refund_to_payer, Currency
1041
- array_of :refund_to_external_funding, ExternalFunding
1042
- object_of :refund_from_transaction_fee, Currency
1043
- object_of :refund_from_received_amount, Currency
1044
- object_of :total_refunded_amount, Currency
1045
- end
1046
- end
1047
-
1048
- class Error < Base
1049
- def self.load_members
1050
- object_of :name, String
1051
- object_of :debug_id, String
1052
- object_of :message, String
1053
- object_of :code, String
1054
- object_of :information_link, String
1055
- array_of :details, ErrorDetails
1056
- array_of :links, Links
1057
- end
1058
- end
1059
-
1060
- class ErrorDetails < Base
1061
- def self.load_members
1062
- object_of :field, String
1063
- object_of :issue, String
1064
- object_of :code, String
1065
- end
1066
- end
1067
-
1068
- class FmfDetails < Base
1069
- def self.load_members
1070
- object_of :filter_type, String
1071
- object_of :filter_id, String
1072
- object_of :name, String
1073
- object_of :description, String
1074
- end
1075
- end
1076
-
1077
- class PaymentInstruction < Base
1078
- def self.load_members
1079
- object_of :reference_number, String
1080
- object_of :instruction_type, String
1081
- object_of :recipient_banking_instruction, RecipientBankingInstruction
1082
- object_of :amount, Currency
1083
- object_of :payment_due_date, String
1084
- object_of :note, String
1085
- array_of :links, Links
1086
- end
1087
-
1088
- include RequestDataType
1089
-
1090
- class << self
1091
- def find(resource_id)
1092
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
1093
- path = "v1/payments/payments/payment/#{resource_id}/payment-instruction"
1094
- self.new(api.get(path))
1095
- end
1096
- end
1097
- end
1098
-
1099
- class RecipientBankingInstruction < Base
1100
- def self.load_members
1101
- object_of :bank_name, String
1102
- object_of :account_holder_name, String
1103
- object_of :account_number, String
1104
- object_of :routing_number, String
1105
- object_of :international_bank_account_number, String
1106
- object_of :bank_identifier_code, String
1107
- end
1108
- end
1109
-
1110
- class RedirectUrls < Base
1111
- def self.load_members
1112
- object_of :return_url, String
1113
- object_of :cancel_url, String
1114
- end
1115
- end
1116
-
1117
- class Patch < Base
1118
- def self.load_members
1119
- object_of :op, String
1120
- object_of :path, String
1121
- object_of :value, Object
1122
- object_of :from, String
1123
- end
1124
- end
1125
-
1126
- class PatchRequest < Base
1127
- def self.load_members
1128
- object_of :op, String
1129
- object_of :path, String
1130
- object_of :value, Object
1131
- object_of :from, String
1132
- end
1133
-
1134
- end
1135
- class PaymentExecution < Base
1136
- def self.load_members
1137
- object_of :payer_id, String
1138
- object_of :carrier_account_id, String
1139
- array_of :transactions, CartBase
1140
- end
1141
- end
1142
-
1143
- class PaymentHistory < Base
1144
- def self.load_members
1145
- array_of :payments, Payment
1146
- object_of :count, Integer
1147
- object_of :next_id, String
1148
- end
1149
- end
1150
-
1151
- class CreditCardList < Base
1152
- def self.load_members
1153
- array_of :items, CreditCard
1154
- object_of :total_items, Integer
1155
- object_of :total_pages, Integer
1156
- array_of :links, Links
1157
- end
1158
-
1159
- class << self
1160
- def list(options={})
1161
- # for entire list of filter options, see https://developer.paypal.com/webapps/developer/docs/api/#list-credit-card-resources
1162
- path = "v1/vault/credit-cards"
1163
- response = api.get(path, options)
1164
- self.new(response)
1165
- end
1166
- end
1167
- end
1168
-
1169
- class BankAccountsList < Base
1170
- def self.load_members
1171
- array_of :bank_accounts, BankAccount
1172
- object_of :count, Integer
1173
- object_of :next_id, String
1174
- end
1175
- end
1176
-
1177
- class InvoiceAmountWrapper < Base
1178
- def self.load_members
1179
- object_of :paypal, Currency
1180
- end
1181
- end
1182
-
1183
- class Invoice < Base
1184
- def self.load_members
1185
- object_of :id, String
1186
- object_of :number, String
1187
- object_of :template_id, String
1188
- object_of :uri, String
1189
- object_of :status, String
1190
- object_of :merchant_info, MerchantInfo
1191
- array_of :billing_info, BillingInfo
1192
- array_of :cc_info, Participant
1193
- object_of :shipping_info, ShippingInfo
1194
- array_of :items, InvoiceItem
1195
- object_of :invoice_date, String
1196
- object_of :payment_term, PaymentTerm
1197
- object_of :reference, String
1198
- object_of :discount, Cost
1199
- object_of :shipping_cost, ShippingCost
1200
- object_of :custom, CustomAmount
1201
- object_of :allow_partial_payment, Boolean
1202
- object_of :minimum_amount_due, Currency
1203
- object_of :tax_calculated_after_discount, Boolean
1204
- object_of :tax_inclusive, Boolean
1205
- object_of :terms, String
1206
- object_of :note, String
1207
- object_of :merchant_memo, String
1208
- object_of :logo_url, String
1209
- object_of :total_amount, Currency
1210
- array_of :payments, PaymentDetail
1211
- array_of :refunds, RefundDetail
1212
- object_of :metadata, Metadata
1213
- object_of :additional_data, String
1214
- object_of :gratuity, Currency
1215
- object_of :paid_amount, PaymentSummary
1216
- object_of :refunded_amount, PaymentSummary
1217
- array_of :attachments, FileAttachment
1218
- array_of :links, Links
1219
- end
1220
-
1221
- include RequestDataType
1222
-
1223
- def create()
1224
- path = "v1/invoicing/invoices"
1225
- response = api.post(path, self.to_hash, http_header)
1226
- self.merge!(response)
1227
- success?
1228
- end
1229
-
1230
- def send_invoice()
1231
- path = "v1/invoicing/invoices/#{self.id}/send"
1232
- response = api.post(path, {}, http_header)
1233
- self.merge!(response)
1234
- success?
1235
- end
1236
-
1237
- def remind(notification)
1238
- notification = Notification.new(notification) unless notification.is_a? Notification
1239
- path = "v1/invoicing/invoices/#{self.id}/remind"
1240
- response = api.post(path, notification.to_hash, http_header)
1241
- self.merge!(response)
1242
- success?
1243
- end
1244
-
1245
- def cancel(cancel_notification)
1246
- cancel_notification = CancelNotification.new(cancel_notification) unless cancel_notification.is_a? CancelNotification
1247
- path = "v1/invoicing/invoices/#{self.id}/cancel"
1248
- response = api.post(path, cancel_notification.to_hash, http_header)
1249
- self.merge!(response)
1250
- success?
1251
- end
1252
-
1253
- def record_payment(payment_detail)
1254
- payment_detail = PaymentDetail.new(payment_detail) unless payment_detail.is_a? PaymentDetail
1255
- path = "v1/invoicing/invoices/#{self.id}/record-payment"
1256
- response = api.post(path, payment_detail.to_hash, http_header)
1257
- self.merge!(response)
1258
- success?
1259
- end
1260
-
1261
- def record_refund(refund_detail)
1262
- refund_detail = RefundDetail.new(refund_detail) unless refund_detail.is_a? RefundDetail
1263
- path = "v1/invoicing/invoices/#{self.id}/record-refund"
1264
- response = api.post(path, refund_detail.to_hash, http_header)
1265
- self.merge!(response)
1266
- success?
1267
- end
1268
-
1269
- def update()
1270
- path = "v1/invoicing/invoices/#{self.id}"
1271
- response = api.put(path, self.to_hash, http_header)
1272
- self.merge!(response)
1273
- success?
1274
- end
1275
-
1276
- def delete()
1277
- path = "v1/invoicing/invoices/#{self.id}"
1278
- response = api.delete(path, {})
1279
- self.merge!(response)
1280
- success?
1281
- end
1282
-
1283
- raise_on_api_error :create, :send_invoice, :remind, :cancel,
1284
- :record_payment, :record_refund, :update, :delete
1285
-
1286
- #
1287
- class << self
1288
- def search(options, access_token = nil)
1289
- path = "v1/invoicing/search"
1290
- api.token = access_token unless access_token.nil?
1291
- response = api.post(path, options)
1292
- Invoices.new(response)
1293
- end
1294
-
1295
- def find(resource_id, access_token = nil)
1296
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
1297
- path = "v1/invoicing/invoices/#{resource_id}"
1298
- api.token = access_token unless access_token.nil?
1299
- self.new(api.get(path))
1300
- end
1301
-
1302
- def get_all(options = {}, access_token = nil)
1303
- path = "v1/invoicing/invoices/"
1304
- api.token = access_token unless access_token.nil?
1305
- Invoices.new(api.get(path, options))
1306
- end
1307
-
1308
- def qr_code(options = {})
1309
- path = "v1/invoicing/invoices/{invoice_id}/qr-code"
1310
- object.new(api.get(path, options))
1311
- end
1312
-
1313
- def self.generate_number(options)
1314
- path = "v1/invoicing/invoices/next-invoice-number"
1315
- response = api.post(path, options)
1316
- object.new(response)
1317
- end
1318
- end
1319
- end
1320
-
1321
- class Participant < Base
1322
- def self.load_members
1323
- object_of :email, String
1324
- object_of :first_name, String
1325
- object_of :last_name, String
1326
- object_of :business_name, String
1327
- object_of :phone, Phone
1328
- object_of :fax, Phone
1329
- object_of :website, String
1330
- object_of :additional_info, String
1331
- object_of :address, Address
1332
- end
1333
- end
1334
-
1335
- class Template < Base
1336
-
1337
- def self.load_members
1338
- object_of :template_id, String
1339
- object_of :name, String
1340
- object_of :default, Boolean
1341
- object_of :template_data, TemplateData
1342
- array_of :settings, TemplateSettings
1343
- object_of :unit_of_measure, String
1344
- object_of :custom, Boolean
1345
- array_of :links, Links
1346
- end
1347
-
1348
- include RequestDataType
1349
-
1350
- def delete()
1351
- path = "v1/invoicing/templates/#{self.template_id}"
1352
- response = api.delete(path, {})
1353
- self.merge!(response)
1354
- success?
1355
- end
1356
-
1357
- def update()
1358
- path = "v1/invoicing/templates/#{self.template_id}"
1359
- response = api.put(path, self.to_hash, http_header)
1360
- self.merge!(response)
1361
- Template.new(response)
1362
- end
1363
-
1364
- def create()
1365
- path = "v1/invoicing/templates"
1366
- response = api.post(path, self.to_hash, http_header)
1367
- self.merge!(response)
1368
- Template.new(response)
1369
- end
1370
-
1371
- class << self
1372
- def get(template_id, options = {})
1373
- raise ArgumentError.new("template_id required") if template_id.to_s.strip.empty?
1374
- path = "v1/invoicing/templates/#{template_id}"
1375
- self.new(api.get(path, options))
1376
- end
1377
- end
1378
- end
1379
-
1380
- class TemplateData < Base
1381
-
1382
- def self.load_members
1383
- object_of :merchant_info, MerchantInfo
1384
- array_of :billing_info, BillingInfo
1385
- array_of :cc_info, String
1386
- object_of :shipping_info, ShippingInfo
1387
- array_of :items, InvoiceItem
1388
- object_of :payment_term, PaymentTerm
1389
- object_of :reference, String
1390
- object_of :discount, Cost
1391
- object_of :shipping_cost, ShippingCost
1392
- object_of :custom, CustomAmount
1393
- object_of :allow_partial_payment, Boolean
1394
- object_of :minimum_amount_due, Currency
1395
- object_of :tax_calculated_after_discount, Boolean
1396
- object_of :tax_inclusive, Boolean
1397
- object_of :terms, String
1398
- object_of :note, String
1399
- object_of :merchant_memo, String
1400
- object_of :logo_url, String
1401
- object_of :total_amount, Currency
1402
- array_of :attachments, FileAttachment
1403
- end
1404
-
1405
- end
1406
-
1407
- class TemplateSettings < Base
1408
-
1409
- def self.load_members
1410
- object_of :field_name, String
1411
- object_of :display_preference, TemplateSettingsMetadata
1412
- end
1413
- end
1414
-
1415
- class TemplateSettingsMetadata < Base
1416
-
1417
- def self.load_members
1418
- object_of :hidden, Boolean
1419
- end
1420
-
1421
- end
1422
-
1423
- class PaymentSummary < Base
1424
- def self.load_members
1425
- object_of :paypal, Currency
1426
- object_of :other, Currency
1427
- end
1428
- end
1429
- class FileAttachment < Base
1430
-
1431
- def self.load_members
1432
- object_of :name, String
1433
- object_of :url, String
1434
- end
1435
-
1436
- end
1437
- class Templates < Base
1438
-
1439
- def self.load_members
1440
- array_of :addresses, Address
1441
- array_of :emails, String
1442
- array_of :phones, Phone
1443
- array_of :templates, Template
1444
- array_of :links, Links
1445
- end
1446
-
1447
- include RequestDataType
1448
-
1449
- class << self
1450
- def get_all(options = {})
1451
- path = "v1/invoicing/templates/"
1452
- Templates.new(api.get(path, options))
1453
- end
1454
- end
1455
- end
1456
-
1457
- class WebhooksEventType < Base
1458
- def self.load_members
1459
- array_of :event_types, EventType
1460
- end
1461
-
1462
- include RequestDataType
1463
-
1464
- class << self
1465
- def all(options = {})
1466
- path = "v1/notifications/webhooks-event-types"
1467
- EventTypeList.new(api.get(path, options))
1468
- end
1469
- end
1470
- end
1471
-
1472
- class EventTypeList < Base
1473
- def self.load_members
1474
- array_of :event_types, EventType
1475
- end
1476
- end
1477
-
1478
- class WebhookList < Base
1479
- def self.load_members
1480
- array_of :webhooks, Webhook
1481
- end
1482
- end
1483
-
1484
- class EventType < Base
1485
- def self.load_members
1486
- object_of :name, String
1487
- object_of :description, String
1488
- object_of :status, String
1489
- end
1490
- end
1491
-
1492
- class WebhookEventList < Base
1493
- def self.load_members
1494
- object_of :count, Integer
1495
- array_of :events, WebhookEvent
1496
- array_of :links, Links
1497
- end
1498
- end
1499
-
1500
- class WebhookEvent < Base
1501
- def self.load_members
1502
- object_of :id, String
1503
- object_of :create_time, String
1504
- object_of :resource_type, String
1505
- object_of :event_version, String
1506
- object_of :event_type, String
1507
- object_of :summary, String
1508
- object_of :status, String
1509
- object_of :resource, Hash
1510
- array_of :links, Links
1511
- end
1512
-
1513
- def resend()
1514
- path = "v1/notifications/webhooks-events/#{self.id}/resend"
1515
- WebhookEvent.new(api.post(path))
1516
- end
1517
-
1518
- def get_resource()
1519
- webhook_resource_type = self.resource_type
1520
- resource_class = self.class.get_resource_class(webhook_resource_type)
1521
- if resource_class
1522
- return Object::const_get(resource_class).new(self.resource)
1523
- else
1524
- return self.resource
1525
- end
1526
- end
1527
-
1528
- include RequestDataType
1529
-
1530
- class << self
1531
-
1532
- def get_cert(cert_url)
1533
- data = Net::HTTP.get_response(URI.parse(cert_url))
1534
- cert = OpenSSL::X509::Certificate.new data.body
1535
- end
1536
-
1537
- def get_cert_chain()
1538
- root_cert = File.expand_path(File.join(File.dirname(__FILE__), '../../../data/DigiCertHighAssuranceEVRootCA.pem'))
1539
- intermediate_cert = File.expand_path(File.join(File.dirname(__FILE__), '../../../data/DigiCertSHA2ExtendedValidationServerCA.pem'))
1540
-
1541
- cert_store = OpenSSL::X509::Store.new
1542
- cert_store.add_file(root_cert)
1543
- cert_store.add_file(intermediate_cert)
1544
-
1545
- cert_store
1546
- end
1547
-
1548
- def get_expected_sig(transmission_id, timestamp, webhook_id, event_body)
1549
- utf8_encoded_event_body = event_body.force_encoding("UTF-8")
1550
- crc = Zlib::crc32(utf8_encoded_event_body).to_s
1551
- transmission_id + "|" + timestamp + "|" + webhook_id + "|" + crc
1552
- end
1553
-
1554
- def verify_common_name(cert)
1555
- common_name = cert.subject.to_a.select{|name, _, _| name == 'CN' }.first[1]
1556
-
1557
- common_name.start_with?("messageverificationcerts.") && common_name.end_with?(".paypal.com")
1558
- end
1559
-
1560
- def verify_signature(transmission_id, timestamp, webhook_id, event_body, cert, actual_sig_encoded, algo)
1561
- expected_sig = get_expected_sig(transmission_id, timestamp, webhook_id, event_body)
1562
-
1563
- digest = OpenSSL::Digest.new(algo)
1564
- digest.update(expected_sig)
1565
- actual_sig = Base64.decode64(actual_sig_encoded).force_encoding('UTF-8')
1566
-
1567
- cert.public_key.verify(digest, actual_sig, expected_sig)
1568
- end
1569
-
1570
- def verify_expiration(cert)
1571
- cert.not_after >= Time.now
1572
- end
1573
-
1574
- def verify_cert_chain(cert_store, cert)
1575
- cert_store.verify(cert)
1576
- end
1577
-
1578
- def verify_cert(cert)
1579
- cert_store = get_cert_chain()
1580
-
1581
- verify_cert_chain(cert_store, cert) && verify_common_name(cert) && verify_expiration(cert)
1582
- end
1583
-
1584
- def verify(transmission_id, timestamp, webhook_id, event_body, cert_url, sig, algo='sha256')
1585
- cert = get_cert(cert_url)
1586
- verify_signature(transmission_id, timestamp, webhook_id, event_body, cert, sig, algo) && verify_cert(cert)
1587
- end
1588
-
1589
- def get_resource_class(name)
1590
- class_array = PayPal::SDK::REST.constants.select {|c| Class === PayPal::SDK::REST.const_get(c)}
1591
- class_array.each do |classname|
1592
- if (classname.to_s.downcase == name.downcase)
1593
- return classname
1594
- end
1595
- end
1596
- end
1597
-
1598
- def search(page_size, start_time, end_time)
1599
- path = "v1/notifications/webhooks-events"
1600
- options = { :page_size => page_size, :start_time => start_time, :end_time => end_time }
1601
- WebhookEventList.new(api.get(path, options))
1602
- end
1603
-
1604
- def get(webhook_event_id)
1605
- WebhookEvent.find(webhook_event_id)
1606
- end
1607
-
1608
- def find(resource_id)
1609
- raise ArgumentError.new("webhook_event_id required") if resource_id.to_s.strip.empty?
1610
- path = "v1/notifications/webhooks-events/#{resource_id}"
1611
- self.new(api.get(path))
1612
- end
1613
-
1614
- def all(options = {})
1615
- path = "v1/notifications/webhooks-events"
1616
- WebhookEventList.new(api.get(path, options))
1617
- end
1618
- end
1619
- end
1620
-
1621
- class Webhook < Base
1622
-
1623
- def self.load_members
1624
- object_of :id, String
1625
- object_of :url, String
1626
- array_of :event_types, EventType
1627
- array_of :links, Links
1628
- end
1629
-
1630
- include RequestDataType
1631
-
1632
- def create()
1633
- path = "v1/notifications/webhooks"
1634
- response = api.post(path, self.to_hash, http_header)
1635
- self.merge!(response)
1636
- Webhook.new(response)
1637
- end
1638
-
1639
- def update(patch)
1640
- patch = Patch.new(patch) unless patch.is_a? Patch
1641
- patch_request = Array.new(1, patch.to_hash)
1642
- path = "v1/notifications/webhooks/#{self.id}"
1643
- response = api.patch(path, patch_request, http_header)
1644
- self.merge!(response)
1645
- success?
1646
- end
1647
-
1648
- def delete()
1649
- path = "v1/notifications/webhooks/#{self.id}"
1650
- response = api.delete(path, {})
1651
- self.merge!(response)
1652
- success?
1653
- end
1654
-
1655
- raise_on_api_error :update, :delete
1656
-
1657
- class << self
1658
- def get(webhook_id)
1659
- raise ArgumentError.new("webhook_id required") if webhook_id.to_s.strip.empty?
1660
- path = "v1/notifications/webhooks/#{webhook_id}"
1661
- Webhook.new(api.get(path))
1662
- end
1663
-
1664
- def get_event_types(webhook_id)
1665
- raise ArgumentError.new("webhook_id required") if webhook_id.to_s.strip.empty?
1666
- path = "v1/notifications/webhooks/#{webhook_id}/event-types"
1667
- EventTypeList.new(api.get(path))
1668
- end
1669
-
1670
- def all(options={})
1671
- path = "v1/notifications/webhooks"
1672
- WebhookList.new(api.get(path))
1673
- end
1674
-
1675
- def simulate_event(webhook_id, url, event_type)
1676
- path = "v1/notifications/simulate-event"
1677
- options = { :webhook_id => webhook_id, :url => url, :event_type => event_type }
1678
- response = api.post(path, options)
1679
- WebhookEvent.new(response)
1680
- end
1681
- end
1682
- end
1683
-
1684
- class Payout < Base
1685
-
1686
- def self.load_members
1687
- object_of :sender_batch_header, PayoutSenderBatchHeader
1688
- array_of :items, PayoutItem
1689
- end
1690
-
1691
- include RequestDataType
1692
-
1693
- def create(sync_mode = false)
1694
- path = "v1/payments/payouts"
1695
- options = { :sync_mode => sync_mode }
1696
- response = api.post(path, self.to_hash, http_header, options)
1697
- PayoutBatch.new(response)
1698
- end
1699
-
1700
- class << self
1701
- def get(payout_batch_id, options = {})
1702
- raise ArgumentError.new("id required") if payout_batch_id.to_s.strip.empty?
1703
- path = "v1/payments/payouts/#{payout_batch_id}"
1704
- PayoutBatch.new(api.get(path, options))
1705
- end
1706
- end
1707
- end
1708
- class PayoutItem < Base
1709
-
1710
- def self.load_members
1711
- object_of :recipient_type, String
1712
- object_of :amount, Currency
1713
- object_of :note, String
1714
- object_of :receiver, String
1715
- object_of :sender_item_id, String
1716
- end
1717
-
1718
- include RequestDataType
1719
-
1720
- class << self
1721
- def get(payout_item_id)
1722
- raise ArgumentError.new("payout_item_id required") if payout_item_id.to_s.strip.empty?
1723
- path = "v1/payments/payouts-item/#{payout_item_id}"
1724
- PayoutItemDetails.new(api.get(path))
1725
- end
1726
- def cancel(payout_item_id)
1727
- raise ArgumentError.new("payout_item_id required") if payout_item_id.to_s.strip.empty?
1728
- path = "v1/payments/payouts-item/#{payout_item_id}/cancel"
1729
- PayoutItemDetails.new(api.post(path))
1730
- end
1731
- end
1732
-
1733
- end
1734
- class PayoutItemDetails < Base
1735
-
1736
- def self.load_members
1737
- object_of :payout_item_id, String
1738
- object_of :transaction_id, String
1739
- object_of :transaction_status, String
1740
- object_of :payout_item_fee, Currency
1741
- object_of :payout_batch_id, String
1742
- object_of :sender_batch_id, String
1743
- object_of :payout_item, PayoutItem
1744
- object_of :time_processed, String
1745
- object_of :errors, Error
1746
- array_of :links, Links
1747
- end
1748
-
1749
- end
1750
- class PayoutBatch < Base
1751
-
1752
- def self.load_members
1753
- object_of :batch_header, PayoutBatchHeader
1754
- array_of :items, PayoutItemDetails
1755
- array_of :links, Links
1756
- end
1757
-
1758
- end
1759
- class PayoutBatchHeader < Base
1760
-
1761
- def self.load_members
1762
- object_of :payout_batch_id, String
1763
- object_of :batch_status, String
1764
- object_of :time_created, String
1765
- object_of :time_completed, String
1766
- object_of :sender_batch_header, PayoutSenderBatchHeader
1767
- object_of :amount, Currency
1768
- object_of :fees, Currency
1769
- object_of :errors, Error
1770
- end
1771
-
1772
- end
1773
- class PayoutSenderBatchHeader < Base
1774
-
1775
- def self.load_members
1776
- object_of :sender_batch_id, String
1777
- object_of :email_subject, String
1778
- object_of :recipient_type, String
1779
- end
1780
-
1781
- end
1782
- class Invoices < Base
1783
- def self.load_members
1784
- object_of :total_count, Integer
1785
- array_of :invoices, Invoice
1786
- end
1787
- end
1788
-
1789
- class InvoiceItem < Base
1790
- def self.load_members
1791
- object_of :name, String
1792
- object_of :description, String
1793
- object_of :quantity, Number
1794
- object_of :unit_price, Currency
1795
- object_of :tax, Tax
1796
- object_of :date, String
1797
- object_of :discount, Cost
1798
- object_of :image_url, String
1799
- object_of :unit_of_measure, String
1800
- end
1801
- end
1802
-
1803
- class MerchantInfo < Base
1804
- def self.load_members
1805
- object_of :email, String
1806
- object_of :first_name, String
1807
- object_of :last_name, String
1808
- object_of :address, Address
1809
- object_of :business_name, String
1810
- object_of :phone, Phone
1811
- object_of :fax, Phone
1812
- object_of :website, String
1813
- object_of :tax_id, String
1814
- object_of :additional_info_label, String
1815
- object_of :additional_info, String
1816
- end
1817
- end
1818
-
1819
- class BillingInfo < Base
1820
- def self.load_members
1821
- object_of :email, String
1822
- object_of :first_name, String
1823
- object_of :last_name, String
1824
- object_of :business_name, String
1825
- object_of :address, InvoiceAddress
1826
- object_of :language, String
1827
- object_of :additional_info, String
1828
- object_of :notification_channel, String
1829
- object_of :phone, Phone
1830
-
1831
- define_method "address=" do |value|
1832
- if value.is_a?(Address)
1833
- value = value.to_hash
1834
- end
1835
- object = convert_object(value, InvoiceAddress)
1836
- instance_variable_set("@address", object)
1837
- end
1838
-
1839
- define_method "address" do |&block|
1840
- default_value = PayPal::SDK::Core::Util::OrderedHash.new
1841
- value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1842
- value = convert_object(value.to_hash, Address)
1843
- value
1844
- end
1845
-
1846
- define_method "invoice_address=" do |value|
1847
- object = convert_object(value, InvoiceAddress)
1848
- instance_variable_set("@address", object)
1849
- end
1850
-
1851
- define_method "invoice_address" do |&block|
1852
- default_value = PayPal::SDK::Core::Util::OrderedHash.new
1853
- value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1854
- value
1855
- end
1856
- end
1857
- end
1858
-
1859
- class ShippingInfo < Base
1860
- def self.load_members
1861
- object_of :first_name, String
1862
- object_of :last_name, String
1863
- object_of :business_name, String
1864
- object_of :address, InvoiceAddress
1865
- object_of :email, String
1866
-
1867
- define_method "address=" do |value|
1868
- if value.is_a?(Address)
1869
- value = value.to_hash
1870
- end
1871
- object = convert_object(value, InvoiceAddress)
1872
- instance_variable_set("@address", object)
1873
- end
1874
-
1875
- define_method "address" do |&block|
1876
- default_value = PayPal::SDK::Core::Util::OrderedHash.new
1877
- value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1878
- value = convert_object(value.to_hash, Address)
1879
- value
1880
- end
1881
-
1882
- define_method "invoice_address=" do |value|
1883
- object = convert_object(value, InvoiceAddress)
1884
- instance_variable_set("@address", object)
1885
- end
1886
-
1887
- define_method "invoice_address" do |&block|
1888
- default_value = PayPal::SDK::Core::Util::OrderedHash.new
1889
- value = instance_variable_get("@address") || ( default_value && (send("address=", default_value)))
1890
- value
1891
- end
1892
- end
1893
- end
1894
-
1895
- class InvoicingNotification < Base
1896
- def self.load_members
1897
- object_of :subject, String
1898
- object_of :note, String
1899
- object_of :send_to_merchant, Boolean
1900
- array_of :cc_emails, String
1901
- end
1902
- end
1903
-
1904
- class InvoicingMetaData < Base
1905
- def self.load_members
1906
- object_of :created_date, String
1907
- object_of :created_by, String
1908
- object_of :cancelled_date, String
1909
- object_of :cancelled_by, String
1910
- object_of :last_updated_date, String
1911
- object_of :last_updated_by, String
1912
- object_of :first_sent_date, String
1913
- object_of :last_sent_date, String
1914
- object_of :last_sent_by, String
1915
- end
1916
- end
1917
-
1918
- class InvoicingPaymentDetail < Base
1919
- def self.load_members
1920
- object_of :type, String
1921
- object_of :transaction_id, String
1922
- object_of :transaction_type, String
1923
- object_of :date, String
1924
- object_of :method, String
1925
- object_of :note, String
1926
- end
1927
- end
1928
-
1929
- class InvoicingRefundDetail < Base
1930
- def self.load_members
1931
- object_of :type, String
1932
- object_of :date, String
1933
- object_of :note, String
1934
- end
1935
- end
1936
-
1937
- class InvoicingSearch < Base
1938
- def self.load_members
1939
- object_of :email, String
1940
- object_of :recipient_first_name, String
1941
- object_of :recipient_last_name, String
1942
- object_of :recipient_business_name, String
1943
- object_of :number, String
1944
- object_of :status, String
1945
- object_of :lower_total_amount, Currency
1946
- object_of :upper_total_amount, Currency
1947
- object_of :start_invoice_date, String
1948
- object_of :end_invoice_date, String
1949
- object_of :start_due_date, String
1950
- object_of :end_due_date, String
1951
- object_of :start_payment_date, String
1952
- object_of :end_payment_date, String
1953
- object_of :start_creation_date, String
1954
- object_of :end_creation_date, String
1955
- object_of :page, Number
1956
- object_of :page_size, Number
1957
- object_of :total_count_required, Boolean
1958
- object_of :archived, Boolean
1959
- end
1960
- end
1961
-
1962
- class PaymentTerm < Base
1963
- def self.load_members
1964
- object_of :term_type, String
1965
- object_of :due_date, String
1966
- end
1967
- end
1968
-
1969
- class Cost < Base
1970
- def self.load_members
1971
- object_of :percent, Number
1972
- object_of :amount, Currency
1973
- end
1974
- end
1975
-
1976
- class ShippingCost < Base
1977
- def self.load_members
1978
- object_of :amount, Currency
1979
- object_of :tax, Tax
1980
- end
1981
- end
1982
-
1983
- class Tax < Base
1984
- def self.load_members
1985
- object_of :id, String
1986
- object_of :name, String
1987
- object_of :percent, Number
1988
- object_of :amount, Currency
1989
- end
1990
- end
1991
-
1992
- class CustomAmount < Base
1993
- def self.load_members
1994
- object_of :label, String
1995
- object_of :amount, Currency
1996
- end
1997
- end
1998
-
1999
- class PaymentDetail < Base
2000
- def self.load_members
2001
- object_of :type, String
2002
- object_of :transaction_id, String
2003
- object_of :transaction_type, String
2004
- object_of :date, String
2005
- object_of :method, String
2006
- object_of :note, String
2007
- end
2008
- end
2009
-
2010
- class RefundDetail < Base
2011
- def self.load_members
2012
- object_of :type, String
2013
- object_of :date, String
2014
- object_of :note, String
2015
- end
2016
- end
2017
-
2018
- class Metadata < Base
2019
- def self.load_members
2020
- object_of :created_date, String
2021
- object_of :created_by, String
2022
- object_of :cancelled_date, String
2023
- object_of :cancelled_by, String
2024
- object_of :last_updated_date, String
2025
- object_of :last_updated_by, String
2026
- object_of :first_sent_date, String
2027
- object_of :last_sent_date, String
2028
- object_of :last_sent_by, String
2029
- object_of :payer_view_url, String
2030
- end
2031
- end
2032
-
2033
- class Notification < Base
2034
- def self.load_members
2035
- object_of :subject, String
2036
- object_of :note, String
2037
- object_of :send_to_merchant, Boolean
2038
- end
2039
- end
2040
-
2041
- class Search < Base
2042
- def self.load_members
2043
- object_of :email, String
2044
- object_of :recipient_first_name, String
2045
- object_of :recipient_last_name, String
2046
- object_of :recipient_business_name, String
2047
- object_of :number, String
2048
- object_of :status, String
2049
- object_of :lower_total_amount, Currency
2050
- object_of :upper_total_amount, Currency
2051
- object_of :start_invoice_date, String
2052
- object_of :end_invoice_date, String
2053
- object_of :start_due_date, String
2054
- object_of :end_due_date, String
2055
- object_of :start_payment_date, String
2056
- object_of :end_payment_date, String
2057
- object_of :start_creation_date, String
2058
- object_of :end_creation_date, String
2059
- object_of :page, Number
2060
- object_of :page_size, Number
2061
- object_of :total_count_required, Boolean
2062
- end
2063
- end
2064
-
2065
- class CancelNotification < Base
2066
- def self.load_members
2067
- object_of :subject, String
2068
- object_of :note, String
2069
- object_of :send_to_merchant, Boolean
2070
- object_of :send_to_payer, Boolean
2071
- end
2072
- end
2073
-
2074
- class Plan < Base
2075
- def self.load_members
2076
- object_of :id, String
2077
- object_of :name, String
2078
- object_of :description, String
2079
- object_of :type, String
2080
- object_of :state, String
2081
- object_of :create_time, String
2082
- object_of :update_time, String
2083
- array_of :payment_definitions, PaymentDefinition
2084
- array_of :terms, Terms
2085
- object_of :merchant_preferences, MerchantPreferences
2086
- array_of :links, Links
2087
- end
2088
-
2089
- include RequestDataType
2090
-
2091
- def create()
2092
- path = "v1/payments/billing-plans/"
2093
- response = api.post(path, self.to_hash, http_header)
2094
- self.merge!(response)
2095
- success?
2096
- end
2097
-
2098
- def update(patch)
2099
- patch = Patch.new(patch) unless patch.is_a? Patch
2100
- patch_request = Array.new(1, patch.to_hash)
2101
- path = "v1/payments/billing-plans/#{self.id}"
2102
- response = api.patch(path, patch_request, http_header)
2103
- self.merge!(response)
2104
- success?
2105
- end
2106
-
2107
- raise_on_api_error :create, :update
2108
-
2109
- class << self
2110
- def find(resource_id)
2111
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
2112
- path = "v1/payments/billing-plans/#{resource_id}"
2113
- self.new(api.get(path))
2114
- end
2115
-
2116
- def all(options = {})
2117
- path = "v1/payments/billing-plans/"
2118
- PlanList.new(api.get(path, options))
2119
- end
2120
- end
2121
- end
2122
-
2123
- class PaymentDefinition < Base
2124
- def self.load_members
2125
- object_of :id, String
2126
- object_of :name, String
2127
- object_of :type, String
2128
- object_of :frequency_interval, String
2129
- object_of :frequency, String
2130
- object_of :cycles, String
2131
- object_of :amount, Currency
2132
- array_of :charge_models, ChargeModels
2133
- end
2134
- end
2135
-
2136
- class ChargeModels < Base
2137
- def self.load_members
2138
- object_of :id, String
2139
- object_of :type, String
2140
- object_of :amount, Currency
2141
- end
2142
- end
2143
-
2144
- class Terms < Base
2145
- def self.load_members
2146
- object_of :id, String
2147
- object_of :type, String
2148
- object_of :max_billing_amount, Currency
2149
- object_of :occurrences, String
2150
- object_of :amount_range, Currency
2151
- object_of :buyer_editable, String
2152
- end
2153
- end
2154
-
2155
- class MerchantPreferences < Base
2156
- def self.load_members
2157
- object_of :id, String
2158
- object_of :setup_fee, Currency
2159
- object_of :cancel_url, String
2160
- object_of :return_url, String
2161
- object_of :notify_url, String
2162
- object_of :max_fail_attempts, String
2163
- object_of :auto_bill_amount, String
2164
- object_of :initial_fail_amount_action, String
2165
- object_of :accepted_payment_type, String
2166
- object_of :char_set, String
2167
- end
2168
- end
2169
-
2170
- class Links < Base
2171
- def self.load_members
2172
- object_of :href, String
2173
- object_of :rel, String
2174
- object_of :targetSchema, HyperSchema
2175
- object_of :method, String
2176
- object_of :encType, String
2177
- object_of :schema, HyperSchema
2178
- end
2179
- end
2180
-
2181
- class Schema < Base
2182
- def self.load_members
2183
- object_of :type, Object
2184
- object_of :properties, Schema
2185
- object_of :patternProperties, Schema
2186
- object_of :additionalProperties, Object
2187
- object_of :items, Object
2188
- object_of :additionalItems, Object
2189
- object_of :required, Boolean
2190
- object_of :dependencies, Object
2191
- object_of :minimum, Number
2192
- object_of :maximum, Number
2193
- object_of :exclusiveMinimum, Boolean
2194
- object_of :exclusiveMaximum, Boolean
2195
- object_of :minItems, Integer
2196
- object_of :maxItems, Integer
2197
- object_of :uniqueItems, Boolean
2198
- object_of :pattern, String
2199
- object_of :minLength, Integer
2200
- object_of :maxLength, Integer
2201
- array_of :enum, Array
2202
- object_of :title, String
2203
- object_of :description, String
2204
- object_of :format, String
2205
- object_of :divisibleBy, Number
2206
- object_of :disallow, Object
2207
- object_of :extends, Object
2208
- object_of :id, String
2209
- object_of :$ref, String
2210
- object_of :$schema, String
2211
- end
2212
- end
2213
-
2214
- class HyperSchema < Schema
2215
- def self.load_members
2216
- array_of :links, Links
2217
- object_of :fragmentResolution, String
2218
- object_of :readonly, Boolean
2219
- object_of :contentEncoding, String
2220
- object_of :pathStart, String
2221
- object_of :mediaType, String
2222
- end
2223
- end
2224
-
2225
- class PlanList < Base
2226
- def self.load_members
2227
- array_of :plans, Plan
2228
- object_of :total_items, String
2229
- object_of :total_pages, String
2230
- array_of :links, Links
2231
- end
2232
- end
2233
-
2234
- class Agreement < Base
2235
- def self.load_members
2236
- object_of :id, String
2237
- object_of :state, String
2238
- object_of :name, String
2239
- object_of :description, String
2240
- object_of :start_date, String
2241
- object_of :agreement_details, AgreementDetails
2242
- object_of :payer, Payer
2243
- object_of :shipping_address, Address
2244
- object_of :override_merchant_preferences, MerchantPreferences
2245
- array_of :override_charge_models, OverrideChargeModel
2246
- object_of :plan, Plan
2247
- object_of :create_time, String
2248
- object_of :update_time, String
2249
- array_of :links, Links
2250
- object_of :token, String
2251
- end
2252
-
2253
- include RequestDataType
2254
-
2255
- def create()
2256
- path = "v1/payments/billing-agreements/"
2257
- response = api.post(path, self.to_hash, http_header)
2258
- self.merge!(response)
2259
- self.get_token(self.links)
2260
- success?
2261
- end
2262
-
2263
- def execute()
2264
- path = "v1/payments/billing-agreements/#{self.token}/agreement-execute"
2265
- response = api.post(path, {}, http_header)
2266
- self.merge!(response)
2267
- success?
2268
- end
2269
-
2270
- class << self
2271
- def find(resource_id)
2272
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
2273
- path = "v1/payments/billing-agreements/#{resource_id}"
2274
- self.new(api.get(path))
2275
- end
2276
- end
2277
-
2278
- def update(patch)
2279
- patch = Patch.new(patch) unless patch.is_a? Patch
2280
- path = "v1/payments/billing-agreements/#{self.id}"
2281
- response = api.patch(path, [patch.to_hash], http_header)
2282
- self.merge!(response)
2283
- success?
2284
- end
2285
-
2286
- def suspend(agreement_state_descriptor)
2287
- agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
2288
- path = "v1/payments/billing-agreements/#{self.id}/suspend"
2289
- response = api.post(path, agreement_state_descriptor.to_hash, http_header)
2290
- self.merge!(response)
2291
- success?
2292
- end
2293
-
2294
- def re_activate(agreement_state_descriptor)
2295
- agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
2296
- path = "v1/payments/billing-agreements/#{self.id}/re-activate"
2297
- response = api.post(path, agreement_state_descriptor.to_hash, http_header)
2298
- self.merge!(response)
2299
- success?
2300
- end
2301
-
2302
- def cancel(agreement_state_descriptor)
2303
- agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
2304
- path = "v1/payments/billing-agreements/#{self.id}/cancel"
2305
- response = api.post(path, agreement_state_descriptor.to_hash, http_header)
2306
- self.merge!(response)
2307
- success?
2308
- end
2309
-
2310
- def bill_balance(agreement_state_descriptor)
2311
- agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
2312
- path = "v1/payments/billing-agreements/#{self.id}/bill-balance"
2313
- response = api.post(path, agreement_state_descriptor.to_hash, http_header)
2314
- self.merge!(response)
2315
- success?
2316
- end
2317
-
2318
- def set_balance(currency)
2319
- currency = Currency.new(currency) unless currency.is_a? Currency
2320
- path = "v1/payments/billing-agreements/#{self.id}/set-balance"
2321
- response = api.post(path, currency.to_hash, http_header)
2322
- self.merge!(response)
2323
- success?
2324
- end
2325
-
2326
- raise_on_api_error :create, :execute, :update, :suspend, :re_activate,
2327
- :cancel, :bill_balance, :set_balance
2328
-
2329
- class << self
2330
- def transactions(agreement_id, start_date, end_date, options = {})
2331
- path = "v1/payments/billing-agreements/#{agreement_id}/transactions" #?start-date=#{start_date}&end-date=#{end_date}"
2332
- options = { :start_date => start_date, :end_date => end_date }
2333
- AgreementTransactions.new(api.get(path, options))
2334
- end
2335
- end
2336
-
2337
- def get_token(links)
2338
- links.each do |link|
2339
- if link.rel.eql? "approval_url"
2340
- uri = URI.parse(link.href)
2341
- params = CGI.parse(uri.query)
2342
- self.token = params['token'][0]
2343
- return
2344
- end
2345
- end
2346
- end
2347
- end
2348
- class AgreementDetails < Base
2349
- def self.load_members
2350
- object_of :outstanding_balance, Currency
2351
- object_of :cycles_remaining, String
2352
- object_of :cycles_completed, String
2353
- object_of :next_billing_date, String
2354
- object_of :last_payment_date, String
2355
- object_of :last_payment_amount, Currency
2356
- object_of :final_payment_date, String
2357
- object_of :failed_payment_count, String
2358
- end
2359
- end
2360
-
2361
- class OverrideChargeModel < Base
2362
- def self.load_members
2363
- object_of :charge_id, String
2364
- object_of :amount, Currency
2365
- end
2366
- end
2367
-
2368
- class AgreementStateDescriptor < Base
2369
- def self.load_members
2370
- object_of :note, String
2371
- object_of :amount, Currency
2372
- end
2373
- end
2374
-
2375
- class AgreementTransactions < Base
2376
- def self.load_members
2377
- array_of :agreement_transaction_list, AgreementTransaction
2378
- end
2379
- end
2380
-
2381
- class AgreementTransaction < Base
2382
- def self.load_members
2383
- object_of :transaction_id, String
2384
- object_of :status, String
2385
- object_of :transaction_type, String
2386
- object_of :amount, Currency
2387
- object_of :fee_amount, Currency
2388
- object_of :net_amount, Currency
2389
- object_of :payer_email, String
2390
- object_of :payer_name, String
2391
- object_of :time_zone, String
2392
- object_of :time_stamp, DateTime
2393
- end
2394
- end
2395
-
2396
- class WebProfile < Base
2397
- def self.load_members
2398
- object_of :id, String
2399
- object_of :name, String
2400
- object_of :temporary, Boolean
2401
- object_of :flow_config, FlowConfig
2402
- object_of :input_fields, InputFields
2403
- object_of :presentation, Presentation
2404
- end
2405
-
2406
- include RequestDataType
2407
-
2408
- def create()
2409
- path = "v1/payment-experience/web-profiles/"
2410
- response = api.post(path, self.to_hash, http_header)
2411
- self.merge!(response)
2412
- WebProfile.new(response)
2413
- end
2414
-
2415
- def update()
2416
- path = "v1/payment-experience/web-profiles/#{self.id}"
2417
- response = api.put(path, self.to_hash, http_header)
2418
- self.merge!(response)
2419
- success?
2420
- end
2421
-
2422
- def partial_update(patch_request)
2423
- patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
2424
- path = "v1/payment-experience/web-profiles/#{self.id}"
2425
- response = api.patch(path, patch_request.to_hash, http_header)
2426
- self.merge!(response)
2427
- success?
2428
- end
2429
-
2430
- def delete()
2431
- path = "v1/payment-experience/web-profiles/#{self.id}"
2432
- response = api.delete(path, {})
2433
- self.merge!(response)
2434
- success?
2435
- end
2436
-
2437
- raise_on_api_error :update, :partial_update, :delete
2438
-
2439
- class << self
2440
- def find(resource_id)
2441
- raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
2442
- path = "v1/payment-experience/web-profiles/#{resource_id}"
2443
- self.new(api.get(path))
2444
- end
2445
-
2446
- def get_list(options = {})
2447
- path = "v1/payment-experience/web-profiles/"
2448
- l = api.get(path, options)
2449
- # The API is inconsistent in that it returns an array of WebProfiles
2450
- # instead of a JSON object with a property which should be a list
2451
- # of WebProfiles.
2452
- #
2453
- # Note that the WebProfileList is technically incorrect. It should
2454
- # be a WebProfile.new() here, but due to backwards-compatibility,
2455
- # may need to leave it as WebProfileList.
2456
- l.map { |x| WebProfileList.new(x) }
2457
- end
2458
- end
2459
- end
2460
-
2461
- class FlowConfig < Base
2462
- def self.load_members
2463
- object_of :landing_page_type, String
2464
- object_of :bank_txn_pending_url, String
2465
- object_of :user_action, String
2466
- object_of :return_uri_http_method, String
2467
- end
2468
- end
2469
-
2470
- class InputFields < Base
2471
- def self.load_members
2472
- object_of :allow_note, Boolean
2473
- object_of :no_shipping, Integer
2474
- object_of :address_override, Integer
2475
- end
2476
- end
2477
-
2478
- class Presentation < Base
2479
- def self.load_members
2480
- object_of :brand_name, String
2481
- object_of :logo_image, String
2482
- object_of :locale_code, String
2483
- object_of :return_url_label, String
2484
- object_of :note_to_seller_label, String
2485
- end
2486
- end
2487
-
2488
- class WebProfileList < Base
2489
- def self.load_members
2490
- object_of :id, String
2491
- object_of :name, String
2492
- object_of :flow_config, FlowConfig
2493
- object_of :input_fields, InputFields
2494
- object_of :presentation, Presentation
2495
- object_of :temporary, Boolean
2496
- end
2497
- end
2498
-
2499
- class Dispute < Base
2500
- def self.load_members
2501
- object_of :dispute_id, String
2502
- object_of :create_time, String
2503
- object_of :update_time, String
2504
- array_of :disputed_transactions, TransactionInfo
2505
- object_of :reason, String
2506
- object_of :status, String
2507
- object_of :dispute_amount, Money
2508
- object_of :external_reason_code, String
2509
- object_of :dispute_outcome, DisputeOutcome
2510
- object_of :dispute_life_cycle_stage, String
2511
- object_of :dispute_channel, String
2512
- array_of :messages, Messages
2513
- object_of :buyer_response_due_date, String
2514
- object_of :seller_response_due_date, String
2515
- object_of :offer, Offer
2516
- array_of :links, Links
2517
- end
2518
- end
2519
-
2520
- class TransactionInfo < Base
2521
- def self.load_members
2522
- object_of :buyer_transaction_id, String
2523
- object_of :seller_transaction_id, String
2524
- object_of :create_time, String
2525
- object_of :transaction_status, String
2526
- object_of :gross_amount, Money
2527
- object_of :invoice_number, String
2528
- object_of :custom, String
2529
- object_of :buyer, Buyer
2530
- object_of :seller, Seller
2531
- array_of :items, ItemInfo
2532
- end
2533
- end
2534
-
2535
- class Buyer < Base
2536
- def self.load_members
2537
- object_of :email, String
2538
- object_of :name, String
2539
- end
2540
- end
2541
-
2542
- class Seller < Base
2543
- def self.load_members
2544
- object_of :email, String
2545
- object_of :merchant_id, String
2546
- object_of :name, String
2547
- end
2548
- end
2549
-
2550
- class ItemInfo < Base
2551
- def self.load_members
2552
- object_of :item_id, String
2553
- object_of :partner_transaction_id, String
2554
- object_of :reason, String
2555
- object_of :dispute_amount, Money
2556
- object_of :notes, String
2557
- end
2558
- end
2559
-
2560
- class Money < Base
2561
- def self.load_members
2562
- object_of :currency_code, String
2563
- object_of :value, String
2564
- end
2565
- end
2566
-
2567
- class DisputeOutcome < Base
2568
- def self.load_members
2569
- object_of :outcome_code, String
2570
- object_of :amount_refunded, Money
2571
- end
2572
- end
2573
-
2574
- class Messages < Base
2575
- def self.load_members
2576
- object_of :posted_by, String
2577
- object_of :time_posted, String
2578
- object_of :content, String
2579
- end
2580
- end
2581
-
2582
- class Offer < Base
2583
- def self.load_members
2584
- object_of :buyer_requested_amount, Money
2585
- object_of :seller_offered_amount, Money
2586
- object_of :offer_type, String
2587
- end
2588
- end
2589
-
2590
- constants.each do |data_type_klass|
2591
- data_type_klass = const_get(data_type_klass)
2592
- data_type_klass.load_members if defined? data_type_klass.load_members
2593
- end
2594
- end
2595
- end
2596
- end