solidus_paypal_commerce_platform 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
 - data/.circleci/config.yml +4 -0
 - data/.rubocop.yml +4 -4
 - data/CHANGELOG.md +46 -2
 - data/Gemfile +2 -2
 - data/LICENSE +1 -1
 - data/README.md +25 -0
 - data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +3 -1
 - data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js +14 -0
 - data/app/controllers/solidus_paypal_commerce_platform/payments_controller.rb +4 -2
 - data/app/helpers/solidus_paypal_commerce_platform/button_options_helper.rb +4 -0
 - data/app/models/solidus_paypal_commerce_platform/gateway.rb +20 -1
 - data/app/models/solidus_paypal_commerce_platform/payment_method.rb +22 -0
 - data/app/models/solidus_paypal_commerce_platform/payment_source.rb +11 -0
 - data/app/models/solidus_paypal_commerce_platform/paypal_order.rb +26 -5
 - data/app/models/solidus_paypal_commerce_platform/wizard.rb +1 -1
 - data/bin/rails-engine +1 -1
 - data/bin/sandbox +1 -1
 - data/config/locales/en.yml +34 -1
 - data/db/migrate/20211220133406_add_paypal_funding_source_to_paypal_commerce_platform_sources.rb +5 -0
 - data/lib/solidus_paypal_commerce_platform/client.rb +3 -3
 - data/lib/solidus_paypal_commerce_platform/configuration.rb +2 -2
 - data/lib/solidus_paypal_commerce_platform/engine.rb +13 -4
 - data/lib/solidus_paypal_commerce_platform/testing_support/factories.rb +2 -1
 - data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
 - data/lib/views/backend/spree/admin/payments/source_views/_paypal_commerce_platform.html.erb +3 -0
 - data/lib/views/frontend/solidus_paypal_commerce_platform/payments/_payment.html.erb +4 -0
 - data/lib/views/frontend/spree/checkout/payment/_paypal_commerce_platform.html.erb +17 -3
 - data/solidus_paypal_commerce_platform.gemspec +3 -3
 - metadata +14 -64
 - data/spec/features/backend/new_payment_method_spec.rb +0 -40
 - data/spec/features/frontend/cart_spec.rb +0 -46
 - data/spec/features/frontend/checkout_spec.rb +0 -89
 - data/spec/features/frontend/product_spec.rb +0 -91
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.COMPLETED.v2.json +0 -121
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/CHECKOUT.ORDER.PROCESSED.v2.json +0 -121
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v1.json +0 -50
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.COMPLETED.v2.json +0 -72
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v1.json +0 -50
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.DENIED.v2.json +0 -68
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v1.json +0 -51
 - data/spec/jobs/solidus_paypal_commerce_platform/fixtures/PAYMENT.CAPTURE.REFUNDED.v2.json +0 -63
 - data/spec/jobs/solidus_paypal_commerce_platform/webhook_job_spec.rb +0 -44
 - data/spec/lib/solidus_paypal_commerce_platform/client_spec.rb +0 -21
 - data/spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb +0 -91
 - data/spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb +0 -121
 - data/spec/models/solidus_paypal_commerce_platform/payment_source_spec.rb +0 -62
 - data/spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb +0 -67
 - data/spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb +0 -38
 - data/spec/models/solidus_paypal_commerce_platform/wizard_spec.rb +0 -9
 - data/spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb +0 -36
 - data/spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb +0 -44
 - data/spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb +0 -44
 - data/spec/spec_helper.rb +0 -32
 - data/spec/support/capybara.rb +0 -11
 - data/spec/support/paypal_sdk_script_tag_helper.rb +0 -13
 
