paypal-sdk-rest-pmrb 1.8.0

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 (72) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +15 -0
  3. data/README.md +265 -0
  4. data/Rakefile +15 -0
  5. data/data/DigiCertHighAssuranceEVRootCA.pem +23 -0
  6. data/data/DigiCertSHA2ExtendedValidationServerCA.pem +28 -0
  7. data/data/paypal.crt +193 -0
  8. data/lib/generators/paypal/sdk/USAGE +3 -0
  9. data/lib/generators/paypal/sdk/install_generator.rb +17 -0
  10. data/lib/generators/paypal/sdk/templates/paypal.rb +2 -0
  11. data/lib/generators/paypal/sdk/templates/paypal.yml +29 -0
  12. data/lib/paypal-sdk-core.rb +38 -0
  13. data/lib/paypal-sdk-rest.rb +2 -0
  14. data/lib/paypal-sdk/core/api.rb +20 -0
  15. data/lib/paypal-sdk/core/api/base.rb +169 -0
  16. data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +44 -0
  17. data/lib/paypal-sdk/core/api/data_types/base.rb +225 -0
  18. data/lib/paypal-sdk/core/api/data_types/enum.rb +26 -0
  19. data/lib/paypal-sdk/core/api/data_types/simple_types.rb +52 -0
  20. data/lib/paypal-sdk/core/api/ipn.rb +66 -0
  21. data/lib/paypal-sdk/core/api/rest.rb +177 -0
  22. data/lib/paypal-sdk/core/authentication.rb +66 -0
  23. data/lib/paypal-sdk/core/config.rb +253 -0
  24. data/lib/paypal-sdk/core/credential.rb +16 -0
  25. data/lib/paypal-sdk/core/credential/base.rb +27 -0
  26. data/lib/paypal-sdk/core/credential/certificate.rb +32 -0
  27. data/lib/paypal-sdk/core/credential/signature.rb +22 -0
  28. data/lib/paypal-sdk/core/credential/third_party/subject.rb +25 -0
  29. data/lib/paypal-sdk/core/credential/third_party/token.rb +39 -0
  30. data/lib/paypal-sdk/core/exceptions.rb +112 -0
  31. data/lib/paypal-sdk/core/logging.rb +50 -0
  32. data/lib/paypal-sdk/core/openid_connect.rb +140 -0
  33. data/lib/paypal-sdk/core/openid_connect/api.rb +50 -0
  34. data/lib/paypal-sdk/core/openid_connect/data_types.rb +73 -0
  35. data/lib/paypal-sdk/core/openid_connect/get_api.rb +28 -0
  36. data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +52 -0
  37. data/lib/paypal-sdk/core/openid_connect/set_api.rb +36 -0
  38. data/lib/paypal-sdk/core/util.rb +11 -0
  39. data/lib/paypal-sdk/core/util/http_helper.rb +171 -0
  40. data/lib/paypal-sdk/core/util/oauth_signature.rb +64 -0
  41. data/lib/paypal-sdk/core/util/ordered_hash.rb +165 -0
  42. data/lib/paypal-sdk/rest.rb +39 -0
  43. data/lib/paypal-sdk/rest/api.rb +23 -0
  44. data/lib/paypal-sdk/rest/data_types.rb +2597 -0
  45. data/lib/paypal-sdk/rest/error_hash.rb +39 -0
  46. data/lib/paypal-sdk/rest/get_api.rb +20 -0
  47. data/lib/paypal-sdk/rest/request_data_type.rb +53 -0
  48. data/lib/paypal-sdk/rest/set_api.rb +42 -0
  49. data/lib/paypal-sdk/rest/version.rb +7 -0
  50. data/spec/README.md +22 -0
  51. data/spec/config/cacert.pem +171 -0
  52. data/spec/config/cert_key.pem +33 -0
  53. data/spec/config/paypal.yml +35 -0
  54. data/spec/config/sample_data.yml +3 -0
  55. data/spec/core/api/data_type_spec.rb +289 -0
  56. data/spec/core/api/rest_spec.rb +211 -0
  57. data/spec/core/config_spec.rb +192 -0
  58. data/spec/core/logging_spec.rb +28 -0
  59. data/spec/core/openid_connect_spec.rb +153 -0
  60. data/spec/invoice_examples_spec.rb +38 -0
  61. data/spec/log/http.log +175 -0
  62. data/spec/log/rest_http.log +0 -0
  63. data/spec/payments_examples_spec.rb +437 -0
  64. data/spec/payouts_examples_spec.rb +74 -0
  65. data/spec/rest/data_types_spec.rb +62 -0
  66. data/spec/rest/error_hash_spec.rb +83 -0
  67. data/spec/spec_helper.rb +37 -0
  68. data/spec/subscription_examples_spec.rb +227 -0
  69. data/spec/support/sample_data.rb +5 -0
  70. data/spec/web_profile_examples_spec.rb +106 -0
  71. data/spec/webhooks_examples_spec.rb +93 -0
  72. metadata +177 -0
