Class: PaypalAPI::Client
- Inherits:
-
Object
- Object
- PaypalAPI::Client
- Includes:
- APIMethods, AccessTokenMethods, EnvironmentMethods, HTTPMethods
- Defined in:
- lib/paypal-api/client.rb,
lib/paypal-api/client/api_methods.rb,
lib/paypal-api/client/http_methods.rb,
lib/paypal-api/client/environment_methods.rb,
lib/paypal-api/client/access_token_methods.rb
Overview
PaypalAPI Client
Defined Under Namespace
Modules: APIMethods, AccessTokenMethods, EnvironmentMethods, HTTPMethods
Instance Attribute Summary collapse
-
#callbacks ⇒ Hash
readonly
Registered callbacks.
-
#config ⇒ Config
readonly
Gem Configuration.
-
#env ⇒ Object
readonly
Paypal environment.
Instance Method Summary collapse
-
#add_callback(callback_name, &block) ⇒ void
Registers callback.
-
#initialize(client_id:, client_secret:, live: false, http_opts: nil, retries: nil, cache: nil) ⇒ Client
constructor
Initializes Client.
-
#verify_webhook(webhook_id:, headers:, raw_body:) ⇒ Boolean
Verifies Webhook.
Methods included from HTTPMethods
#delete, #get, #patch, #post, #put
Methods included from EnvironmentMethods
#api_url, #live?, #sandbox?, #web_url
Methods included from APIMethods
#authentication, #authorized_payments, #captured_payments, #catalog_products, #disputes, #invoice_templates, #invoices, #orders, #orders_v1, #partner_referrals, #payment_experience_web_profiles, #payment_tokens, #payout_items, #payouts, #referenced_payout_items, #referenced_payouts, #refunds, #setup_tokens, #shipment_tracking, #subscription_plans, #subscriptions, #transaction_search, #user_info, #users, #webhook_events, #webhook_lookups, #webhooks
Methods included from AccessTokenMethods
#access_token, #refresh_access_token
Constructor Details
#initialize(client_id:, client_secret:, live: false, http_opts: nil, retries: nil, cache: nil) ⇒ Client
Initializes Client
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/paypal-api/client.rb', line 37 def initialize(client_id:, client_secret:, live: false, http_opts: nil, retries: nil, cache: nil) @env = PaypalAPI::Environment.new(client_id: client_id, client_secret: client_secret, live: live) @config = PaypalAPI::Config.new(http_opts: http_opts, retries: retries, cache: cache) @callbacks = { before: [], after_success: [], after_fail: [], after_network_error: [] }.freeze @access_token = nil end |
Instance Attribute Details
#callbacks ⇒ Hash (readonly)
Registered callbacks
24 25 26 |
# File 'lib/paypal-api/client.rb', line 24 def callbacks @callbacks end |
#config ⇒ Config (readonly)
Gem Configuration
19 20 21 |
# File 'lib/paypal-api/client.rb', line 19 def config @config end |
#env ⇒ Object (readonly)
Paypal environment
14 15 16 |
# File 'lib/paypal-api/client.rb', line 14 def env @env end |
Instance Method Details
#add_callback(callback_name, &block) ⇒ void
This method returns an undefined value.
Registers callback
70 71 72 |
# File 'lib/paypal-api/client.rb', line 70 def add_callback(callback_name, &block) callbacks.fetch(callback_name) << block end |
#verify_webhook(webhook_id:, headers:, raw_body:) ⇒ Boolean
Verifies Webhook
It requires one-time request to download and cache certificate. If local verification returns false it tries to verify webhook online.
102 103 104 |
# File 'lib/paypal-api/client.rb', line 102 def verify_webhook(webhook_id:, headers:, raw_body:) WebhookVerifier.new(self).call(webhook_id: webhook_id, headers: headers, raw_body: raw_body) end |