| 
         @@ -1,121 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {
         
     | 
| 
       2 
     | 
    
         
            -
              "id": "WH-COC11055RA711503B-4YM959094A144403T",
         
     | 
| 
       3 
     | 
    
         
            -
              "create_time": "2018-04-16T21:21:49.000Z",
         
     | 
| 
       4 
     | 
    
         
            -
              "resource_type": "checkout-order",
         
     | 
| 
       5 
     | 
    
         
            -
              "event_type": "CHECKOUT.ORDER.COMPLETED",
         
     | 
| 
       6 
     | 
    
         
            -
              "summary": "Checkout Order Completed",
         
     | 
| 
       7 
     | 
    
         
            -
              "resource": {
         
     | 
| 
       8 
     | 
    
         
            -
                "update_time": "2018-04-01T21:20:49Z",
         
     | 
| 
       9 
     | 
    
         
            -
                "create_time": "2018-04-01T21:18:49Z",
         
     | 
| 
       10 
     | 
    
         
            -
                "purchase_units": [
         
     | 
| 
       11 
     | 
    
         
            -
                  {
         
     | 
| 
       12 
     | 
    
         
            -
                    "reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
         
     | 
| 
       13 
     | 
    
         
            -
                    "amount": {
         
     | 
| 
       14 
     | 
    
         
            -
                      "currency_code": "USD",
         
     | 
| 
       15 
     | 
    
         
            -
                      "value": "100.00"
         
     | 
| 
       16 
     | 
    
         
            -
                    },
         
     | 
| 
       17 
     | 
    
         
            -
                    "payee": {
         
     | 
| 
       18 
     | 
    
         
            -
                      "email_address": "seller@example.com"
         
     | 
| 
       19 
     | 
    
         
            -
                    },
         
     | 
| 
       20 
     | 
    
         
            -
                    "shipping": {
         
     | 
| 
       21 
     | 
    
         
            -
                      "method": "United States Postal Service",
         
     | 
| 
       22 
     | 
    
         
            -
                      "address": {
         
     | 
| 
       23 
     | 
    
         
            -
                        "address_line_1": "2211 N First Street",
         
     | 
| 
       24 
     | 
    
         
            -
                        "address_line_2": "Building 17",
         
     | 
| 
       25 
     | 
    
         
            -
                        "admin_area_2": "San Jose",
         
     | 
| 
       26 
     | 
    
         
            -
                        "admin_area_1": "CA",
         
     | 
| 
       27 
     | 
    
         
            -
                        "postal_code": "95131",
         
     | 
| 
       28 
     | 
    
         
            -
                        "country_code": "US"
         
     | 
| 
       29 
     | 
    
         
            -
                      }
         
     | 
| 
       30 
     | 
    
         
            -
                    },
         
     | 
| 
       31 
     | 
    
         
            -
                    "payments": {
         
     | 
| 
       32 
     | 
    
         
            -
                      "captures": [
         
     | 
| 
       33 
     | 
    
         
            -
                        {
         
     | 
| 
       34 
     | 
    
         
            -
                          "id": "3C679366HH908993F",
         
     | 
| 
       35 
     | 
    
         
            -
                          "status": "COMPLETED",
         
     | 
| 
       36 
     | 
    
         
            -
                          "amount": {
         
     | 
| 
       37 
     | 
    
         
            -
                            "currency_code": "USD",
         
     | 
| 
       38 
     | 
    
         
            -
                            "value": "100.00"
         
     | 
| 
       39 
     | 
    
         
            -
                          },
         
     | 
| 
       40 
     | 
    
         
            -
                          "seller_protection": {
         
     | 
| 
       41 
     | 
    
         
            -
                            "status": "ELIGIBLE",
         
     | 
| 
       42 
     | 
    
         
            -
                            "dispute_categories": [
         
     | 
| 
       43 
     | 
    
         
            -
                              "ITEM_NOT_RECEIVED",
         
     | 
| 
       44 
     | 
    
         
            -
                              "UNAUTHORIZED_TRANSACTION"
         
     | 
| 
       45 
     | 
    
         
            -
                            ]
         
     | 
| 
       46 
     | 
    
         
            -
                          },
         
     | 
| 
       47 
     | 
    
         
            -
                          "final_capture": true,
         
     | 
| 
       48 
     | 
    
         
            -
                          "seller_receivable_breakdown": {
         
     | 
| 
       49 
     | 
    
         
            -
                            "gross_amount": {
         
     | 
| 
       50 
     | 
    
         
            -
                              "currency_code": "USD",
         
     | 
| 
       51 
     | 
    
         
            -
                              "value": "100.00"
         
     | 
| 
       52 
     | 
    
         
            -
                            },
         
     | 
| 
       53 
     | 
    
         
            -
                            "paypal_fee": {
         
     | 
| 
       54 
     | 
    
         
            -
                              "currency_code": "USD",
         
     | 
| 
       55 
     | 
    
         
            -
                              "value": "3.00"
         
     | 
| 
       56 
     | 
    
         
            -
                            },
         
     | 
| 
       57 
     | 
    
         
            -
                            "net_amount": {
         
     | 
| 
       58 
     | 
    
         
            -
                              "currency_code": "USD",
         
     | 
| 
       59 
     | 
    
         
            -
                              "value": "97.00"
         
     | 
| 
       60 
     | 
    
         
            -
                            }
         
     | 
| 
       61 
     | 
    
         
            -
                          },
         
     | 
| 
       62 
     | 
    
         
            -
                          "create_time": "2018-04-01T21:20:49Z",
         
     | 
| 
       63 
     | 
    
         
            -
                          "update_time": "2018-04-01T21:20:49Z",
         
     | 
| 
       64 
     | 
    
         
            -
                          "links": [
         
     | 
| 
       65 
     | 
    
         
            -
                            {
         
     | 
| 
       66 
     | 
    
         
            -
                              "href": "https://api.paypal.com/v2/payments/captures/3C679366HH908993F",
         
     | 
| 
       67 
     | 
    
         
            -
                              "rel": "self",
         
     | 
| 
       68 
     | 
    
         
            -
                              "method": "GET"
         
     | 
| 
       69 
     | 
    
         
            -
                            },
         
     | 
| 
       70 
     | 
    
         
            -
                            {
         
     | 
| 
       71 
     | 
    
         
            -
                              "href": "https://api.paypal.com/v2/payments/captures/3C679366HH908993F/refund",
         
     | 
| 
       72 
     | 
    
         
            -
                              "rel": "refund",
         
     | 
| 
       73 
     | 
    
         
            -
                              "method": "POST"
         
     | 
| 
       74 
     | 
    
         
            -
                            }
         
     | 
| 
       75 
     | 
    
         
            -
                          ]
         
     | 
| 
       76 
     | 
    
         
            -
                        }
         
     | 
| 
       77 
     | 
    
         
            -
                      ]
         
     | 
| 
       78 
     | 
    
         
            -
                    }
         
     | 
| 
       79 
     | 
    
         
            -
                  }
         
     | 
| 
       80 
     | 
    
         
            -
                ],
         
     | 
| 
       81 
     | 
    
         
            -
                "links": [
         
     | 
| 
       82 
     | 
    
         
            -
                  {
         
     | 
| 
       83 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/checkout/orders/5O190127TN364715T",
         
     | 
| 
       84 
     | 
    
         
            -
                    "rel": "self",
         
     | 
| 
       85 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       86 
     | 
    
         
            -
                  }
         
     | 
| 
       87 
     | 
    
         
            -
                ],
         
     | 
| 
       88 
     | 
    
         
            -
                "id": "5O190127TN364715T",
         
     | 
| 
       89 
     | 
    
         
            -
                "gross_amount": {
         
     | 
| 
       90 
     | 
    
         
            -
                  "currency_code": "USD",
         
     | 
| 
       91 
     | 
    
         
            -
                  "value": "100.00"
         
     | 
| 
       92 
     | 
    
         
            -
                },
         
     | 
| 
       93 
     | 
    
         
            -
                "intent": "CAPTURE",
         
     | 
| 
       94 
     | 
    
         
            -
                "payer": {
         
     | 
| 
       95 
     | 
    
         
            -
                  "name": {
         
     | 
| 
       96 
     | 
    
         
            -
                    "given_name": "John",
         
     | 
| 
       97 
     | 
    
         
            -
                    "surname": "Doe"
         
     | 
| 
       98 
     | 
    
         
            -
                  },
         
     | 
| 
       99 
     | 
    
         
            -
                  "email_address": "buyer@example.com",
         
     | 
| 
       100 
     | 
    
         
            -
                  "payer_id": "QYR5Z8XDVJNXQ"
         
     | 
| 
       101 
     | 
    
         
            -
                },
         
     | 
| 
       102 
     | 
    
         
            -
                "status": "COMPLETED"
         
     | 
| 
       103 
     | 
    
         
            -
              },
         
     | 
| 
       104 
     | 
    
         
            -
              "links": [
         
     | 
| 
       105 
     | 
    
         
            -
                {
         
     | 
| 
       106 
     | 
    
         
            -
                  "href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-COC11055RA711503B-4YM959094A144403T",
         
     | 
| 
       107 
     | 
    
         
            -
                  "rel": "self",
         
     | 
| 
       108 
     | 
    
         
            -
                  "method": "GET",
         
     | 
| 
       109 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       110 
     | 
    
         
            -
                },
         
     | 
| 
       111 
     | 
    
         
            -
                {
         
     | 
| 
       112 
     | 
    
         
            -
                  "href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-COC11055RA711503B-4YM959094A144403T/resend",
         
     | 
| 
       113 
     | 
    
         
            -
                  "rel": "resend",
         
     | 
| 
       114 
     | 
    
         
            -
                  "method": "POST",
         
     | 
| 
       115 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       116 
     | 
    
         
            -
                }
         
     | 
| 
       117 
     | 
    
         
            -
              ],
         
     | 
| 
       118 
     | 
    
         
            -
              "event_version": "1.0",
         
     | 
| 
       119 
     | 
    
         
            -
              "zts": 1494957670,
         
     | 
| 
       120 
     | 
    
         
            -
              "resource_version": "2.0"
         
     | 
| 
       121 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,50 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {
         
     | 
| 
       2 
     | 
    
         
            -
              "id": "WH-7Y7254563A4550640-11V2185806837105M",
         
     | 
| 
       3 
     | 
    
         
            -
              "create_time": "2015-02-17T18:51:33Z",
         
     | 
| 
       4 
     | 
    
         
            -
              "resource_type": "capture",
         
     | 
| 
       5 
     | 
    
         
            -
              "event_type": "PAYMENT.CAPTURE.COMPLETED",
         
     | 
| 
       6 
     | 
    
         
            -
              "summary": "Payment completed for $ 7.47 USD",
         
     | 
| 
       7 
     | 
    
         
            -
              "resource": {
         
     | 
| 
       8 
     | 
    
         
            -
                "parent_payment": "PAY-3YE025760C441402AKTRY2PQ",
         
     | 
| 
       9 
     | 
    
         
            -
                "update_time": "2015-02-17T18:50:45Z",
         
     | 
| 
       10 
     | 
    
         
            -
                "amount": {
         
     | 
| 
       11 
     | 
    
         
            -
                  "total": "7.47",
         
     | 
| 
       12 
     | 
    
         
            -
                  "currency": "USD"
         
     | 
| 
       13 
     | 
    
         
            -
                },
         
     | 
| 
       14 
     | 
    
         
            -
                "create_time": "2015-02-17T18:50:44Z",
         
     | 
| 
       15 
     | 
    
         
            -
                "links": [
         
     | 
| 
       16 
     | 
    
         
            -
                  {
         
     | 
| 
       17 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/capture/42311647XV020574X",
         
     | 
| 
       18 
     | 
    
         
            -
                    "rel": "self",
         
     | 
| 
       19 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       20 
     | 
    
         
            -
                  },
         
     | 
| 
       21 
     | 
    
         
            -
                  {
         
     | 
| 
       22 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/capture/42311647XV020574X/refund",
         
     | 
| 
       23 
     | 
    
         
            -
                    "rel": "refund",
         
     | 
| 
       24 
     | 
    
         
            -
                    "method": "POST"
         
     | 
| 
       25 
     | 
    
         
            -
                  },
         
     | 
| 
       26 
     | 
    
         
            -
                  {
         
     | 
| 
       27 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/payment/PAY-3YE025760C441402AKTRY2PQ",
         
     | 
| 
       28 
     | 
    
         
            -
                    "rel": "parent_payment",
         
     | 
| 
       29 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       30 
     | 
    
         
            -
                  }
         
     | 
| 
       31 
     | 
    
         
            -
                ],
         
     | 
| 
       32 
     | 
    
         
            -
                "id": "42311647XV020574X",
         
     | 
| 
       33 
     | 
    
         
            -
                "state": "completed"
         
     | 
| 
       34 
     | 
    
         
            -
              },
         
     | 
| 
       35 
     | 
    
         
            -
              "links": [
         
     | 
| 
       36 
     | 
    
         
            -
                {
         
     | 
| 
       37 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-7Y7254563A4550640-11V2185806837105M",
         
     | 
| 
       38 
     | 
    
         
            -
                  "rel": "self",
         
     | 
| 
       39 
     | 
    
         
            -
                  "method": "GET",
         
     | 
| 
       40 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       41 
     | 
    
         
            -
                },
         
     | 
| 
       42 
     | 
    
         
            -
                {
         
     | 
| 
       43 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-7Y7254563A4550640-11V2185806837105M/resend",
         
     | 
| 
       44 
     | 
    
         
            -
                  "rel": "resend",
         
     | 
| 
       45 
     | 
    
         
            -
                  "method": "POST",
         
     | 
| 
       46 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       47 
     | 
    
         
            -
                }
         
     | 
| 
       48 
     | 
    
         
            -
              ],
         
     | 
| 
       49 
     | 
    
         
            -
              "event_version": "1.0"
         
     | 
| 
       50 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,72 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {
         
     | 
| 
       2 
     | 
    
         
            -
              "id": "WH-58D329510W468432D-8HN650336L201105X",
         
     | 
| 
       3 
     | 
    
         
            -
              "create_time": "2019-02-14T21:50:07.940Z",
         
     | 
| 
       4 
     | 
    
         
            -
              "resource_type": "capture",
         
     | 
| 
       5 
     | 
    
         
            -
              "event_type": "PAYMENT.CAPTURE.COMPLETED",
         
     | 
| 
       6 
     | 
    
         
            -
              "summary": "Payment completed for $ 2.51 USD",
         
     | 
| 
       7 
     | 
    
         
            -
              "resource": {
         
     | 
| 
       8 
     | 
    
         
            -
                "amount": {
         
     | 
| 
       9 
     | 
    
         
            -
                  "currency_code": "USD",
         
     | 
| 
       10 
     | 
    
         
            -
                  "value": "2.51"
         
     | 
| 
       11 
     | 
    
         
            -
                },
         
     | 
| 
       12 
     | 
    
         
            -
                "seller_protection": {
         
     | 
| 
       13 
     | 
    
         
            -
                  "status": "ELIGIBLE",
         
     | 
| 
       14 
     | 
    
         
            -
                  "dispute_categories": [
         
     | 
| 
       15 
     | 
    
         
            -
                    "ITEM_NOT_RECEIVED",
         
     | 
| 
       16 
     | 
    
         
            -
                    "UNAUTHORIZED_TRANSACTION"
         
     | 
| 
       17 
     | 
    
         
            -
                  ]
         
     | 
| 
       18 
     | 
    
         
            -
                },
         
     | 
| 
       19 
     | 
    
         
            -
                "update_time": "2019-02-14T21:49:58Z",
         
     | 
| 
       20 
     | 
    
         
            -
                "create_time": "2019-02-14T21:49:58Z",
         
     | 
| 
       21 
     | 
    
         
            -
                "final_capture": true,
         
     | 
| 
       22 
     | 
    
         
            -
                "seller_receivable_breakdown": {
         
     | 
| 
       23 
     | 
    
         
            -
                  "gross_amount": {
         
     | 
| 
       24 
     | 
    
         
            -
                    "currency_code": "USD",
         
     | 
| 
       25 
     | 
    
         
            -
                    "value": "2.51"
         
     | 
| 
       26 
     | 
    
         
            -
                  },
         
     | 
| 
       27 
     | 
    
         
            -
                  "paypal_fee": {
         
     | 
| 
       28 
     | 
    
         
            -
                    "currency_code": "USD",
         
     | 
| 
       29 
     | 
    
         
            -
                    "value": "0.37"
         
     | 
| 
       30 
     | 
    
         
            -
                  },
         
     | 
| 
       31 
     | 
    
         
            -
                  "net_amount": {
         
     | 
| 
       32 
     | 
    
         
            -
                    "currency_code": "USD",
         
     | 
| 
       33 
     | 
    
         
            -
                    "value": "2.14"
         
     | 
| 
       34 
     | 
    
         
            -
                  }
         
     | 
| 
       35 
     | 
    
         
            -
                },
         
     | 
| 
       36 
     | 
    
         
            -
                "links": [
         
     | 
| 
       37 
     | 
    
         
            -
                  {
         
     | 
| 
       38 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/captures/27M47624FP291604U",
         
     | 
| 
       39 
     | 
    
         
            -
                    "rel": "self",
         
     | 
| 
       40 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       41 
     | 
    
         
            -
                  },
         
     | 
| 
       42 
     | 
    
         
            -
                  {
         
     | 
| 
       43 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/captures/27M47624FP291604U/refund",
         
     | 
| 
       44 
     | 
    
         
            -
                    "rel": "refund",
         
     | 
| 
       45 
     | 
    
         
            -
                    "method": "POST"
         
     | 
| 
       46 
     | 
    
         
            -
                  },
         
     | 
| 
       47 
     | 
    
         
            -
                  {
         
     | 
| 
       48 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/authorizations/7W5147081L658180V",
         
     | 
| 
       49 
     | 
    
         
            -
                    "rel": "up",
         
     | 
| 
       50 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       51 
     | 
    
         
            -
                  }
         
     | 
| 
       52 
     | 
    
         
            -
                ],
         
     | 
| 
       53 
     | 
    
         
            -
                "id": "27M47624FP291604U",
         
     | 
| 
       54 
     | 
    
         
            -
                "status": "COMPLETED"
         
     | 
| 
       55 
     | 
    
         
            -
              },
         
     | 
| 
       56 
     | 
    
         
            -
              "links": [
         
     | 
| 
       57 
     | 
    
         
            -
                {
         
     | 
| 
       58 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-58D329510W468432D-8HN650336L201105X",
         
     | 
| 
       59 
     | 
    
         
            -
                  "rel": "self",
         
     | 
| 
       60 
     | 
    
         
            -
                  "method": "GET",
         
     | 
| 
       61 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       62 
     | 
    
         
            -
                },
         
     | 
| 
       63 
     | 
    
         
            -
                {
         
     | 
| 
       64 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-58D329510W468432D-8HN650336L201105X/resend",
         
     | 
| 
       65 
     | 
    
         
            -
                  "rel": "resend",
         
     | 
| 
       66 
     | 
    
         
            -
                  "method": "POST",
         
     | 
| 
       67 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       68 
     | 
    
         
            -
                }
         
     | 
| 
       69 
     | 
    
         
            -
              ],
         
     | 
| 
       70 
     | 
    
         
            -
              "event_version": "1.0",
         
     | 
| 
       71 
     | 
    
         
            -
              "resource_version": "2.0"
         
     | 
| 
       72 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,50 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {
         
     | 
| 
       2 
     | 
    
         
            -
              "id": "WH-8Y6524781B2662740-6BA13970S75831204",
         
     | 
| 
       3 
     | 
    
         
            -
              "create_time": "2015-10-07T16:58:15Z",
         
     | 
| 
       4 
     | 
    
         
            -
              "resource_type": "capture",
         
     | 
| 
       5 
     | 
    
         
            -
              "event_type": "PAYMENT.CAPTURE.DENIED",
         
     | 
| 
       6 
     | 
    
         
            -
              "summary": "A EUR 0.5 EUR capture payment was denied",
         
     | 
| 
       7 
     | 
    
         
            -
              "resource": {
         
     | 
| 
       8 
     | 
    
         
            -
                "parent_payment": "PAY-6AG64245W53716013KYKUWNI",
         
     | 
| 
       9 
     | 
    
         
            -
                "update_time": "2015-10-07T16:42:57Z",
         
     | 
| 
       10 
     | 
    
         
            -
                "amount": {
         
     | 
| 
       11 
     | 
    
         
            -
                  "total": "0.50",
         
     | 
| 
       12 
     | 
    
         
            -
                  "currency": "EUR"
         
     | 
| 
       13 
     | 
    
         
            -
                },
         
     | 
| 
       14 
     | 
    
         
            -
                "create_time": "2015-10-07T16:42:50Z",
         
     | 
| 
       15 
     | 
    
         
            -
                "links": [
         
     | 
| 
       16 
     | 
    
         
            -
                  {
         
     | 
| 
       17 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/capture/1YH34677BD7819356",
         
     | 
| 
       18 
     | 
    
         
            -
                    "rel": "self",
         
     | 
| 
       19 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       20 
     | 
    
         
            -
                  },
         
     | 
| 
       21 
     | 
    
         
            -
                  {
         
     | 
| 
       22 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/capture/1YH34677BD7819356/refund",
         
     | 
| 
       23 
     | 
    
         
            -
                    "rel": "refund",
         
     | 
| 
       24 
     | 
    
         
            -
                    "method": "POST"
         
     | 
| 
       25 
     | 
    
         
            -
                  },
         
     | 
| 
       26 
     | 
    
         
            -
                  {
         
     | 
| 
       27 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/payment/PAY-6AG64245W53716013KYKUWNI",
         
     | 
| 
       28 
     | 
    
         
            -
                    "rel": "parent_payment",
         
     | 
| 
       29 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       30 
     | 
    
         
            -
                  }
         
     | 
| 
       31 
     | 
    
         
            -
                ],
         
     | 
| 
       32 
     | 
    
         
            -
                "id": "1YH34677BD7819356",
         
     | 
| 
       33 
     | 
    
         
            -
                "state": "denied"
         
     | 
| 
       34 
     | 
    
         
            -
              },
         
     | 
| 
       35 
     | 
    
         
            -
              "links": [
         
     | 
| 
       36 
     | 
    
         
            -
                {
         
     | 
| 
       37 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-8Y6524781B2662740-6BA13970S75831204",
         
     | 
| 
       38 
     | 
    
         
            -
                  "rel": "self",
         
     | 
| 
       39 
     | 
    
         
            -
                  "method": "GET",
         
     | 
| 
       40 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       41 
     | 
    
         
            -
                },
         
     | 
| 
       42 
     | 
    
         
            -
                {
         
     | 
| 
       43 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-8Y6524781B2662740-6BA13970S75831204/resend",
         
     | 
| 
       44 
     | 
    
         
            -
                  "rel": "resend",
         
     | 
| 
       45 
     | 
    
         
            -
                  "method": "POST",
         
     | 
| 
       46 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       47 
     | 
    
         
            -
                }
         
     | 
| 
       48 
     | 
    
         
            -
              ],
         
     | 
| 
       49 
     | 
    
         
            -
              "event_version": "1.0"
         
     | 
| 
       50 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,68 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {
         
     | 
| 
       2 
     | 
    
         
            -
              "id": "WH-4SW78779LY2325805-07E03580SX1414828",
         
     | 
| 
       3 
     | 
    
         
            -
              "create_time": "2019-02-14T22:20:08.370Z",
         
     | 
| 
       4 
     | 
    
         
            -
              "resource_type": "capture",
         
     | 
| 
       5 
     | 
    
         
            -
              "event_type": "PAYMENT.CAPTURE.DENIED",
         
     | 
| 
       6 
     | 
    
         
            -
              "summary": "A AUD 2.51 AUD capture payment was denied",
         
     | 
| 
       7 
     | 
    
         
            -
              "resource": {
         
     | 
| 
       8 
     | 
    
         
            -
                "amount": {
         
     | 
| 
       9 
     | 
    
         
            -
                  "currency_code": "AUD",
         
     | 
| 
       10 
     | 
    
         
            -
                  "value": "2.51"
         
     | 
| 
       11 
     | 
    
         
            -
                },
         
     | 
| 
       12 
     | 
    
         
            -
                "seller_protection": {
         
     | 
| 
       13 
     | 
    
         
            -
                  "status": "ELIGIBLE",
         
     | 
| 
       14 
     | 
    
         
            -
                  "dispute_categories": [
         
     | 
| 
       15 
     | 
    
         
            -
                    "ITEM_NOT_RECEIVED",
         
     | 
| 
       16 
     | 
    
         
            -
                    "UNAUTHORIZED_TRANSACTION"
         
     | 
| 
       17 
     | 
    
         
            -
                  ]
         
     | 
| 
       18 
     | 
    
         
            -
                },
         
     | 
| 
       19 
     | 
    
         
            -
                "update_time": "2019-02-14T22:20:01Z",
         
     | 
| 
       20 
     | 
    
         
            -
                "create_time": "2019-02-14T22:18:14Z",
         
     | 
| 
       21 
     | 
    
         
            -
                "final_capture": true,
         
     | 
| 
       22 
     | 
    
         
            -
                "seller_receivable_breakdown": {
         
     | 
| 
       23 
     | 
    
         
            -
                  "gross_amount": {
         
     | 
| 
       24 
     | 
    
         
            -
                    "currency_code": "AUD",
         
     | 
| 
       25 
     | 
    
         
            -
                    "value": "2.51"
         
     | 
| 
       26 
     | 
    
         
            -
                  },
         
     | 
| 
       27 
     | 
    
         
            -
                  "net_amount": {
         
     | 
| 
       28 
     | 
    
         
            -
                    "currency_code": "AUD",
         
     | 
| 
       29 
     | 
    
         
            -
                    "value": "2.51"
         
     | 
| 
       30 
     | 
    
         
            -
                  }
         
     | 
| 
       31 
     | 
    
         
            -
                },
         
     | 
| 
       32 
     | 
    
         
            -
                "links": [
         
     | 
| 
       33 
     | 
    
         
            -
                  {
         
     | 
| 
       34 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/captures/7NW873794T343360M",
         
     | 
| 
       35 
     | 
    
         
            -
                    "rel": "self",
         
     | 
| 
       36 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       37 
     | 
    
         
            -
                  },
         
     | 
| 
       38 
     | 
    
         
            -
                  {
         
     | 
| 
       39 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/captures/7NW873794T343360M/refund",
         
     | 
| 
       40 
     | 
    
         
            -
                    "rel": "refund",
         
     | 
| 
       41 
     | 
    
         
            -
                    "method": "POST"
         
     | 
| 
       42 
     | 
    
         
            -
                  },
         
     | 
| 
       43 
     | 
    
         
            -
                  {
         
     | 
| 
       44 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/authorizations/2W543679LP5841156",
         
     | 
| 
       45 
     | 
    
         
            -
                    "rel": "up",
         
     | 
| 
       46 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       47 
     | 
    
         
            -
                  }
         
     | 
| 
       48 
     | 
    
         
            -
                ],
         
     | 
| 
       49 
     | 
    
         
            -
                "id": "7NW873794T343360M",
         
     | 
| 
       50 
     | 
    
         
            -
                "status": "DECLINED"
         
     | 
| 
       51 
     | 
    
         
            -
              },
         
     | 
| 
       52 
     | 
    
         
            -
              "links": [
         
     | 
| 
       53 
     | 
    
         
            -
                {
         
     | 
| 
       54 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-4SW78779LY2325805-07E03580SX1414828",
         
     | 
| 
       55 
     | 
    
         
            -
                  "rel": "self",
         
     | 
| 
       56 
     | 
    
         
            -
                  "method": "GET",
         
     | 
| 
       57 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       58 
     | 
    
         
            -
                },
         
     | 
| 
       59 
     | 
    
         
            -
                {
         
     | 
| 
       60 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-4SW78779LY2325805-07E03580SX1414828/resend",
         
     | 
| 
       61 
     | 
    
         
            -
                  "rel": "resend",
         
     | 
| 
       62 
     | 
    
         
            -
                  "method": "POST",
         
     | 
| 
       63 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       64 
     | 
    
         
            -
                }
         
     | 
| 
       65 
     | 
    
         
            -
              ],
         
     | 
| 
       66 
     | 
    
         
            -
              "event_version": "1.0",
         
     | 
| 
       67 
     | 
    
         
            -
              "resource_version": "2.0"
         
     | 
| 
       68 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,51 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {
         
     | 
| 
       2 
     | 
    
         
            -
              "id": "WH-2JG62852X9350413N-40V56408FN023574K",
         
     | 
| 
       3 
     | 
    
         
            -
              "create_time": "2014-10-22T23:49:03Z",
         
     | 
| 
       4 
     | 
    
         
            -
              "resource_type": "capture",
         
     | 
| 
       5 
     | 
    
         
            -
              "event_type": "PAYMENT.CAPTURE.REFUNDED",
         
     | 
| 
       6 
     | 
    
         
            -
              "summary": "A $ 0.15 USD capture payment was refunded",
         
     | 
| 
       7 
     | 
    
         
            -
              "resource": {
         
     | 
| 
       8 
     | 
    
         
            -
                "parent_payment": "PAY-7PD36489JY0066936KREEERQ",
         
     | 
| 
       9 
     | 
    
         
            -
                "update_time": "2014-10-22T23:48:57Z",
         
     | 
| 
       10 
     | 
    
         
            -
                "amount": {
         
     | 
| 
       11 
     | 
    
         
            -
                  "total": "-0.15",
         
     | 
| 
       12 
     | 
    
         
            -
                  "currency": "USD"
         
     | 
| 
       13 
     | 
    
         
            -
                },
         
     | 
| 
       14 
     | 
    
         
            -
                "create_time": "2014-10-22T23:48:57Z",
         
     | 
| 
       15 
     | 
    
         
            -
                "links": [
         
     | 
| 
       16 
     | 
    
         
            -
                  {
         
     | 
| 
       17 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/refund/8VC964970N548345V",
         
     | 
| 
       18 
     | 
    
         
            -
                    "rel": "self",
         
     | 
| 
       19 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       20 
     | 
    
         
            -
                  },
         
     | 
| 
       21 
     | 
    
         
            -
                  {
         
     | 
| 
       22 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/payment/PAY-7PD36489JY0066936KREEERQ",
         
     | 
| 
       23 
     | 
    
         
            -
                    "rel": "parent_payment",
         
     | 
| 
       24 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       25 
     | 
    
         
            -
                  },
         
     | 
| 
       26 
     | 
    
         
            -
                  {
         
     | 
| 
       27 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v1/payments/capture/5LK72275CG489890D",
         
     | 
| 
       28 
     | 
    
         
            -
                    "rel": "capture",
         
     | 
| 
       29 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       30 
     | 
    
         
            -
                  }
         
     | 
| 
       31 
     | 
    
         
            -
                ],
         
     | 
| 
       32 
     | 
    
         
            -
                "id": "8VC964970N548345V",
         
     | 
| 
       33 
     | 
    
         
            -
                "state": "completed",
         
     | 
| 
       34 
     | 
    
         
            -
                "capture_id": "5LK72275CG489890D"
         
     | 
| 
       35 
     | 
    
         
            -
              },
         
     | 
| 
       36 
     | 
    
         
            -
              "links": [
         
     | 
| 
       37 
     | 
    
         
            -
                {
         
     | 
| 
       38 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-2JG62852X9350413N-40V56408FN023574K",
         
     | 
| 
       39 
     | 
    
         
            -
                  "rel": "self",
         
     | 
| 
       40 
     | 
    
         
            -
                  "method": "GET",
         
     | 
| 
       41 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       42 
     | 
    
         
            -
                },
         
     | 
| 
       43 
     | 
    
         
            -
                {
         
     | 
| 
       44 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-2JG62852X9350413N-40V56408FN023574K/resend",
         
     | 
| 
       45 
     | 
    
         
            -
                  "rel": "resend",
         
     | 
| 
       46 
     | 
    
         
            -
                  "method": "POST",
         
     | 
| 
       47 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       48 
     | 
    
         
            -
                }
         
     | 
| 
       49 
     | 
    
         
            -
              ],
         
     | 
| 
       50 
     | 
    
         
            -
              "event_version": "1.0"
         
     | 
| 
       51 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,63 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {
         
     | 
| 
       2 
     | 
    
         
            -
              "id": "WH-1GE84257G0350133W-6RW800890C634293G",
         
     | 
| 
       3 
     | 
    
         
            -
              "create_time": "2018-08-15T19:14:04.543Z",
         
     | 
| 
       4 
     | 
    
         
            -
              "resource_type": "refund",
         
     | 
| 
       5 
     | 
    
         
            -
              "event_type": "PAYMENT.CAPTURE.REFUNDED",
         
     | 
| 
       6 
     | 
    
         
            -
              "summary": "A $ 0.99 USD capture payment was refunded",
         
     | 
| 
       7 
     | 
    
         
            -
              "resource": {
         
     | 
| 
       8 
     | 
    
         
            -
                "seller_payable_breakdown": {
         
     | 
| 
       9 
     | 
    
         
            -
                  "gross_amount": {
         
     | 
| 
       10 
     | 
    
         
            -
                    "currency_code": "USD",
         
     | 
| 
       11 
     | 
    
         
            -
                    "value": "0.99"
         
     | 
| 
       12 
     | 
    
         
            -
                  },
         
     | 
| 
       13 
     | 
    
         
            -
                  "paypal_fee": {
         
     | 
| 
       14 
     | 
    
         
            -
                    "currency_code": "USD",
         
     | 
| 
       15 
     | 
    
         
            -
                    "value": "0.02"
         
     | 
| 
       16 
     | 
    
         
            -
                  },
         
     | 
| 
       17 
     | 
    
         
            -
                  "net_amount": {
         
     | 
| 
       18 
     | 
    
         
            -
                    "currency_code": "USD",
         
     | 
| 
       19 
     | 
    
         
            -
                    "value": "0.97"
         
     | 
| 
       20 
     | 
    
         
            -
                  },
         
     | 
| 
       21 
     | 
    
         
            -
                  "total_refunded_amount": {
         
     | 
| 
       22 
     | 
    
         
            -
                    "currency_code": "USD",
         
     | 
| 
       23 
     | 
    
         
            -
                    "value": "1.98"
         
     | 
| 
       24 
     | 
    
         
            -
                  }
         
     | 
| 
       25 
     | 
    
         
            -
                },
         
     | 
| 
       26 
     | 
    
         
            -
                "amount": {
         
     | 
| 
       27 
     | 
    
         
            -
                  "currency_code": "USD",
         
     | 
| 
       28 
     | 
    
         
            -
                  "value": "0.99"
         
     | 
| 
       29 
     | 
    
         
            -
                },
         
     | 
| 
       30 
     | 
    
         
            -
                "update_time": "2018-08-15T12:13:29-07:00",
         
     | 
| 
       31 
     | 
    
         
            -
                "create_time": "2018-08-15T12:13:29-07:00",
         
     | 
| 
       32 
     | 
    
         
            -
                "links": [
         
     | 
| 
       33 
     | 
    
         
            -
                  {
         
     | 
| 
       34 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/refunds/1Y107995YT783435V",
         
     | 
| 
       35 
     | 
    
         
            -
                    "rel": "self",
         
     | 
| 
       36 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       37 
     | 
    
         
            -
                  },
         
     | 
| 
       38 
     | 
    
         
            -
                  {
         
     | 
| 
       39 
     | 
    
         
            -
                    "href": "https://api.paypal.com/v2/payments/captures/0JF852973C016714D",
         
     | 
| 
       40 
     | 
    
         
            -
                    "rel": "up",
         
     | 
| 
       41 
     | 
    
         
            -
                    "method": "GET"
         
     | 
| 
       42 
     | 
    
         
            -
                  }
         
     | 
| 
       43 
     | 
    
         
            -
                ],
         
     | 
| 
       44 
     | 
    
         
            -
                "id": "1Y107995YT783435V",
         
     | 
| 
       45 
     | 
    
         
            -
                "status": "COMPLETED"
         
     | 
| 
       46 
     | 
    
         
            -
              },
         
     | 
| 
       47 
     | 
    
         
            -
              "links": [
         
     | 
| 
       48 
     | 
    
         
            -
                {
         
     | 
| 
       49 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-1GE84257G0350133W-6RW800890C634293G",
         
     | 
| 
       50 
     | 
    
         
            -
                  "rel": "self",
         
     | 
| 
       51 
     | 
    
         
            -
                  "method": "GET",
         
     | 
| 
       52 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       53 
     | 
    
         
            -
                },
         
     | 
| 
       54 
     | 
    
         
            -
                {
         
     | 
| 
       55 
     | 
    
         
            -
                  "href": "https://api.paypal.com/v1/notifications/webhooks-events/WH-1GE84257G0350133W-6RW800890C634293G/resend",
         
     | 
| 
       56 
     | 
    
         
            -
                  "rel": "resend",
         
     | 
| 
       57 
     | 
    
         
            -
                  "method": "POST",
         
     | 
| 
       58 
     | 
    
         
            -
                  "encType": "application/json"
         
     | 
| 
       59 
     | 
    
         
            -
                }
         
     | 
| 
       60 
     | 
    
         
            -
              ],
         
     | 
| 
       61 
     | 
    
         
            -
              "event_version": "1.0",
         
     | 
| 
       62 
     | 
    
         
            -
              "resource_version": "2.0"
         
     | 
| 
       63 
     | 
    
         
            -
            }
         
     | 
| 
         @@ -1,44 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            RSpec.describe SolidusPaypalCommercePlatform::WebhookJob do
         
     | 
| 
       4 
     | 
    
         
            -
              let(:paypal_order_id) { SecureRandom.uuid }
         
     | 
| 
       5 
     | 
    
         
            -
              let(:capture_id) { SecureRandom.uuid }
         
     | 
| 
       6 
     | 
    
         
            -
              let(:refund_id) { SecureRandom.uuid }
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              let(:payment_source) {
         
     | 
| 
       9 
     | 
    
         
            -
                SolidusPaypalCommercePlatform::PaymentSource.new(
         
     | 
| 
       10 
     | 
    
         
            -
                  paypal_order_id: paypal_order_id,
         
     | 
| 
       11 
     | 
    
         
            -
                  capture_id: capture_id,
         
     | 
| 
       12 
     | 
    
         
            -
                  refund_id: refund_id,
         
     | 
| 
       13 
     | 
    
         
            -
                  payment_method: create(:paypal_payment_method),
         
     | 
| 
       14 
     | 
    
         
            -
                )
         
     | 
| 
       15 
     | 
    
         
            -
              }
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              let(:payment) {
         
     | 
| 
       18 
     | 
    
         
            -
                create(:order).payments.create!(
         
     | 
| 
       19 
     | 
    
         
            -
                  payment_method: payment_source.payment_method,
         
     | 
| 
       20 
     | 
    
         
            -
                  source: payment_source,
         
     | 
| 
       21 
     | 
    
         
            -
                )
         
     | 
| 
       22 
     | 
    
         
            -
              }
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              [
         
     | 
| 
       25 
     | 
    
         
            -
                ["CHECKOUT.ORDER.COMPLETED.v2", "paypal_order_id"],
         
     | 
| 
       26 
     | 
    
         
            -
                ["CHECKOUT.ORDER.PROCESSED.v2", "paypal_order_id"],
         
     | 
| 
       27 
     | 
    
         
            -
                ["PAYMENT.CAPTURE.COMPLETED.v1", "capture_id"],
         
     | 
| 
       28 
     | 
    
         
            -
                ["PAYMENT.CAPTURE.COMPLETED.v2", "capture_id"],
         
     | 
| 
       29 
     | 
    
         
            -
                ["PAYMENT.CAPTURE.DENIED.v1", "capture_id"],
         
     | 
| 
       30 
     | 
    
         
            -
                ["PAYMENT.CAPTURE.DENIED.v2", "capture_id"],
         
     | 
| 
       31 
     | 
    
         
            -
                ["PAYMENT.CAPTURE.REFUNDED.v1", "capture_id"],
         
     | 
| 
       32 
     | 
    
         
            -
                ["PAYMENT.CAPTURE.REFUNDED.v2", "refund_id"],
         
     | 
| 
       33 
     | 
    
         
            -
              ].each do |(event, source_attr)|
         
     | 
| 
       34 
     | 
    
         
            -
                describe event do
         
     | 
| 
       35 
     | 
    
         
            -
                  let(:payload) { JSON.parse(File.read("#{__dir__}/fixtures/#{event}.json")) }
         
     | 
| 
       36 
     | 
    
         
            -
                  let(source_attr) { payload.dig("resource", "id") }
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  it 'inserts a log entry for the corresponding payment source' do
         
     | 
| 
       39 
     | 
    
         
            -
                    expect { described_class.perform_now(payload) }.to change(payment.log_entries, :count).by(1)
         
     | 
| 
       40 
     | 
    
         
            -
                    expect(YAML.load(payment.log_entries.last.details)).to eq(payload)
         
     | 
| 
       41 
     | 
    
         
            -
                  end
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,21 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            RSpec.describe SolidusPaypalCommercePlatform::Client do
         
     | 
| 
       4 
     | 
    
         
            -
              subject(:client) { described_class.new(client_id: "1234") }
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              describe '#execute_with_response' do
         
     | 
| 
       7 
     | 
    
         
            -
                let(:request_class) { SolidusPaypalCommercePlatform::Gateway::OrdersCaptureRequest }
         
     | 
| 
       8 
     | 
    
         
            -
                let(:paypal_request) { double(:request, class: request_class) }
         
     | 
| 
       9 
     | 
    
         
            -
                let(:paypal_response) { double(:response, status_code: status_code, result: nil, headers: {}) }
         
     | 
| 
       10 
     | 
    
         
            -
                let(:status_code) { 201 }
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                it 'forwards to the upstream client adding i18n response messages' do
         
     | 
| 
       13 
     | 
    
         
            -
                  allow_any_instance_of(PayPal::PayPalHttpClient)
         
     | 
| 
       14 
     | 
    
         
            -
                    .to receive(:execute).with(paypal_request).and_return(paypal_response)
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                  response = subject.execute_with_response(paypal_request)
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                  expect(response.message).to eq("Payment captured")
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
              end
         
     | 
| 
       21 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,91 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'spec_helper'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            RSpec.describe SolidusPaypalCommercePlatform::Configuration do
         
     | 
| 
       4 
     | 
    
         
            -
              let(:subject) { described_class.new }
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              describe '#default_env' do
         
     | 
| 
       7 
     | 
    
         
            -
                it "uses ENV['PAYPAL_ENV'] when present" do
         
     | 
| 
       8 
     | 
    
         
            -
                  expect(ENV).to receive(:[]).with("PAYPAL_ENV").and_return("foo").at_least(:once)
         
     | 
| 
       9 
     | 
    
         
            -
                  expect(subject.default_env).to eq("foo")
         
     | 
| 
       10 
     | 
    
         
            -
                end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                it "falls back to Rails.env if ENV['PAYPAL_ENV'] is not set" do
         
     | 
| 
       13 
     | 
    
         
            -
                  expect(ENV).to receive(:[]).with("PAYPAL_ENV").and_return(nil).at_least(:once)
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                  allow(Rails).to receive(:env).and_return("development".inquiry)
         
     | 
| 
       16 
     | 
    
         
            -
                  expect(subject.default_env).to eq("sandbox")
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                  allow(Rails).to receive(:env).and_return("test".inquiry)
         
     | 
| 
       19 
     | 
    
         
            -
                  expect(subject.default_env).to eq("sandbox")
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                  allow(Rails).to receive(:env).and_return("production".inquiry)
         
     | 
| 
       22 
     | 
    
         
            -
                  expect(subject.default_env).to eq("live")
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                  allow(Rails).to receive(:env).and_return("staging".inquiry)
         
     | 
| 
       25 
     | 
    
         
            -
                  expect{ subject.default_env }.to raise_error(described_class::InvalidEnvironment)
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
              describe '#env' do
         
     | 
| 
       30 
     | 
    
         
            -
                it 'returns a string inquirer' do
         
     | 
| 
       31 
     | 
    
         
            -
                  expect(subject.env).to eq("sandbox")
         
     | 
| 
       32 
     | 
    
         
            -
                  expect(subject.env).to be_sandbox
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                  subject.env = "live"
         
     | 
| 
       35 
     | 
    
         
            -
                  expect(subject.env).to eq("live")
         
     | 
| 
       36 
     | 
    
         
            -
                  expect(subject.env).to be_live
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                  subject.env = "sandbox"
         
     | 
| 
       39 
     | 
    
         
            -
                  expect(subject.env).to eq("sandbox")
         
     | 
| 
       40 
     | 
    
         
            -
                  expect(subject.env).to be_sandbox
         
     | 
| 
       41 
     | 
    
         
            -
                end
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                it 'raises an error when assigned an unsupported value' do
         
     | 
| 
       44 
     | 
    
         
            -
                  expect{ subject.env = "foo" }.to raise_error(described_class::InvalidEnvironment)
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
              end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
              describe '#env_class' do
         
     | 
| 
       49 
     | 
    
         
            -
                it 'changes based on the current env' do
         
     | 
| 
       50 
     | 
    
         
            -
                  subject.env = "live"
         
     | 
| 
       51 
     | 
    
         
            -
                  expect(subject.env_class).to eq(PayPal::LiveEnvironment)
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                  subject.env = "sandbox"
         
     | 
| 
       54 
     | 
    
         
            -
                  expect(subject.env_class).to eq(PayPal::SandboxEnvironment)
         
     | 
| 
       55 
     | 
    
         
            -
                end
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
              describe '#env_domain' do
         
     | 
| 
       59 
     | 
    
         
            -
                it 'changes based on the current env' do
         
     | 
| 
       60 
     | 
    
         
            -
                  subject.env = "live"
         
     | 
| 
       61 
     | 
    
         
            -
                  expect(subject.env_domain).to eq("www.paypal.com")
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                  subject.env = "sandbox"
         
     | 
| 
       64 
     | 
    
         
            -
                  expect(subject.env_domain).to eq("www.sandbox.paypal.com")
         
     | 
| 
       65 
     | 
    
         
            -
                end
         
     | 
| 
       66 
     | 
    
         
            -
              end
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
              describe "#state_guesser_class" do
         
     | 
| 
       69 
     | 
    
         
            -
                before do
         
     | 
| 
       70 
     | 
    
         
            -
                  stub_const('SolidusPaypalCommercePlatform::BetterStateGuesser', Class.new)
         
     | 
| 
       71 
     | 
    
         
            -
                end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                it "returns a class" do
         
     | 
| 
       74 
     | 
    
         
            -
                  expect(subject.state_guesser_class).to be_kind_of(Class)
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                it "is settable" do
         
     | 
| 
       78 
     | 
    
         
            -
                  expect(subject.state_guesser_class).to eq(SolidusPaypalCommercePlatform::StateGuesser)
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
                  subject.state_guesser_class = "SolidusPaypalCommercePlatform::BetterStateGuesser"
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                  expect(subject.state_guesser_class).to eq(SolidusPaypalCommercePlatform::BetterStateGuesser)
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
              end
         
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
              describe "#partner_code" do
         
     | 
| 
       87 
     | 
    
         
            -
                it "returns the correct code" do
         
     | 
| 
       88 
     | 
    
         
            -
                  expect(subject.partner_code).to eq("Solidus_PCP_SP")
         
     | 
| 
       89 
     | 
    
         
            -
                end
         
     | 
| 
       90 
     | 
    
         
            -
              end
         
     | 
| 
       91 
     | 
    
         
            -
            end
         
     |