@@ -0,0 +1,38 @@
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
@@ -0,0 +1,175 @@
1
+ opening connection to api.sandbox.paypal.com:443...
2
+ opened
3
+ starting SSL for api.sandbox.paypal.com:443...
4
+ SSL established
5
+ <- "POST /v1/catalogs/products HTTP/1.1\r\nX-Paypal-Sandbox-Email-Address: Platform.sdk.seller@gmail.com\r\nAuthorization: Bearer A21AAG8MoVno3Y9NQ2vroTmt44Cj6hQkReVae6MxBoBIK3C-0Unfc7GWR-hEDS1YkzC9mPb-g0AT0ZFz_57dbdlC5BYSpKMWA\r\nContent-Type: application/json\r\nUser-Agent: PayPalSDK/PayPal-Ruby-SDK 1.7.3 (paypal-sdk-core 1.7.3; ruby 2.5.1p57-x86_64-darwin16;OpenSSL 1.1.1 11 Sep 2018)\r\nPaypal-Request-Id: c110df92-a2e3-41e8-92a1-d61d60caea47\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nHost: api.sandbox.paypal.com\r\nContent-Length: 199\r\n\r\n"
6
+ <- "{\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"type\":\"SERVICE\",\"category\":\"SOFTWARE\",\"image_url\":\"https://example.com/streaming.jpg\",\"home_url\":\"https://example.com/home\"}"
7
+ -> "HTTP/1.1 201 Created\r\n"
8
+ -> "Date: Thu, 20 Jun 2019 14:08:35 GMT\r\n"
9
+ -> "Server: Apache\r\n"
10
+ -> "paypal-debug-id: 9225ea5cb8d9a\r\n"
11
+ -> "HTTP_X_PP_AZ_LOCATOR: sandbox.slc\r\n"
12
+ -> "Paypal-Debug-Id: 9225ea5cb8d9a\r\n"
13
+ -> "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1670581085%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Thu, 20 Jun 2019 14:38:35 GMT; domain=.paypal.com; path=/; Secure; HttpOnly\r\n"
14
+ -> "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n"
15
+ -> "Vary: Authorization\r\n"
16
+ -> "Content-Length: 381\r\n"
17
+ -> "Connection: close\r\n"
18
+ -> "Content-Type: application/json\r\n"
19
+ -> "\r\n"
20
+ reading 381 bytes...
21
+ -> "{\"id\":\"PROD-2TH454956H633411P\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"create_time\":\"2019-06-20T14:08:35Z\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2TH454956H633411P\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2TH454956H633411P\",\"rel\":\"edit\",\"method\":\"PATCH\"}]}"
22
+ read 381 bytes
23
+ Conn close
24
+ opening connection to api.sandbox.paypal.com:443...
25
+ opened
26
+ starting SSL for api.sandbox.paypal.com:443...
27
+ SSL established
28
+ <- "GET /v1/catalogs/products?page_size=99&total_required=true HTTP/1.1\r\nX-Paypal-Sandbox-Email-Address: Platform.sdk.seller@gmail.com\r\nAuthorization: Bearer A21AAG8MoVno3Y9NQ2vroTmt44Cj6hQkReVae6MxBoBIK3C-0Unfc7GWR-hEDS1YkzC9mPb-g0AT0ZFz_57dbdlC5BYSpKMWA\r\nContent-Type: application/json\r\nUser-Agent: PayPalSDK/PayPal-Ruby-SDK 1.7.3 (paypal-sdk-core 1.7.3; ruby 2.5.1p57-x86_64-darwin16;OpenSSL 1.1.1 11 Sep 2018)\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nHost: api.sandbox.paypal.com\r\n\r\n"
29
+ -> "HTTP/1.1 200 OK\r\n"
30
+ -> "Date: Thu, 20 Jun 2019 14:08:36 GMT\r\n"
31
+ -> "Server: Apache\r\n"
32
+ -> "paypal-debug-id: 4029769b40014\r\n"
33
+ -> "HTTP_X_PP_AZ_LOCATOR: sandbox.slc\r\n"
34
+ -> "Paypal-Debug-Id: 4029769b40014\r\n"
35
+ -> "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1687358301%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Thu, 20 Jun 2019 14:38:36 GMT; domain=.paypal.com; path=/; Secure; HttpOnly\r\n"
36
+ -> "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n"
37
+ -> "Vary: Authorization\r\n"
38
+ -> "Connection: close\r\n"
39
+ -> "Transfer-Encoding: chunked\r\n"
40
+ -> "Content-Type: application/json\r\n"
41
+ -> "\r\n"
42
+ -> "2000\r\n"
43
+ reading 8192 bytes...
44
+ -> ""
45
+ -> "{\"products\":[{\"id\":\"PROD-88P66116U8424713Y\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-88P66116U8424713Y\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-9HR25263MW049305R\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-9HR25263MW049305R\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-6N696826HG113224A\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-6N696826HG113224A\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-27M99624TE143843E\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-27M99624TE143843E\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-7RY89329KN7803222\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-7RY89329KN7803222\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-3KE343427A712191C\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-3KE343427A712191C\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-2RK5942798309264B\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2RK5942798309264B\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-8MX8812952166872B\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-8MX8812952166872B\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-4N2795536X5381140\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-4N2795536X5381140\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-4HW458221B2951531\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-4HW458221B2951531\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-4FN0679242198735T\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-4FN0679242198735T\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-9KH91817U6217692V\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-9KH91817U6217692V\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-4R285588KV4469238\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-4R285588KV4469238\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-3SP328368F401020A\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-3SP328368F401020A\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-5H899287EC102604X\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-5H899287EC102604X\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-1LL701415A885501N\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-1LL701415A885501N\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-1WK9470583999374J\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-1WK9470583999374J\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-03305783CL1520143\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-03305783CL1520143\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-27X1077636135754X\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-27X1077636135754X\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-1S707532XJ8460936\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-1S707532XJ8460936\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-26K19609M72274849\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-26K19609M72274849\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-7WR46934VF294752N\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-7WR46934VF294752N\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-2AD63024DP278321E\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2AD63024DP278321E\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-5D466893YC6738502\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-5D466893YC6738502\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-87J53413AC569925A\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-87J53413AC569925A\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-45K97299DY4079610\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-45K97299DY4079610\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-9EM270580D5144407\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-9EM270580D5144407\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-44X18262XM369262K\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-44X18262XM369262K\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-7HA77800KP103692P\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-7HA77800KP103692P\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-45347439SP9015829\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-45347439SP9015829\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-06N54517KT2707919\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-06N54517KT2707919\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-38U021592D6077444\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-38U021592D6077444\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-31R388081G1636052\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-31R388081G1636052\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-2YA54096D37972117\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2YA54096D37972117\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-8JP83890WK478815N\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-8JP83890WK478815N\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-7GM866379C284591N\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-7GM866379C284591N\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-17231329HM741940W\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-17231329HM741940W\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-1XS14307924998900\""
46
+ read 8192 bytes
47
+ reading 2 bytes...
48
+ -> ""
49
+ -> "\r\n"
50
+ read 2 bytes
51
+ -> "15f5\r\n"
52
+ reading 5621 bytes...
53
+ -> ""
54
+ -> ",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-1XS14307924998900\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-29S30004HB811152U\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-29S30004HB811152U\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-53271887CD151284K\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-53271887CD151284K\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-2KX55625S8611251V\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2KX55625S8611251V\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-6G654233NV063351W\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-6G654233NV063351W\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-7N229559MX8840154\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-7N229559MX8840154\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-5LY78944L0615893M\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-5LY78944L0615893M\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-93263879DU4052047\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-93263879DU4052047\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-00S71064VJ717570N\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-00S71064VJ717570N\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-3Y218025DC540635L\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-3Y218025DC540635L\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-2FY85319U1181950H\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2FY85319U1181950H\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-0FP590913B222104R\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-0FP590913B222104R\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-5AG62884JS725423D\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-5AG62884JS725423D\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-4R623883VM371433K\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-4R623883VM371433K\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-4F695312355081434\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-4F695312355081434\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-3CJ45351NR353464N\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-3CJ45351NR353464N\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-79799678UR6102740\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-79799678UR6102740\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-1HX815213L743425E\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-1HX815213L743425E\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-2PM25506D7287145L\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2PM25506D7287145L\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-5TH73023L52525018\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-5TH73023L52525018\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-0U762116706527633\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-0U762116706527633\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-6GV203945K987723H\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-6GV203945K987723H\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-4R917551KP670700L\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-4R917551KP670700L\",\"rel\":\"self\",\"method\":\"GET\"}]},{\"id\":\"PROD-2TH454956H633411P\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-2TH454956H633411P\",\"rel\":\"self\",\"method\":\"GET\"}]}],\"total_items\":61,\"total_pages\":1,\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=99&page=1\",\"rel\":\"self\",\"method\":\"GET\"}]}"
55
+ read 5621 bytes
56
+ reading 2 bytes...
57
+ -> ""
58
+ -> "\r\n"
59
+ read 2 bytes
60
+ -> "0\r\n"
61
+ -> "\r\n"
62
+ Conn close
63
+ opening connection to api.sandbox.paypal.com:443...
64
+ opened
65
+ starting SSL for api.sandbox.paypal.com:443...
66
+ SSL established
67
+ <- "GET /v1/catalogs/products?page_size=1&total_required=true HTTP/1.1\r\nX-Paypal-Sandbox-Email-Address: Platform.sdk.seller@gmail.com\r\nAuthorization: Bearer A21AAG8MoVno3Y9NQ2vroTmt44Cj6hQkReVae6MxBoBIK3C-0Unfc7GWR-hEDS1YkzC9mPb-g0AT0ZFz_57dbdlC5BYSpKMWA\r\nContent-Type: application/json\r\nUser-Agent: PayPalSDK/PayPal-Ruby-SDK 1.7.3 (paypal-sdk-core 1.7.3; ruby 2.5.1p57-x86_64-darwin16;OpenSSL 1.1.1 11 Sep 2018)\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nHost: api.sandbox.paypal.com\r\n\r\n"
68
+ -> "HTTP/1.1 200 OK\r\n"
69
+ -> "Date: Thu, 20 Jun 2019 14:08:36 GMT\r\n"
70
+ -> "Server: Apache\r\n"
71
+ -> "paypal-debug-id: 799c68c0d4382\r\n"
72
+ -> "HTTP_X_PP_AZ_LOCATOR: sandbox.slc\r\n"
73
+ -> "Paypal-Debug-Id: 799c68c0d4382\r\n"
74
+ -> "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1687358301%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Thu, 20 Jun 2019 14:38:36 GMT; domain=.paypal.com; path=/; Secure; HttpOnly\r\n"
75
+ -> "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n"
76
+ -> "Vary: Authorization\r\n"
77
+ -> "Content-Length: 606\r\n"
78
+ -> "Connection: close\r\n"
79
+ -> "Content-Type: application/json\r\n"
80
+ -> "\r\n"
81
+ reading 606 bytes...
82
+ -> "{\"products\":[{\"id\":\"PROD-88P66116U8424713Y\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-88P66116U8424713Y\",\"rel\":\"self\",\"method\":\"GET\"}]}],\"total_items\":61,\"total_pages\":61,\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=1\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=2\",\"rel\":\"next\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=61\",\"rel\":\"last\",\"method\":\"GET\"}]}"
83
+ read 606 bytes
84
+ Conn close
85
+ opening connection to api.sandbox.paypal.com:443...
86
+ opened
87
+ starting SSL for api.sandbox.paypal.com:443...
88
+ SSL established
89
+ <- "GET /v1/catalogs/products/?page_size=1&page=2 HTTP/1.1\r\nX-Paypal-Sandbox-Email-Address: Platform.sdk.seller@gmail.com\r\nAuthorization: Bearer A21AAG8MoVno3Y9NQ2vroTmt44Cj6hQkReVae6MxBoBIK3C-0Unfc7GWR-hEDS1YkzC9mPb-g0AT0ZFz_57dbdlC5BYSpKMWA\r\nContent-Type: application/json\r\nUser-Agent: PayPalSDK/PayPal-Ruby-SDK 1.7.3 (paypal-sdk-core 1.7.3; ruby 2.5.1p57-x86_64-darwin16;OpenSSL 1.1.1 11 Sep 2018)\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nHost: api.sandbox.paypal.com\r\n\r\n"
90
+ -> "HTTP/1.1 200 OK\r\n"
91
+ -> "Date: Thu, 20 Jun 2019 14:08:37 GMT\r\n"
92
+ -> "Server: Apache\r\n"
93
+ -> "paypal-debug-id: 1cc68fda5449c\r\n"
94
+ -> "HTTP_X_PP_AZ_LOCATOR: sandbox.slc\r\n"
95
+ -> "Paypal-Debug-Id: 1cc68fda5449c\r\n"
96
+ -> "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1704135517%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Thu, 20 Jun 2019 14:38:37 GMT; domain=.paypal.com; path=/; Secure; HttpOnly\r\n"
97
+ -> "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n"
98
+ -> "Vary: Authorization\r\n"
99
+ -> "Content-Length: 793\r\n"
100
+ -> "Connection: close\r\n"
101
+ -> "Content-Type: application/json\r\n"
102
+ -> "\r\n"
103
+ reading 793 bytes...
104
+ -> "{\"products\":[{\"id\":\"PROD-9HR25263MW049305R\",\"name\":\"My Cool Service\",\"description\":\"Service-Description\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-9HR25263MW049305R\",\"rel\":\"self\",\"method\":\"GET\"}]}],\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=2\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=1\",\"rel\":\"first\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=1\",\"rel\":\"prev\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=3\",\"rel\":\"next\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products?page_size=1&page=61\",\"rel\":\"last\",\"method\":\"GET\"}]}"
105
+ read 793 bytes
106
+ Conn close
107
+ opening connection to api.sandbox.paypal.com:443...
108
+ opened
109
+ starting SSL for api.sandbox.paypal.com:443...
110
+ SSL established
111
+ <- "POST /v1/catalogs/products HTTP/1.1\r\nX-Paypal-Sandbox-Email-Address: Platform.sdk.seller@gmail.com\r\nAuthorization: Bearer A21AAG8MoVno3Y9NQ2vroTmt44Cj6hQkReVae6MxBoBIK3C-0Unfc7GWR-hEDS1YkzC9mPb-g0AT0ZFz_57dbdlC5BYSpKMWA\r\nContent-Type: application/json\r\nUser-Agent: PayPalSDK/PayPal-Ruby-SDK 1.7.3 (paypal-sdk-core 1.7.3; ruby 2.5.1p57-x86_64-darwin16;OpenSSL 1.1.1 11 Sep 2018)\r\nPaypal-Request-Id: ea1f9f40-629a-4e24-8a83-00d9ca5c483a\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nHost: api.sandbox.paypal.com\r\nContent-Length: 199\r\n\r\n"
112
+ <- "{\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"type\":\"SERVICE\",\"category\":\"SOFTWARE\",\"image_url\":\"https://example.com/streaming.jpg\",\"home_url\":\"https://example.com/home\"}"
113
+ -> "HTTP/1.1 201 Created\r\n"
114
+ -> "Date: Thu, 20 Jun 2019 14:08:37 GMT\r\n"
115
+ -> "Server: Apache\r\n"
116
+ -> "paypal-debug-id: 14d36013dac11\r\n"
117
+ -> "HTTP_X_PP_AZ_LOCATOR: sandbox.slc\r\n"
118
+ -> "Paypal-Debug-Id: 14d36013dac11\r\n"
119
+ -> "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1704135517%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Thu, 20 Jun 2019 14:38:38 GMT; domain=.paypal.com; path=/; Secure; HttpOnly\r\n"
120
+ -> "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n"
121
+ -> "Vary: Authorization\r\n"
122
+ -> "Content-Length: 381\r\n"
123
+ -> "Connection: close\r\n"
124
+ -> "Content-Type: application/json\r\n"
125
+ -> "\r\n"
126
+ reading 381 bytes...
127
+ -> "{\"id\":\"PROD-9JL54131RW723273F\",\"name\":\"Video Streaming Service\",\"description\":\"Video streaming service\",\"create_time\":\"2019-06-20T14:08:38Z\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-9JL54131RW723273F\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/catalogs/products/PROD-9JL54131RW723273F\",\"rel\":\"edit\",\"method\":\"PATCH\"}]}"
128
+ read 381 bytes
129
+ Conn close
130
+ opening connection to api.sandbox.paypal.com:443...
131
+ opened
132
+ starting SSL for api.sandbox.paypal.com:443...
133
+ SSL established
134
+ <- "POST /v1/billing/plans/ HTTP/1.1\r\nX-Paypal-Sandbox-Email-Address: Platform.sdk.seller@gmail.com\r\nAuthorization: Bearer A21AAG8MoVno3Y9NQ2vroTmt44Cj6hQkReVae6MxBoBIK3C-0Unfc7GWR-hEDS1YkzC9mPb-g0AT0ZFz_57dbdlC5BYSpKMWA\r\nContent-Type: application/json\r\nUser-Agent: PayPalSDK/PayPal-Ruby-SDK 1.7.3 (paypal-sdk-core 1.7.3; ruby 2.5.1p57-x86_64-darwin16;OpenSSL 1.1.1 11 Sep 2018)\r\nPaypal-Request-Id: 2c389b8a-4fa9-4ff8-9e0b-ffd25ba1242a\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nHost: api.sandbox.paypal.com\r\nContent-Length: 621\r\n\r\n"
135
+ <- "{\"product_id\":\"PROD-9JL54131RW723273F\",\"name\":\"Basic Plan\",\"description\":\"Basic plan\",\"billing_cycles\":[{\"frequency\":{\"interval_unit\":\"MONTH\",\"interval_count\":1},\"tenure_type\":\"TRIAL\",\"sequence\":1,\"total_cycles\":1},{\"frequency\":{\"interval_unit\":\"MONTH\",\"interval_count\":1},\"tenure_type\":\"REGULAR\",\"sequence\":2,\"total_cycles\":12,\"pricing_scheme\":{\"fixed_price\":{\"currency_code\":\"USD\",\"value\":\"10\"}}}],\"payment_preferences\":{\"service_type\":\"PREPAID\",\"auto_bill_outstanding\":true,\"setup_fee\":{\"currency_code\":\"USD\",\"value\":\"10\"},\"setup_fee_failure_action\":\"CONTINUE\",\"payment_failure_threshold\":3},\"quantity_supported\":true}"
136
+ -> "HTTP/1.1 201 Created\r\n"
137
+ -> "Date: Thu, 20 Jun 2019 14:08:38 GMT\r\n"
138
+ -> "Server: Apache\r\n"
139
+ -> "paypal-debug-id: c4ce4c5c602fc\r\n"
140
+ -> "HTTP_X_PP_AZ_LOCATOR: sandbox.slc\r\n"
141
+ -> "Paypal-Debug-Id: c4ce4c5c602fc\r\n"
142
+ -> "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1720912733%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Thu, 20 Jun 2019 14:38:38 GMT; domain=.paypal.com; path=/; Secure; HttpOnly\r\n"
143
+ -> "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n"
144
+ -> "Vary: Authorization\r\n"
145
+ -> "Content-Length: 457\r\n"
146
+ -> "Connection: close\r\n"
147
+ -> "Content-Type: application/json\r\n"
148
+ -> "\r\n"
149
+ reading 457 bytes...
150
+ -> "{\"id\":\"P-0SF499894B180714ELUFZGZQ\",\"product_id\":\"PROD-9JL54131RW723273F\",\"status\":\"ACTIVE\",\"links\":[{\"href\":\"https://api.sandbox.paypal.com/v1/billing/plans/P-0SF499894B180714ELUFZGZQ\",\"rel\":\"self\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/billing/plans/P-0SF499894B180714ELUFZGZQ\",\"rel\":\"edit\",\"method\":\"PATCH\"},{\"href\":\"https://api.sandbox.paypal.com/v1/billing/plans/P-0SF499894B180714ELUFZGZQ/deactivate\",\"rel\":\"self\",\"method\":\"POST\"}]}"
151
+ read 457 bytes
152
+ Conn close
153
+ opening connection to api.sandbox.paypal.com:443...
154
+ opened
155
+ starting SSL for api.sandbox.paypal.com:443...
156
+ SSL established
157
+ <- "POST /v1/billing/subscriptions/ HTTP/1.1\r\nX-Paypal-Sandbox-Email-Address: Platform.sdk.seller@gmail.com\r\nAuthorization: Bearer A21AAG8MoVno3Y9NQ2vroTmt44Cj6hQkReVae6MxBoBIK3C-0Unfc7GWR-hEDS1YkzC9mPb-g0AT0ZFz_57dbdlC5BYSpKMWA\r\nContent-Type: application/json\r\nUser-Agent: PayPalSDK/PayPal-Ruby-SDK 1.7.3 (paypal-sdk-core 1.7.3; ruby 2.5.1p57-x86_64-darwin16;OpenSSL 1.1.1 11 Sep 2018)\r\nPaypal-Request-Id: 67140417-a458-41e5-9699-f506d94981c8\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nHost: api.sandbox.paypal.com\r\nContent-Length: 816\r\n\r\n"
158
+ <- "{\"plan_id\":\"P-0SF499894B180714ELUFZGZQ\",\"start_time\":\"2019-06-21T00:00:00+00:00\",\"quantity\":20,\"shipping_amount\":{\"currency_code\":\"USD\",\"value\":\"10.00\"},\"subscriber\":{\"name\":{\"given_name\":\"John\",\"surname\":\"Doe\"},\"email_address\":\"customer@example.com\",\"shipping_address\":{\"name\":{\"full_name\":\"John Doe\"},\"address\":{\"address_line_1\":\"2211 N First Street\",\"address_line_2\":\"Building 17\",\"admin_area_2\":\"San Jose\",\"admin_area_1\":\"CA\",\"postal_code\":\"95131\",\"country_code\":\"US\"}}},\"auto_renewal\":true,\"application_context\":{\"brand_name\":\"example\",\"locale\":\"en-US\",\"shipping_preference\":\"SET_PROVIDED_ADDRESS\",\"user_action\":\"SUBSCRIBE_NOW\",\"payment_method\":{\"payer_selected\":\"PAYPAL\",\"payee_preferred\":\"IMMEDIATE_PAYMENT_REQUIRED\"},\"return_url\":\"https://example.com/returnUrl\",\"cancel_url\":\"https://example.com/cancelUrl\"}}"
159
+ -> "HTTP/1.1 201 Created\r\n"
160
+ -> "Date: Thu, 20 Jun 2019 14:08:39 GMT\r\n"
161
+ -> "Server: Apache\r\n"
162
+ -> "paypal-debug-id: 3c63e360dd8\r\n"
163
+ -> "HTTP_X_PP_AZ_LOCATOR: sandbox.slc\r\n"
164
+ -> "Paypal-Debug-Id: 3c63e360dd8\r\n"
165
+ -> "Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dapiplatformproxyserv%26TIME%3D1737689949%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Thu, 20 Jun 2019 14:38:43 GMT; domain=.paypal.com; path=/; Secure; HttpOnly\r\n"
166
+ -> "Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT\r\n"
167
+ -> "Vary: Authorization\r\n"
168
+ -> "Content-Length: 453\r\n"
169
+ -> "Connection: close\r\n"
170
+ -> "Content-Type: application/json\r\n"
171
+ -> "\r\n"
172
+ reading 453 bytes...
173
+ -> "{\"status\":\"APPROVAL_PENDING\",\"id\":\"I-LHUEXTYXXBY4\",\"create_time\":\"2019-06-20T14:08:43Z\",\"links\":[{\"href\":\"https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=BA-8BF77932M4407092C\",\"rel\":\"approve\",\"method\":\"GET\"},{\"href\":\"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LHUEXTYXXBY4\",\"rel\":\"edit\",\"method\":\"PATCH\"},{\"href\":\"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-LHUEXTYXXBY4\",\"rel\":\"self\",\"method\":\"GET\"}]}"
174
+ read 453 bytes
175
+ Conn close
File without changes
@@ -0,0 +1,437 @@
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