paypal-sdk-rest 1.7.6 → 2.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +4 -14
  3. data/README.md +45 -255
  4. data/lib/lib.rb +88 -0
  5. data/lib/paypal/core/access_token.rb +20 -0
  6. data/lib/paypal/core/paypal_environment.rb +38 -0
  7. data/lib/paypal/core/paypal_http_client.rb +51 -0
  8. data/lib/paypal/core/token_requests.rb +40 -0
  9. data/lib/paypal/core/version.rb +3 -0
  10. data/lib/v1/billing_agreements/agreement_bill_balance_request.rb +35 -0
  11. data/lib/v1/billing_agreements/agreement_cancel_request.rb +35 -0
  12. data/lib/v1/billing_agreements/agreement_create_request.rb +33 -0
  13. data/lib/v1/billing_agreements/agreement_execute_request.rb +31 -0
  14. data/lib/v1/billing_agreements/agreement_get_request.rb +31 -0
  15. data/lib/v1/billing_agreements/agreement_re_activate_request.rb +35 -0
  16. data/lib/v1/billing_agreements/agreement_set_balance_request.rb +35 -0
  17. data/lib/v1/billing_agreements/agreement_suspend_request.rb +35 -0
  18. data/lib/v1/billing_agreements/agreement_transactions_request.rb +41 -0
  19. data/lib/v1/billing_agreements/agreement_update_request.rb +35 -0
  20. data/lib/v1/billing_plans/plan_create_request.rb +33 -0
  21. data/lib/v1/billing_plans/plan_get_request.rb +31 -0
  22. data/lib/v1/billing_plans/plan_list_request.rb +49 -0
  23. data/lib/v1/billing_plans/plan_update_request.rb +35 -0
  24. data/lib/v1/identity/user_consent.rb +45 -0
  25. data/lib/v1/identity/userinfo_get_request.rb +33 -0
  26. data/lib/v1/invoices/invoice_cancel_request.rb +35 -0
  27. data/lib/v1/invoices/invoice_create_request.rb +33 -0
  28. data/lib/v1/invoices/invoice_delete_external_payment_request.rb +33 -0
  29. data/lib/v1/invoices/invoice_delete_external_refund_request.rb +33 -0
  30. data/lib/v1/invoices/invoice_delete_request.rb +31 -0
  31. data/lib/v1/invoices/invoice_get_request.rb +31 -0
  32. data/lib/v1/invoices/invoice_list_request.rb +44 -0
  33. data/lib/v1/invoices/invoice_next_invoice_number_request.rb +29 -0
  34. data/lib/v1/invoices/invoice_qr_code_request.rb +46 -0
  35. data/lib/v1/invoices/invoice_record_payment_request.rb +35 -0
  36. data/lib/v1/invoices/invoice_record_refund_request.rb +35 -0
  37. data/lib/v1/invoices/invoice_remind_request.rb +35 -0
  38. data/lib/v1/invoices/invoice_search_request.rb +33 -0
  39. data/lib/v1/invoices/invoice_send_request.rb +36 -0
  40. data/lib/v1/invoices/invoice_update_request.rb +40 -0
  41. data/lib/v1/invoices/template_create_request.rb +33 -0
  42. data/lib/v1/invoices/template_delete_request.rb +31 -0
  43. data/lib/v1/invoices/template_get_request.rb +31 -0
  44. data/lib/v1/invoices/template_list_request.rb +34 -0
  45. data/lib/v1/invoices/template_update_request.rb +35 -0
  46. data/lib/v1/orders/orders_cancel_request.rb +31 -0
  47. data/lib/v1/orders/orders_create_request.rb +33 -0
  48. data/lib/v1/orders/orders_get_request.rb +31 -0
  49. data/lib/v1/orders/orders_pay_request.rb +35 -0
  50. data/lib/v1/payment_experience/web_profile_create_request.rb +33 -0
  51. data/lib/v1/payment_experience/web_profile_delete_request.rb +31 -0
  52. data/lib/v1/payment_experience/web_profile_get_request.rb +31 -0
  53. data/lib/v1/payment_experience/web_profile_list_request.rb +29 -0
  54. data/lib/v1/payment_experience/web_profile_partial_update_request.rb +35 -0
  55. data/lib/v1/payment_experience/web_profile_update_request.rb +35 -0
  56. data/lib/v1/payments/authorization_capture_request.rb +35 -0
  57. data/lib/v1/payments/authorization_get_request.rb +31 -0
  58. data/lib/v1/payments/authorization_reauthorize_request.rb +35 -0
  59. data/lib/v1/payments/authorization_void_request.rb +31 -0
  60. data/lib/v1/payments/capture_get_request.rb +31 -0
  61. data/lib/v1/payments/capture_refund_request.rb +35 -0
  62. data/lib/v1/payments/order_authorize_request.rb +35 -0
  63. data/lib/v1/payments/order_capture_request.rb +35 -0
  64. data/lib/v1/payments/order_get_request.rb +31 -0
  65. data/lib/v1/payments/order_void_request.rb +31 -0
  66. data/lib/v1/payments/payment_create_request.rb +33 -0
  67. data/lib/v1/payments/payment_execute_request.rb +35 -0
  68. data/lib/v1/payments/payment_get_request.rb +31 -0
  69. data/lib/v1/payments/payment_list_request.rb +69 -0
  70. data/lib/v1/payments/payment_update_request.rb +35 -0
  71. data/lib/v1/payments/refund_get_request.rb +31 -0
  72. data/lib/v1/payments/sale_get_request.rb +31 -0
  73. data/lib/v1/payments/sale_refund_request.rb +35 -0
  74. data/lib/v1/sync/search_get_request.rb +99 -0
  75. data/lib/v1/vault/credit_card_create_request.rb +33 -0
  76. data/lib/v1/vault/credit_card_delete_request.rb +31 -0
  77. data/lib/v1/vault/credit_card_get_request.rb +31 -0
  78. data/lib/v1/vault/credit_card_list_request.rb +79 -0
  79. data/lib/v1/vault/credit_card_update_request.rb +35 -0
  80. data/lib/v1/webhooks/available_event_type_list_request.rb +29 -0
  81. data/lib/v1/webhooks/event_get_request.rb +31 -0
  82. data/lib/v1/webhooks/event_list_request.rb +54 -0
  83. data/lib/v1/webhooks/event_resend_request.rb +35 -0
  84. data/lib/v1/webhooks/simulate_event_request.rb +33 -0
  85. data/lib/v1/webhooks/webhook_create_request.rb +33 -0
  86. data/lib/v1/webhooks/webhook_delete_request.rb +31 -0
  87. data/lib/v1/webhooks/webhook_get_request.rb +31 -0
  88. data/lib/v1/webhooks/webhook_list_event_subscriptions_request.rb +31 -0
  89. data/lib/v1/webhooks/webhook_list_request.rb +34 -0
  90. data/lib/v1/webhooks/webhook_update_request.rb +35 -0
  91. data/lib/v1/webhooks/webhook_verify_signature_request.rb +33 -0
  92. data/spec/integration/test_harness.rb +25 -0
  93. data/spec/integration/v1/billing_agreements/agreement_create_spec.rb +63 -0
  94. data/spec/integration/v1/billing_plans/plan_create_spec.rb +12 -0
  95. data/spec/integration/v1/billing_plans/plan_get_spec.rb +16 -0
  96. data/spec/integration/v1/billing_plans/plan_helper.rb +71 -0
  97. data/spec/integration/v1/billing_plans/plan_list_spec.rb +16 -0
  98. data/spec/integration/v1/billing_plans/plan_update_spec.rb +19 -0
  99. data/spec/integration/v1/identity/userinfo_get_spec.rb +65 -0
  100. data/spec/integration/v1/invoices/invoice_cancel_spec.rb +23 -0
  101. data/spec/integration/v1/invoices/invoice_create_spec.rb +15 -0
  102. data/spec/integration/v1/invoices/invoice_delete_external_payment_spec.rb +23 -0
  103. data/spec/integration/v1/invoices/invoice_delete_external_refund_spec.rb +21 -0
  104. data/spec/integration/v1/invoices/invoice_delete_spec.rb +16 -0
  105. data/spec/integration/v1/invoices/invoice_get_spec.rb +18 -0
  106. data/spec/integration/v1/invoices/invoice_helper.rb +171 -0
  107. data/spec/integration/v1/invoices/invoice_list_spec.rb +20 -0
  108. data/spec/integration/v1/invoices/invoice_next_invoice_number_spec.rb +14 -0
  109. data/spec/integration/v1/invoices/invoice_qr_code_spec.rb +18 -0
  110. data/spec/integration/v1/invoices/invoice_record_payment_spec.rb +14 -0
  111. data/spec/integration/v1/invoices/invoice_record_refund_spec.rb +14 -0
  112. data/spec/integration/v1/invoices/invoice_remind_spec.rb +22 -0
  113. data/spec/integration/v1/invoices/invoice_search_spec.rb +20 -0
  114. data/spec/integration/v1/invoices/invoice_send_spec.rb +15 -0
  115. data/spec/integration/v1/invoices/invoice_update_spec.rb +26 -0
  116. data/spec/integration/v1/invoices/template_create_spec.rb +14 -0
  117. data/spec/integration/v1/invoices/template_delete_spec.rb +15 -0
  118. data/spec/integration/v1/invoices/template_get_spec.rb +18 -0
  119. data/spec/integration/v1/invoices/template_list_spec.rb +15 -0
  120. data/spec/integration/v1/invoices/template_update_spec.rb +62 -0
  121. data/spec/integration/v1/orders/orders_cancel_spec.rb +15 -0
  122. data/spec/integration/v1/orders/orders_create_spec.rb +17 -0
  123. data/spec/integration/v1/orders/orders_get_spec.rb +18 -0
  124. data/spec/integration/v1/orders/orders_helper.rb +36 -0
  125. data/spec/integration/v1/orders/orders_pay_spec.rb +19 -0
  126. data/spec/integration/v1/payment_experience/pe_helper.rb +35 -0
  127. data/spec/integration/v1/payment_experience/web_profile_create_spec.rb +20 -0
  128. data/spec/integration/v1/payment_experience/web_profile_delete_spec.rb +15 -0
  129. data/spec/integration/v1/payment_experience/web_profile_get_spec.rb +17 -0
  130. data/spec/integration/v1/payment_experience/web_profile_list_spec.rb +18 -0
  131. data/spec/integration/v1/payment_experience/web_profile_partial_update_spec.rb +32 -0
  132. data/spec/integration/v1/payment_experience/web_profile_update_spec.rb +44 -0
  133. data/spec/integration/v1/payments/authorization_capture_spec.rb +17 -0
  134. data/spec/integration/v1/payments/authorization_get_spec.rb +18 -0
  135. data/spec/integration/v1/payments/authorization_reauthorize_spec.rb +26 -0
  136. data/spec/integration/v1/payments/authorization_void_spec.rb +19 -0
  137. data/spec/integration/v1/payments/capture_get_spec.rb +20 -0
  138. data/spec/integration/v1/payments/capture_refund_spec.rb +27 -0
  139. data/spec/integration/v1/payments/order_authorize_spec.rb +20 -0
  140. data/spec/integration/v1/payments/order_capture_spec.rb +21 -0
  141. data/spec/integration/v1/payments/order_get_spec.rb +14 -0
  142. data/spec/integration/v1/payments/order_void_spec.rb +14 -0
  143. data/spec/integration/v1/payments/payment_create_spec.rb +13 -0
  144. data/spec/integration/v1/payments/payment_execute_spec.rb +19 -0
  145. data/spec/integration/v1/payments/payment_get_spec.rb +17 -0
  146. data/spec/integration/v1/payments/payment_list_spec.rb +16 -0
  147. data/spec/integration/v1/payments/payment_update_spec.rb +28 -0
  148. data/spec/integration/v1/payments/payments_helper.rb +72 -0
  149. data/spec/integration/v1/payments/refund_get_spec.rb +19 -0
  150. data/spec/integration/v1/payments/sale_get_spec.rb +18 -0
  151. data/spec/integration/v1/payments/sale_refund_spec.rb +18 -0
  152. data/spec/integration/v1/sync/search_get_spec.rb +34 -0
  153. data/spec/integration/v1/vault/credit_card_create_spec.rb +16 -0
  154. data/spec/integration/v1/vault/credit_card_delete_spec.rb +16 -0
  155. data/spec/integration/v1/vault/credit_card_get_spec.rb +17 -0
  156. data/spec/integration/v1/vault/credit_card_list_spec.rb +18 -0
  157. data/spec/integration/v1/vault/credit_card_update_spec.rb +26 -0
  158. data/spec/integration/v1/vault/vault_helper.rb +28 -0
  159. data/spec/integration/v1/webhooks/available_event_type_list_spec.rb +16 -0
  160. data/spec/integration/v1/webhooks/webhook_create_spec.rb +12 -0
  161. data/spec/integration/v1/webhooks/webhook_delete_spec.rb +13 -0
  162. data/spec/integration/v1/webhooks/webhook_get_spec.rb +16 -0
  163. data/spec/integration/v1/webhooks/webhook_helper.rb +43 -0
  164. data/spec/integration/v1/webhooks/webhook_list_event_subscriptions_spec.rb +16 -0
  165. data/spec/integration/v1/webhooks/webhook_list_spec.rb +15 -0
  166. data/spec/integration/v1/webhooks/webhook_update_spec.rb +29 -0
  167. data/spec/integration/v1/webhooks/webhook_verify_signature_spec.rb +20 -0
  168. data/spec/spec_helper.rb +97 -28
  169. data/spec/unit/paypal_http_client_spec.rb +264 -0
  170. metadata +257 -127
  171. data/Rakefile +0 -15
  172. data/data/DigiCertHighAssuranceEVRootCA.pem +0 -23
  173. data/data/DigiCertSHA2ExtendedValidationServerCA.pem +0 -28
  174. data/data/paypal.crt +0 -171
  175. data/lib/generators/paypal/sdk/USAGE +0 -3
  176. data/lib/generators/paypal/sdk/install_generator.rb +0 -17
  177. data/lib/generators/paypal/sdk/templates/paypal.rb +0 -2
  178. data/lib/generators/paypal/sdk/templates/paypal.yml +0 -29
  179. data/lib/paypal-sdk/core/api/base.rb +0 -169
  180. data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +0 -44
  181. data/lib/paypal-sdk/core/api/data_types/base.rb +0 -225
  182. data/lib/paypal-sdk/core/api/data_types/enum.rb +0 -26
  183. data/lib/paypal-sdk/core/api/data_types/simple_types.rb +0 -52
  184. data/lib/paypal-sdk/core/api/ipn.rb +0 -66
  185. data/lib/paypal-sdk/core/api/rest.rb +0 -177
  186. data/lib/paypal-sdk/core/api.rb +0 -20
  187. data/lib/paypal-sdk/core/authentication.rb +0 -66
  188. data/lib/paypal-sdk/core/config.rb +0 -253
  189. data/lib/paypal-sdk/core/credential/base.rb +0 -27
  190. data/lib/paypal-sdk/core/credential/certificate.rb +0 -32
  191. data/lib/paypal-sdk/core/credential/signature.rb +0 -22
  192. data/lib/paypal-sdk/core/credential/third_party/subject.rb +0 -25
  193. data/lib/paypal-sdk/core/credential/third_party/token.rb +0 -39
  194. data/lib/paypal-sdk/core/credential.rb +0 -16
  195. data/lib/paypal-sdk/core/exceptions.rb +0 -112
  196. data/lib/paypal-sdk/core/logging.rb +0 -50
  197. data/lib/paypal-sdk/core/openid_connect/api.rb +0 -50
  198. data/lib/paypal-sdk/core/openid_connect/data_types.rb +0 -73
  199. data/lib/paypal-sdk/core/openid_connect/get_api.rb +0 -28
  200. data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +0 -52
  201. data/lib/paypal-sdk/core/openid_connect/set_api.rb +0 -36
  202. data/lib/paypal-sdk/core/openid_connect.rb +0 -140
  203. data/lib/paypal-sdk/core/util/http_helper.rb +0 -171
  204. data/lib/paypal-sdk/core/util/oauth_signature.rb +0 -64
  205. data/lib/paypal-sdk/core/util/ordered_hash.rb +0 -165
  206. data/lib/paypal-sdk/core/util.rb +0 -11
  207. data/lib/paypal-sdk/rest/api.rb +0 -23
  208. data/lib/paypal-sdk/rest/data_types.rb +0 -2597
  209. data/lib/paypal-sdk/rest/error_hash.rb +0 -39
  210. data/lib/paypal-sdk/rest/get_api.rb +0 -20
  211. data/lib/paypal-sdk/rest/request_data_type.rb +0 -53
  212. data/lib/paypal-sdk/rest/set_api.rb +0 -42
  213. data/lib/paypal-sdk/rest/version.rb +0 -7
  214. data/lib/paypal-sdk/rest.rb +0 -39
  215. data/lib/paypal-sdk-core.rb +0 -38
  216. data/lib/paypal-sdk-rest.rb +0 -2
  217. data/spec/README.md +0 -22
  218. data/spec/config/cacert.pem +0 -171
  219. data/spec/config/cert_key.pem +0 -33
  220. data/spec/config/paypal.yml +0 -35
  221. data/spec/config/sample_data.yml +0 -3
  222. data/spec/core/api/data_type_spec.rb +0 -289
  223. data/spec/core/api/rest_spec.rb +0 -211
  224. data/spec/core/config_spec.rb +0 -192
  225. data/spec/core/logging_spec.rb +0 -28
  226. data/spec/core/openid_connect_spec.rb +0 -153
  227. data/spec/invoice_examples_spec.rb +0 -38
  228. data/spec/payments_examples_spec.rb +0 -437
  229. data/spec/payouts_examples_spec.rb +0 -74
  230. data/spec/rest/data_types_spec.rb +0 -62
  231. data/spec/rest/error_hash_spec.rb +0 -83
  232. data/spec/subscription_examples_spec.rb +0 -227
  233. data/spec/support/sample_data.rb +0 -5
  234. data/spec/web_profile_examples_spec.rb +0 -106
  235. data/spec/webhooks_examples_spec.rb +0 -93
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
- require 'stringio'
3
-
4
- describe PayPal::SDK::Core::Logging do
5
- Logging = PayPal::SDK::Core::Logging
6
-
7
- class TestLogging
8
- include Logging
9
- end
10
-
11
- before :each do
12
- @logger_file = StringIO.new
13
- Logging.logger = Logger.new(@logger_file)
14
- @test_logging = TestLogging.new
15
- end
16
-
17
- it "get logger object" do
18
- expect(@test_logging.logger).to be_a Logger
19
- end
20
-
21
- it "write message to logger" do
22
- test_message = "Example log message!!!"
23
- @test_logging.logger.info(test_message)
24
- @logger_file.rewind
25
- expect(@logger_file.read).to match test_message
26
- end
27
-
28
- end
@@ -1,153 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PayPal::SDK::OpenIDConnect do
4
- OpenIDConnect = PayPal::SDK::OpenIDConnect
5
-
6
- before :all do
7
- OpenIDConnect.set_config( :client_id => "client_id", :openid_redirect_uri => "http://google.com" )
8
- end
9
-
10
- it "Validate user_agent" do
11
- expect(OpenIDConnect::API.user_agent).to match "PayPalSDK/openid-connect-ruby"
12
- end
13
-
14
- describe "generate_authorize_url" do
15
-
16
- it "generate autorize_url" do
17
- url = OpenIDConnect::Tokeninfo.authorize_url
18
- expect(url).to match "client_id=client_id"
19
- expect(url).to match Regexp.escape("redirect_uri=#{CGI.escape("http://google.com")}")
20
- expect(url).to match "scope=openid"
21
- end
22
-
23
- describe "sandbox" do
24
- before do
25
- PayPal::SDK.configure(:mode => "sandbox")
26
- end
27
-
28
- it "generates a sandbox authorize url" do
29
- url = OpenIDConnect::Tokeninfo.authorize_url
30
- expect(url).to match "sandbox.paypal.com"
31
- end
32
- end
33
- end
34
-
35
- it "Override authorize_url params" do
36
- url = OpenIDConnect.authorize_url(
37
- :client_id => "new_client_id",
38
- :redirect_uri => "http://example.com",
39
- :scope => "openid profile")
40
- expect(url).to match "client_id=new_client_id"
41
- expect(url).to match Regexp.escape("redirect_uri=#{CGI.escape("http://example.com")}")
42
- expect(url).to match Regexp.escape("scope=#{CGI.escape("openid profile")}")
43
- end
44
-
45
- it "Generate logout_url" do
46
- url = OpenIDConnect.logout_url
47
- expect(url).to match "logout=true"
48
- expect(url).to match Regexp.escape("redirect_uri=#{CGI.escape("http://google.com")}")
49
- expect(url).not_to match "id_token"
50
- end
51
-
52
- it "Override logout_url params" do
53
- url = OpenIDConnect.logout_url({
54
- :redirect_uri => "http://example.com",
55
- :id_token => "testing" })
56
- expect(url).to match Regexp.escape("redirect_uri=#{CGI.escape("http://example.com")}")
57
- expect(url).to match "id_token=testing"
58
- end
59
-
60
- describe "Validation" do
61
- it "Create token" do
62
- expect{
63
- tokeninfo = OpenIDConnect::Tokeninfo.create("invalid-autorize-code")
64
- }.to raise_error PayPal::SDK::Core::Exceptions::BadRequest
65
- end
66
-
67
- it "Refresh token" do
68
- expect{
69
- tokeninfo = OpenIDConnect::Tokeninfo.refresh("invalid-refresh-token")
70
- }.to raise_error PayPal::SDK::Core::Exceptions::BadRequest
71
- end
72
-
73
- it "Get userinfo" do
74
- expect{
75
- userinfo = OpenIDConnect::Userinfo.get("invalid-access-token")
76
- }.to raise_error PayPal::SDK::Core::Exceptions::UnauthorizedAccess
77
- end
78
- end
79
-
80
- describe "Tokeninfo" do
81
- before do
82
- @tokeninfo = OpenIDConnect::Tokeninfo.new( :access_token => "test_access_token",
83
- :refresh_token => "test_refresh_token",
84
- :id_token => "test_id_token" )
85
- end
86
-
87
- it "create" do
88
- allow(OpenIDConnect::Tokeninfo.api).to receive_messages( :post => { :access_token => "access_token" } )
89
- tokeninfo = OpenIDConnect::Tokeninfo.create("authorize_code")
90
- expect(tokeninfo).to be_a OpenIDConnect::Tokeninfo
91
- expect(tokeninfo.access_token).to eql "access_token"
92
- end
93
-
94
- it "refresh" do
95
- allow(@tokeninfo.api).to receive_messages( :post => { :access_token => "new_access_token" } )
96
- expect(@tokeninfo.access_token).to eql "test_access_token"
97
- @tokeninfo.refresh
98
- expect(@tokeninfo.access_token).to eql "new_access_token"
99
- end
100
-
101
- it "userinfo" do
102
- allow(@tokeninfo.api).to receive_messages( :post => { :name => "Testing" } )
103
- userinfo = @tokeninfo.userinfo
104
- expect(userinfo).to be_a OpenIDConnect::Userinfo
105
- expect(userinfo.name).to eql "Testing"
106
- end
107
-
108
- describe "logout_url" do
109
- it "Generate logout_url" do
110
- url = @tokeninfo.logout_url
111
- expect(url).to match "id_token=test_id_token"
112
- expect(url).to match "logout=true"
113
- expect(url).to match Regexp.escape("redirect_uri=#{CGI.escape("http://google.com")}")
114
- end
115
-
116
- describe "sandbox" do
117
- before do
118
- PayPal::SDK.configure(:mode => "sandbox")
119
- end
120
-
121
- it "generates a sandbox logout url" do
122
- url = @tokeninfo.logout_url
123
- expect(url).to match "sandbox.paypal.com"
124
- end
125
- end
126
- end
127
- end
128
-
129
- describe "Userinfo" do
130
- it "get" do
131
- allow(OpenIDConnect::Userinfo.api).to receive_messages( :post => { :name => "Testing" } )
132
-
133
- userinfo = OpenIDConnect::Userinfo.get("access_token")
134
- userinfo = OpenIDConnect::Userinfo.new( { :name => "Testing" } )
135
- expect(userinfo).to be_a OpenIDConnect::Userinfo
136
- expect(userinfo.name).to eql "Testing"
137
-
138
- userinfo = OpenIDConnect::Userinfo.get( :access_token => "access_token" )
139
- expect(userinfo).to be_a OpenIDConnect::Userinfo
140
- expect(userinfo.name).to eql "Testing"
141
- end
142
-
143
- it "get", :integration => true do
144
- api = PayPal::SDK::REST::API.new
145
- access_token = api.token_hash()
146
- userinfo = OpenIDConnect::Userinfo.get( access_token )
147
- expect(userinfo).to be_a OpenIDConnect::Userinfo
148
- expect(userinfo.email).to eql "jaypatel512-facilitator@hotmail.com"
149
- end
150
- end
151
-
152
-
153
- end
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Invoice", :integration => true do
4
-
5
- InvoiceAttributes = {
6
- "merchant_info" => {
7
- "email" => "jaypatel512-facilitator@hotmail.com"
8
- },
9
- "billing_info" => [ { "email" => "example@example.com" } ],
10
- "items" => [
11
- {
12
- "name" => "Sutures",
13
- "quantity" => 100,
14
- "unit_price" => {
15
- "currency" => "USD",
16
- "value" => 5
17
- }
18
- }
19
- ],
20
- "note" => "Medical Invoice 16 Jul, 2013 PST"
21
- }
22
-
23
- it "create invoice" do
24
- invoice = PayPal::SDK::REST::Invoice.new(InvoiceAttributes)
25
- expect(invoice.create).to be_truthy
26
- end
27
-
28
- it "list invoice" do
29
- history = PayPal::SDK::REST::Invoice.get_all( :total_count_required =>true )
30
- expect(history.total_count).not_to be_nil
31
- end
32
-
33
- it "get invoice" do
34
- invoice = PayPal::SDK::REST::Invoice.find("INV2-6KYE-67GV-8AJR-SAER")
35
- expect(invoice).to be_a PayPal::SDK::REST::Invoice
36
- expect(invoice.id).to eql "INV2-6KYE-67GV-8AJR-SAER"
37
- end
38
- end
@@ -1,437 +0,0 @@
1
- require 'spec_helper'
2
- require 'json'
3
- require 'webmock/rspec'
4
-
5
- describe "Payments" do
6
-
7
- PaymentAttributes = {
8
- "intent" => "sale",
9
- "payer" => {
10
- "payment_method" => "credit_card",
11
- "funding_instruments" => [ {
12
- "credit_card" => {
13
- "type" => "visa",
14
- "number" => "4567516310777851",
15
- "expire_month" => "11", "expire_year" => "2018",
16
- "cvv2" => "874",
17
- "first_name" => "Joe", "last_name" => "Shopper",
18
- "billing_address" => {
19
- "line1" => "52 N Main ST",
20
- "city" => "Johnstown",
21
- "state" => "OH",
22
- "postal_code" => "43210", "country_code" => "US" } } } ] },
23
- "transactions" => [ {
24
- "amount" => {
25
- "total" => "1.00",
26
- "currency" => "USD" },
27
- "description" => "This is the payment transaction description." } ] }
28
-
29
- PaymentAttributesPayPal = {
30
- "intent" => "sale",
31
- "payer" => {
32
- "payment_method" => "paypal"
33
- },
34
- "redirect_urls" => {
35
- "return_url" => 'https://localhost/return',
36
- "cancel_url" => 'https://localhost/cancel',
37
- },
38
- "transactions" => [ {
39
- "amount" => {
40
- "total" => "1.00",
41
- "currency" => "USD" },
42
- "description" => "This is the payment transaction description." } ] }
43
-
44
- FuturePaymentAttributes = {
45
- "intent" => "authorize",
46
- "payer" => {
47
- "payment_method" => "paypal" },
48
- "transactions" => [ {
49
- "amount" => {
50
- "total" => "1.00",
51
- "currency" => "USD" },
52
- "description" => "This is the payment transaction description." } ] }
53
-
54
- ProcessorErrorResponse = {
55
- "name" => "INSTRUMENT_DECLINED",
56
- "message" => "The instrument presented was either declined by the processor or bank, or it can't be used for this payment.",
57
- "information_link" => "https://developer.paypal.com/docs/api/#INSTRUMENT_DECLINED",
58
- "debug_id" => "20dcd4f71107c",
59
- "another_thing" => {
60
- "avs_code" => "Y",
61
- "cvv_code" => "N",
62
- "response_code" => "0051"
63
- }
64
- }
65
-
66
- it "Validate user-agent", :unit => true do
67
- expect(PayPal::SDK::REST::API.user_agent).to match "PayPalSDK/PayPal-Ruby-SDK"
68
- end
69
-
70
- describe "Examples" do
71
- describe "REST", :unit => true do
72
- it "Modifiy global configuration" do
73
- backup_config = PayPal::SDK::REST.api.config
74
- PayPal::SDK::REST.set_config( :client_id => "XYZ" )
75
- expect(PayPal::SDK::REST.api.config.client_id).to eql "XYZ"
76
- PayPal::SDK::REST.set_config(backup_config)
77
- expect(PayPal::SDK::REST.api.config.client_id).not_to eql "XYZ"
78
- end
79
-
80
- it "Create - does not return true when error not provided in response" do
81
- oauth_response = {
82
- :scope => "https://uri.paypal.com/services/subscriptions https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://uri.paypal.com/services/applications/webhooks openid https://uri.paypal.com/payments/payouts https://api.paypal.com/v1/vault/credit-card/.*",
83
- :nonce => "2016-10-04T18:00:00ZP3PcGAv5XAncoc8Zt4MF5cRLlaEBW3OAoLEhMIFk--g",
84
- :access_token => "A101.tp_sF5GHqWnnqEQA13Ua5ABnIhRWgd-G9LhRnJdgOvJHc_L08zlfD9WgPF4I3kre.mShauuOGxWyw8ikViItmxkWmX78",
85
- :token_type => "Bearer",
86
- :app_id => "APP-80W284485P519543T",
87
- :expires_in => 30695
88
- }
89
-
90
- response_headers = {
91
- "date" => ["Fri, 09 Sep 2016 17:44:23 GMT"],
92
- "server" => ["Apache"],
93
- "proxy_server_info" => ["host=dcg12javapapi8768.dcg12.slc.paypalinc.com;threadId=1177"],
94
- "paypal-debug-id" => ["20dcd4f71107c", "20dcd4f71107c"],
95
- "correlation-id" => ["20dcd4f71107c"],
96
- "content-language" => ["*"],
97
- "connection" => ["close", "close"],
98
- "set-cookie" => ["X-PP-SILOVER=name%3DLIVE3.API.1%26silo_version%3D880%26app%3Dplatformapiserv%26TIME%3D4160016983%26HTTP_X_PP_AZ_LOCATOR%3Ddcg12.slc; Expires=Fri, 09 Sep 2016 18:14:25 GMT; domain=.paypal.com; path=/; Secure; HttpOnly", "X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT"],
99
- "vary" => ["Authorization"],
100
- "content-length" => ["335"],
101
- "content-type"=>["application/json"]
102
- }
103
-
104
- stub_request(:post, "https://api.sandbox.paypal.com/v1/oauth2/token")
105
- .to_return(:body => oauth_response.to_json)
106
-
107
- stub_request(:post, "https://api.sandbox.paypal.com/v1/payments/payment")
108
- .to_return(:body => ProcessorErrorResponse.to_json, :status => 400, :headers => response_headers)
109
-
110
- payment = Payment.new(PaymentAttributes)
111
- expect(payment.create).to be_falsey
112
- end
113
- end
114
-
115
- describe "Payment", :integration => true do
116
- it "Create" do
117
- payment = Payment.new(PaymentAttributes)
118
- # Create
119
- payment.create
120
- expect(payment.error).to be_nil
121
- expect(payment.id).not_to be_nil
122
- expect(payment.approval_url).to be_nil
123
- expect(payment.token).to be_nil
124
- end
125
-
126
- it "Create with request_id" do
127
- payment = Payment.new(PaymentAttributes)
128
- payment.create
129
- expect(payment.error).to be_nil
130
-
131
- request_id = payment.request_id
132
-
133
- new_payment = Payment.new(PaymentAttributes.merge( :request_id => request_id ))
134
- new_payment.create
135
- expect(new_payment.error).to be_nil
136
-
137
- expect(payment.id).to eql new_payment.id
138
- end
139
-
140
- it "Create with token" do
141
- api = API.new
142
- payment = Payment.new(PaymentAttributes.merge( :token => api.token ))
143
- expect(Payment.api).not_to eql payment.api
144
- payment.create
145
- expect(payment.error).to be_nil
146
- expect(payment.id).not_to be_nil
147
- end
148
-
149
- it "Create with client_id and client_secret" do
150
- api = API.new
151
- payment = Payment.new(PaymentAttributes.merge( :client_id => api.config.client_id, :client_secret => api.config.client_secret))
152
- expect(Payment.api).not_to eql payment.api
153
- payment.create
154
- expect(payment.error).to be_nil
155
- expect(payment.id).not_to be_nil
156
- end
157
-
158
- it "Create with redirect urls" do
159
- payment = Payment.new(PaymentAttributesPayPal)
160
- # Create
161
- payment.create
162
- expect(payment.error).to be_nil
163
- expect(payment.id).not_to be_nil
164
- expect(payment.approval_url).to include('webscr?cmd=_express-checkout')
165
- expect(payment.approval_url).not_to include('useraction=commit')
166
- expect(payment.approval_url(true)).to eq payment.approval_url + '&useraction=commit'
167
- expect(payment.token).to match /^EC-[A-Z0-9]+$/
168
- end
169
-
170
- it "List" do
171
- payment_history = Payment.all( "count" => 5 )
172
- expect(payment_history.error).to be_nil
173
- expect(payment_history.count).to eql 5
174
- end
175
-
176
- it "Find" do
177
- payment_history = Payment.all( "count" => 1 )
178
- payment = Payment.find(payment_history.payments[0].id)
179
- expect(payment.error).to be_nil
180
- end
181
-
182
- describe "Validation", :integration => true do
183
-
184
- it "Create with empty values" do
185
- payment = Payment.new
186
- expect(payment.create).to be_falsey
187
- end
188
-
189
- it "Find with invalid ID" do
190
- expect {
191
- payment = Payment.find("Invalid")
192
- }.to raise_error PayPal::SDK::Core::Exceptions::ResourceNotFound
193
- end
194
-
195
- it "Find with nil" do
196
- expect{
197
- payment = Payment.find(nil)
198
- }.to raise_error ArgumentError
199
- end
200
-
201
- it "Find with empty string" do
202
- expect{
203
- payment = Payment.find("")
204
- }.to raise_error ArgumentError
205
- end
206
-
207
- it "Find record with expired token" do
208
- expect {
209
- Payment.api.token
210
- Payment.api.token.sub!(/^/, "Expired")
211
- Payment.all(:count => 1)
212
- }.not_to raise_error
213
- end
214
- end
215
-
216
- # describe "instance method" do
217
-
218
- # it "Execute" do
219
- # pending "Test with capybara"
220
- # end
221
- # end
222
-
223
- end
224
-
225
- describe "Future Payment", :disabled => true do
226
- access_token = nil
227
-
228
- it "Exchange Authorization Code for Refresh / Access Tokens" do
229
-
230
- # put your authorization code for testing here
231
- auth_code = ''
232
-
233
- if auth_code != ''
234
- tokeninfo = FuturePayment.exch_token(auth_code)
235
- expect(tokeninfo.access_token).not_to be_nil
236
- expect(tokeninfo.refresh_token).not_to be_nil
237
- end
238
- end
239
-
240
- it "Create a payment" do
241
- # put your PAYPAL-CLIENT-METADATA-ID
242
- correlation_id = ''
243
- @future_payment = FuturePayment.new(FuturePaymentAttributes.merge( :token => access_token ))
244
- @future_payment.create(correlation_id)
245
- expect(@future_payment.error).to be_nil
246
- expect(@future_payment.id).not_to be_nil
247
- end
248
-
249
- end
250
-
251
- describe "Sale", :integration => true do
252
- before :each do
253
- @payment = Payment.new(PaymentAttributes)
254
- @payment.create
255
- expect(@payment).to be_success
256
- end
257
-
258
- it "Find" do
259
- sale = Sale.find(@payment.transactions[0].related_resources[0].sale.id)
260
- expect(sale.error).to be_nil
261
- expect(sale).to be_a Sale
262
- end
263
-
264
- describe "instance method" do
265
- it "Refund" do
266
- sale = @payment.transactions[0].related_resources[0].sale
267
- refund = sale.refund( :amount => { :total => "1.00", :currency => "USD" } )
268
- expect(refund.error).to be_nil
269
-
270
- refund = Refund.find(refund.id)
271
- expect(refund.error).to be_nil
272
- expect(refund).to be_a Refund
273
- end
274
- end
275
- end
276
-
277
- describe "Order", :integration => true do
278
- it "Find" do
279
- order = Order.find("O-2HT09787H36911800")
280
- expect(order.error).to be_nil
281
- expect(order).to_not be_nil
282
- end
283
-
284
- # The following Order tests must be ignored when run in an automated environment because executing an order
285
- # will require approval via the executed payment's approval_url.
286
-
287
- before :each, :disabled => true do
288
- @payment = Payment.new(PaymentAttributes.merge( "intent" => "order" ))
289
- payer_id = "" # replace with the actual payer_id
290
- @payment.create
291
- @payment.execute( :payer_id => payer_id )
292
- expect(@payment.error).to be_nil
293
- end
294
-
295
- it "Authorize", :disabled => true do
296
- auth = order.authorize
297
- expect(auth.state).to eq("Pending")
298
- end
299
-
300
- it "Capture", :disabled => true do
301
- capture = Capture.new({
302
- "amount" => {
303
- "currency" => "USD",
304
- "total" => "1.00"
305
- },
306
- "is_final_capture" => true
307
- })
308
- order = order.capture(@capture)
309
- expect(order.state).to eq("completed")
310
- end
311
-
312
- it "Void", :disabled => true do
313
- order = order.void()
314
- expect(order.state).to eq("voided")
315
- end
316
-
317
- end
318
-
319
- describe "Authorize", :integration => true do
320
- before :each do
321
- @payment = Payment.new(PaymentAttributes.merge( "intent" => "authorize" ))
322
- @payment.create
323
- expect(@payment.error).to be_nil
324
- end
325
-
326
- it "Find" do
327
- authorize = Authorization.find(@payment.transactions[0].related_resources[0].authorization.id)
328
- expect(authorize.error).to be_nil
329
- expect(authorize).to be_a Authorization
330
- end
331
-
332
- it "Capture" do
333
- authorize = @payment.transactions[0].related_resources[0].authorization
334
- capture = authorize.capture({:amount => { :currency => "USD", :total => "1.00" } })
335
- expect(capture.error).to be_nil
336
- end
337
-
338
- it "Void" do
339
- authorize = @payment.transactions[0].related_resources[0].authorization
340
- authorize.void()
341
- expect(authorize.error).to be_nil
342
- end
343
-
344
- it "Reauthorization" do
345
- authorize = Authorization.find("7GH53639GA425732B");
346
- authorize.amount = { :currency => "USD", :total => "1.00" }
347
- authorize.reauthorize
348
- expect(authorize.error).not_to be_nil
349
- end
350
- end
351
-
352
- describe "Capture", :integration => true do
353
- before :each do
354
- @payment = Payment.new(PaymentAttributes.merge( "intent" => "authorize" ))
355
- @payment.create
356
- expect(@payment.error).to be_nil
357
- authorize = @payment.transactions[0].related_resources[0].authorization
358
- @capture = authorize.capture({:amount => { :currency => "USD", :total => "1.00" } })
359
- expect(@capture.error).to be_nil
360
- end
361
-
362
- it "Find" do
363
- capture = Capture.find(@capture.id)
364
- expect(capture.error).to be_nil
365
- expect(capture).to be_a Capture
366
- end
367
-
368
- it "Refund" do
369
- refund = @capture.refund({})
370
- expect(refund.error).to be_nil
371
- end
372
- end
373
-
374
- describe "CreditCard", :integration => true do
375
- it "Create" do
376
- credit_card = CreditCard.new({
377
- "type" => "visa",
378
- "number" => "4567516310777851",
379
- "expire_month" => "11", "expire_year" => "2018",
380
- "cvv2" => "874",
381
- "first_name" => "Joe", "last_name" => "Shopper",
382
- "billing_address" => {
383
- "line1" => "52 N Main ST",
384
- "city" => "Johnstown",
385
- "state" => "OH",
386
- "postal_code" => "43210", "country_code" => "US" }})
387
- credit_card.create
388
- expect(credit_card.error).to be_nil
389
- expect(credit_card.id).not_to be_nil
390
-
391
- credit_card = CreditCard.find(credit_card.id)
392
- expect(credit_card).to be_a CreditCard
393
- expect(credit_card.error).to be_nil
394
- end
395
-
396
- it "Delete" do
397
- credit_card = CreditCard.new({
398
- "type" => "visa",
399
- "number" => "4567516310777851",
400
- "expire_month" => "11", "expire_year" => "2018" })
401
- expect(credit_card.create).to be_truthy
402
- expect(credit_card.delete).to be_truthy
403
- end
404
-
405
- describe "Validation", :integration => true do
406
- it "Create" do
407
- credit_card = CreditCard.new({
408
- "type" => "visa",
409
- "number" => "4111111111111111" })
410
- credit_card.create
411
- expect(credit_card.error).not_to be_nil
412
-
413
- expect(credit_card.error.name).to eql "VALIDATION_ERROR"
414
- expect(credit_card.error["name"]).to eql "VALIDATION_ERROR"
415
-
416
- expect(credit_card.error.details[0].field).to eql "expire_year"
417
- expect(credit_card.error.details[0].issue).to eql "Required field missing"
418
- expect(credit_card.error.details[1].field).to eql "expire_month"
419
- expect(credit_card.error.details[1].issue).to eql "Required field missing"
420
-
421
- expect(credit_card.error["details"][0]["issue"]).to eql "Required field missing"
422
- end
423
- end
424
- end
425
-
426
- describe 'CreditCardList', :integration => true do
427
-
428
- it "List" do
429
- options = { :create_time => "2015-03-28T15:33:43Z" }
430
- credit_card_list = CreditCardList.list()
431
- expect(credit_card_list.total_items).to be > 0
432
- end
433
-
434
- end
435
-
436
- end
437
- end