README.md in paypal-rest-api-0.1.0 vs README.md in paypal-rest-api-0.1.1

- old
+ new

@@ -6,11 +6,11 @@ bundle add paypal-rest-api ``` ## Features -- Supported Ruby 2.6 - current Head +- Supported Ruby Versions - *(2.6 .. 3.3), head, jruby-9.4, truffleruby-24* - No dependencies; - Automatic authorization & reauthorization; - Auto-retries (configured); - Automatically added Paypal-Request-Id header for idempotent requests if not provided; @@ -142,16 +142,16 @@ ## Webhoooks verification Webhooks can be verified [offline](https://developer.paypal.com/api/rest/webhooks/rest/#link-selfverificationmethod) or [online](https://developer.paypal.com/api/rest/webhooks/rest/#link-postbackmethod). Method `PaypalAPI.verify_webhook(webhook_id:, headers:, raw_body:)` -verifies webhook. It to verify webhook OFFLINE and it fallbacks -to ONLINE if offline verification returns false to be sure you don't miss a +verifies webhook. It verifies webhook OFFLINE and fallbacks +to ONLINE if initial verification returns false to be sure you don't miss a valid webhook. -When some required header is missing it will raise -`PaypalAPI::WebhooksVerifier::MissingHeader` error. +When some required header is missing the +`PaypalAPI::WebhooksVerifier::MissingHeader` error will be raised. Example of Rails controller with webhook verification: ```ruby class Webhooks::PaypalController < ApplicationController @@ -190,21 +190,29 @@ Callbacks are registered on `client` object. Each callback receive `request` and `context` variables. `context` can be modified manually to save state between callbacks. -`:after_success` and `:after_fail` callbacks have additional `response` argument +Arguments: -`:after_network_error` callback has additional `error` argument +- `:before` - (request, context) +- `:after_success` - (request, context, response) +- `:after_fail` - (request, context, response) +- `:after_network_error` - (request, context, error) +`Context` argument contains `retries_enabled` and `retries_count` and +`retry_number` keys by default. + +Examples: + ```ruby PaypalAPI.client.add_callback(:before) do |request, context| context[:request_id] = SecureRandom.hex(3) context[:starts_at] = Process.clock_gettime(Process::CLOCK_MONOTONIC) end -PaypalAPI.client.add_callback(:after) do |request, context, response| +PaypalAPI.client.add_callback(:after_success) do |request, context, response| ends_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) duration = ends_at - context[:starts_at] SomeLogger.debug( 'PaypalAPI success request', @@ -227,11 +235,11 @@ ) end PaypalAPI.client.add_callback(:after_network_error) do |request, context, error| SomeLogger.error( - 'PaypalAPI network connection error' + 'PaypalAPI network connection error', method: request.method, uri: request.uri.to_s, error: error.message, paypal_request_id: request.headers['paypal-request-id'], will_retry: context[:will_retry], @@ -314,18 +322,18 @@ - `PaypalAPI::Orders.track` - `PaypalAPI::Orders.update_tracker` ### Payments -- `PaypalAPI::AuthorizedPayment.show` -- `PaypalAPI::AuthorizedPayment.capture` -- `PaypalAPI::AuthorizedPayment.reauthorize` -- `PaypalAPI::AuthorizedPayment.void` +- `PaypalAPI::AuthorizedPayments.show` +- `PaypalAPI::AuthorizedPayments.capture` +- `PaypalAPI::AuthorizedPayments.reauthorize` +- `PaypalAPI::AuthorizedPayments.void` <!-- --> -- `PaypalAPI::CapturedPayment.show` -- `PaypalAPI::CapturedPayment.refund` +- `PaypalAPI::CapturedPayments.show` +- `PaypalAPI::CapturedPayments.refund` <!-- --> - `PaypalAPI::Refunds.show`