paypal-sdk-rest 1.7.4 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -14
- data/README.md +45 -251
- data/lib/lib.rb +88 -0
- data/lib/paypal/core/access_token.rb +20 -0
- data/lib/paypal/core/paypal_environment.rb +38 -0
- data/lib/paypal/core/paypal_http_client.rb +51 -0
- data/lib/paypal/core/token_requests.rb +40 -0
- data/lib/paypal/core/version.rb +3 -0
- data/lib/v1/billing_agreements/agreement_bill_balance_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_cancel_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_create_request.rb +33 -0
- data/lib/v1/billing_agreements/agreement_execute_request.rb +31 -0
- data/lib/v1/billing_agreements/agreement_get_request.rb +31 -0
- data/lib/v1/billing_agreements/agreement_re_activate_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_set_balance_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_suspend_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_transactions_request.rb +41 -0
- data/lib/v1/billing_agreements/agreement_update_request.rb +35 -0
- data/lib/v1/billing_plans/plan_create_request.rb +33 -0
- data/lib/v1/billing_plans/plan_get_request.rb +31 -0
- data/lib/v1/billing_plans/plan_list_request.rb +49 -0
- data/lib/v1/billing_plans/plan_update_request.rb +35 -0
- data/lib/v1/identity/user_consent.rb +45 -0
- data/lib/v1/identity/userinfo_get_request.rb +33 -0
- data/lib/v1/invoices/invoice_cancel_request.rb +35 -0
- data/lib/v1/invoices/invoice_create_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_external_payment_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_external_refund_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_request.rb +31 -0
- data/lib/v1/invoices/invoice_get_request.rb +31 -0
- data/lib/v1/invoices/invoice_list_request.rb +44 -0
- data/lib/v1/invoices/invoice_next_invoice_number_request.rb +29 -0
- data/lib/v1/invoices/invoice_qr_code_request.rb +46 -0
- data/lib/v1/invoices/invoice_record_payment_request.rb +35 -0
- data/lib/v1/invoices/invoice_record_refund_request.rb +35 -0
- data/lib/v1/invoices/invoice_remind_request.rb +35 -0
- data/lib/v1/invoices/invoice_search_request.rb +33 -0
- data/lib/v1/invoices/invoice_send_request.rb +36 -0
- data/lib/v1/invoices/invoice_update_request.rb +40 -0
- data/lib/v1/invoices/template_create_request.rb +33 -0
- data/lib/v1/invoices/template_delete_request.rb +31 -0
- data/lib/v1/invoices/template_get_request.rb +31 -0
- data/lib/v1/invoices/template_list_request.rb +34 -0
- data/lib/v1/invoices/template_update_request.rb +35 -0
- data/lib/v1/orders/orders_cancel_request.rb +31 -0
- data/lib/v1/orders/orders_create_request.rb +33 -0
- data/lib/v1/orders/orders_get_request.rb +31 -0
- data/lib/v1/orders/orders_pay_request.rb +35 -0
- data/lib/v1/payment_experience/web_profile_create_request.rb +33 -0
- data/lib/v1/payment_experience/web_profile_delete_request.rb +31 -0
- data/lib/v1/payment_experience/web_profile_get_request.rb +31 -0
- data/lib/v1/payment_experience/web_profile_list_request.rb +29 -0
- data/lib/v1/payment_experience/web_profile_partial_update_request.rb +35 -0
- data/lib/v1/payment_experience/web_profile_update_request.rb +35 -0
- data/lib/v1/payments/authorization_capture_request.rb +35 -0
- data/lib/v1/payments/authorization_get_request.rb +31 -0
- data/lib/v1/payments/authorization_reauthorize_request.rb +35 -0
- data/lib/v1/payments/authorization_void_request.rb +31 -0
- data/lib/v1/payments/capture_get_request.rb +31 -0
- data/lib/v1/payments/capture_refund_request.rb +35 -0
- data/lib/v1/payments/order_authorize_request.rb +35 -0
- data/lib/v1/payments/order_capture_request.rb +35 -0
- data/lib/v1/payments/order_get_request.rb +31 -0
- data/lib/v1/payments/order_void_request.rb +31 -0
- data/lib/v1/payments/payment_create_request.rb +33 -0
- data/lib/v1/payments/payment_execute_request.rb +35 -0
- data/lib/v1/payments/payment_get_request.rb +31 -0
- data/lib/v1/payments/payment_list_request.rb +69 -0
- data/lib/v1/payments/payment_update_request.rb +35 -0
- data/lib/v1/payments/refund_get_request.rb +31 -0
- data/lib/v1/payments/sale_get_request.rb +31 -0
- data/lib/v1/payments/sale_refund_request.rb +35 -0
- data/lib/v1/sync/search_get_request.rb +99 -0
- data/lib/v1/vault/credit_card_create_request.rb +33 -0
- data/lib/v1/vault/credit_card_delete_request.rb +31 -0
- data/lib/v1/vault/credit_card_get_request.rb +31 -0
- data/lib/v1/vault/credit_card_list_request.rb +79 -0
- data/lib/v1/vault/credit_card_update_request.rb +35 -0
- data/lib/v1/webhooks/available_event_type_list_request.rb +29 -0
- data/lib/v1/webhooks/event_get_request.rb +31 -0
- data/lib/v1/webhooks/event_list_request.rb +54 -0
- data/lib/v1/webhooks/event_resend_request.rb +35 -0
- data/lib/v1/webhooks/simulate_event_request.rb +33 -0
- data/lib/v1/webhooks/webhook_create_request.rb +33 -0
- data/lib/v1/webhooks/webhook_delete_request.rb +31 -0
- data/lib/v1/webhooks/webhook_get_request.rb +31 -0
- data/lib/v1/webhooks/webhook_list_event_subscriptions_request.rb +31 -0
- data/lib/v1/webhooks/webhook_list_request.rb +34 -0
- data/lib/v1/webhooks/webhook_update_request.rb +35 -0
- data/lib/v1/webhooks/webhook_verify_signature_request.rb +33 -0
- data/spec/integration/test_harness.rb +25 -0
- data/spec/integration/v1/billing_agreements/agreement_create_spec.rb +63 -0
- data/spec/integration/v1/billing_plans/plan_create_spec.rb +12 -0
- data/spec/integration/v1/billing_plans/plan_get_spec.rb +16 -0
- data/spec/integration/v1/billing_plans/plan_helper.rb +71 -0
- data/spec/integration/v1/billing_plans/plan_list_spec.rb +16 -0
- data/spec/integration/v1/billing_plans/plan_update_spec.rb +19 -0
- data/spec/integration/v1/identity/userinfo_get_spec.rb +65 -0
- data/spec/integration/v1/invoices/invoice_cancel_spec.rb +23 -0
- data/spec/integration/v1/invoices/invoice_create_spec.rb +15 -0
- data/spec/integration/v1/invoices/invoice_delete_external_payment_spec.rb +23 -0
- data/spec/integration/v1/invoices/invoice_delete_external_refund_spec.rb +21 -0
- data/spec/integration/v1/invoices/invoice_delete_spec.rb +16 -0
- data/spec/integration/v1/invoices/invoice_get_spec.rb +18 -0
- data/spec/integration/v1/invoices/invoice_helper.rb +171 -0
- data/spec/integration/v1/invoices/invoice_list_spec.rb +20 -0
- data/spec/integration/v1/invoices/invoice_next_invoice_number_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_qr_code_spec.rb +18 -0
- data/spec/integration/v1/invoices/invoice_record_payment_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_record_refund_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_remind_spec.rb +22 -0
- data/spec/integration/v1/invoices/invoice_search_spec.rb +20 -0
- data/spec/integration/v1/invoices/invoice_send_spec.rb +15 -0
- data/spec/integration/v1/invoices/invoice_update_spec.rb +26 -0
- data/spec/integration/v1/invoices/template_create_spec.rb +14 -0
- data/spec/integration/v1/invoices/template_delete_spec.rb +15 -0
- data/spec/integration/v1/invoices/template_get_spec.rb +18 -0
- data/spec/integration/v1/invoices/template_list_spec.rb +15 -0
- data/spec/integration/v1/invoices/template_update_spec.rb +62 -0
- data/spec/integration/v1/orders/orders_cancel_spec.rb +15 -0
- data/spec/integration/v1/orders/orders_create_spec.rb +17 -0
- data/spec/integration/v1/orders/orders_get_spec.rb +18 -0
- data/spec/integration/v1/orders/orders_helper.rb +36 -0
- data/spec/integration/v1/orders/orders_pay_spec.rb +19 -0
- data/spec/integration/v1/payment_experience/pe_helper.rb +35 -0
- data/spec/integration/v1/payment_experience/web_profile_create_spec.rb +20 -0
- data/spec/integration/v1/payment_experience/web_profile_delete_spec.rb +15 -0
- data/spec/integration/v1/payment_experience/web_profile_get_spec.rb +17 -0
- data/spec/integration/v1/payment_experience/web_profile_list_spec.rb +18 -0
- data/spec/integration/v1/payment_experience/web_profile_partial_update_spec.rb +32 -0
- data/spec/integration/v1/payment_experience/web_profile_update_spec.rb +44 -0
- data/spec/integration/v1/payments/authorization_capture_spec.rb +17 -0
- data/spec/integration/v1/payments/authorization_get_spec.rb +18 -0
- data/spec/integration/v1/payments/authorization_reauthorize_spec.rb +26 -0
- data/spec/integration/v1/payments/authorization_void_spec.rb +19 -0
- data/spec/integration/v1/payments/capture_get_spec.rb +20 -0
- data/spec/integration/v1/payments/capture_refund_spec.rb +27 -0
- data/spec/integration/v1/payments/order_authorize_spec.rb +20 -0
- data/spec/integration/v1/payments/order_capture_spec.rb +21 -0
- data/spec/integration/v1/payments/order_get_spec.rb +14 -0
- data/spec/integration/v1/payments/order_void_spec.rb +14 -0
- data/spec/integration/v1/payments/payment_create_spec.rb +13 -0
- data/spec/integration/v1/payments/payment_execute_spec.rb +19 -0
- data/spec/integration/v1/payments/payment_get_spec.rb +17 -0
- data/spec/integration/v1/payments/payment_list_spec.rb +16 -0
- data/spec/integration/v1/payments/payment_update_spec.rb +28 -0
- data/spec/integration/v1/payments/payments_helper.rb +72 -0
- data/spec/integration/v1/payments/refund_get_spec.rb +19 -0
- data/spec/integration/v1/payments/sale_get_spec.rb +18 -0
- data/spec/integration/v1/payments/sale_refund_spec.rb +18 -0
- data/spec/integration/v1/sync/search_get_spec.rb +34 -0
- data/spec/integration/v1/vault/credit_card_create_spec.rb +16 -0
- data/spec/integration/v1/vault/credit_card_delete_spec.rb +16 -0
- data/spec/integration/v1/vault/credit_card_get_spec.rb +17 -0
- data/spec/integration/v1/vault/credit_card_list_spec.rb +18 -0
- data/spec/integration/v1/vault/credit_card_update_spec.rb +26 -0
- data/spec/integration/v1/vault/vault_helper.rb +28 -0
- data/spec/integration/v1/webhooks/available_event_type_list_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_create_spec.rb +12 -0
- data/spec/integration/v1/webhooks/webhook_delete_spec.rb +13 -0
- data/spec/integration/v1/webhooks/webhook_get_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_helper.rb +43 -0
- data/spec/integration/v1/webhooks/webhook_list_event_subscriptions_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_list_spec.rb +15 -0
- data/spec/integration/v1/webhooks/webhook_update_spec.rb +29 -0
- data/spec/integration/v1/webhooks/webhook_verify_signature_spec.rb +20 -0
- data/spec/spec_helper.rb +97 -28
- data/spec/unit/paypal_http_client_spec.rb +264 -0
- metadata +250 -120
- data/Rakefile +0 -15
- data/data/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/data/DigiCertSHA2ExtendedValidationServerCA.pem +0 -28
- data/data/paypal.crt +0 -171
- data/lib/generators/paypal/sdk/USAGE +0 -3
- data/lib/generators/paypal/sdk/install_generator.rb +0 -17
- data/lib/generators/paypal/sdk/templates/paypal.rb +0 -2
- data/lib/generators/paypal/sdk/templates/paypal.yml +0 -29
- data/lib/paypal-sdk-core.rb +0 -38
- data/lib/paypal-sdk-rest.rb +0 -2
- data/lib/paypal-sdk/core/api.rb +0 -20
- data/lib/paypal-sdk/core/api/base.rb +0 -169
- data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +0 -44
- data/lib/paypal-sdk/core/api/data_types/base.rb +0 -225
- data/lib/paypal-sdk/core/api/data_types/enum.rb +0 -26
- data/lib/paypal-sdk/core/api/data_types/simple_types.rb +0 -52
- data/lib/paypal-sdk/core/api/ipn.rb +0 -66
- data/lib/paypal-sdk/core/api/rest.rb +0 -177
- data/lib/paypal-sdk/core/authentication.rb +0 -66
- data/lib/paypal-sdk/core/config.rb +0 -253
- data/lib/paypal-sdk/core/credential.rb +0 -16
- data/lib/paypal-sdk/core/credential/base.rb +0 -27
- data/lib/paypal-sdk/core/credential/certificate.rb +0 -32
- data/lib/paypal-sdk/core/credential/signature.rb +0 -22
- data/lib/paypal-sdk/core/credential/third_party/subject.rb +0 -25
- data/lib/paypal-sdk/core/credential/third_party/token.rb +0 -39
- data/lib/paypal-sdk/core/exceptions.rb +0 -112
- data/lib/paypal-sdk/core/logging.rb +0 -50
- data/lib/paypal-sdk/core/openid_connect.rb +0 -140
- data/lib/paypal-sdk/core/openid_connect/api.rb +0 -50
- data/lib/paypal-sdk/core/openid_connect/data_types.rb +0 -73
- data/lib/paypal-sdk/core/openid_connect/get_api.rb +0 -28
- data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +0 -52
- data/lib/paypal-sdk/core/openid_connect/set_api.rb +0 -36
- data/lib/paypal-sdk/core/util.rb +0 -11
- data/lib/paypal-sdk/core/util/http_helper.rb +0 -171
- data/lib/paypal-sdk/core/util/oauth_signature.rb +0 -64
- data/lib/paypal-sdk/core/util/ordered_hash.rb +0 -165
- data/lib/paypal-sdk/rest.rb +0 -39
- data/lib/paypal-sdk/rest/api.rb +0 -23
- data/lib/paypal-sdk/rest/data_types.rb +0 -2597
- data/lib/paypal-sdk/rest/error_hash.rb +0 -39
- data/lib/paypal-sdk/rest/get_api.rb +0 -20
- data/lib/paypal-sdk/rest/request_data_type.rb +0 -53
- data/lib/paypal-sdk/rest/set_api.rb +0 -42
- data/lib/paypal-sdk/rest/version.rb +0 -7
- data/spec/README.md +0 -22
- data/spec/config/cacert.pem +0 -171
- data/spec/config/cert_key.pem +0 -33
- data/spec/config/paypal.yml +0 -35
- data/spec/config/sample_data.yml +0 -3
- data/spec/core/api/data_type_spec.rb +0 -289
- data/spec/core/api/rest_spec.rb +0 -211
- data/spec/core/config_spec.rb +0 -192
- data/spec/core/logging_spec.rb +0 -28
- data/spec/core/openid_connect_spec.rb +0 -153
- data/spec/invoice_examples_spec.rb +0 -38
- data/spec/payments_examples_spec.rb +0 -437
- data/spec/payouts_examples_spec.rb +0 -74
- data/spec/rest/data_types_spec.rb +0 -62
- data/spec/rest/error_hash_spec.rb +0 -83
- data/spec/subscription_examples_spec.rb +0 -227
- data/spec/support/sample_data.rb +0 -5
- data/spec/web_profile_examples_spec.rb +0 -106
- data/spec/webhooks_examples_spec.rb +0 -93
@@ -1,66 +0,0 @@
|
|
1
|
-
|
2
|
-
module PayPal::SDK::Core
|
3
|
-
|
4
|
-
# Contains methods to format credentials for HTTP protocol.
|
5
|
-
# == Example
|
6
|
-
# include Authentication
|
7
|
-
# credential(url)
|
8
|
-
# base_credential
|
9
|
-
# third_party_credential(url)
|
10
|
-
#
|
11
|
-
# add_certificate(http)
|
12
|
-
module Authentication
|
13
|
-
|
14
|
-
include Configuration
|
15
|
-
|
16
|
-
# Get credential object
|
17
|
-
# === Argument
|
18
|
-
# * <tt>url</tt> -- API request url
|
19
|
-
def credential(url)
|
20
|
-
third_party_credential(url) || base_credential
|
21
|
-
end
|
22
|
-
|
23
|
-
# Get base credential
|
24
|
-
def base_credential
|
25
|
-
@base_credential ||=
|
26
|
-
if config.cert_path
|
27
|
-
Credential::Certificate.new(config)
|
28
|
-
else
|
29
|
-
Credential::Signature.new(config)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Get base credential type
|
34
|
-
def base_credential_type
|
35
|
-
config.cert_path ? :certificate : :three_token
|
36
|
-
end
|
37
|
-
|
38
|
-
# Get third party credential
|
39
|
-
def third_party_credential(url)
|
40
|
-
if config.token and config.token_secret
|
41
|
-
Credential::ThirdParty::Token.new(base_credential, config, url)
|
42
|
-
elsif config.subject
|
43
|
-
Credential::ThirdParty::Subject.new(base_credential, config)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Clear cached variables on changing the configuration.
|
48
|
-
def set_config(*args)
|
49
|
-
@base_credential = nil
|
50
|
-
super
|
51
|
-
end
|
52
|
-
|
53
|
-
# Configure ssl certificate to HTTP object
|
54
|
-
# === Argument
|
55
|
-
# * <tt>http</tt> -- Net::HTTP object
|
56
|
-
def add_certificate(http)
|
57
|
-
if base_credential.is_a? Credential::Certificate
|
58
|
-
http.cert = base_credential.cert
|
59
|
-
http.key = base_credential.key
|
60
|
-
else
|
61
|
-
http.cert = nil
|
62
|
-
http.key = nil
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,253 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
module PayPal::SDK::Core
|
5
|
-
|
6
|
-
# Include Configuration module to access configuration from any object
|
7
|
-
# == Examples
|
8
|
-
# # Include in any class
|
9
|
-
# include Configuration
|
10
|
-
#
|
11
|
-
# # Access config object and attributes
|
12
|
-
# config
|
13
|
-
# config.username
|
14
|
-
#
|
15
|
-
# # Change configuration
|
16
|
-
# set_config(:development)
|
17
|
-
module Configuration
|
18
|
-
|
19
|
-
# To get default Config object.
|
20
|
-
def config
|
21
|
-
@config ||= Config.config
|
22
|
-
end
|
23
|
-
|
24
|
-
# To change the configuration to given environment or configuration
|
25
|
-
# === Arguments
|
26
|
-
# * <tt>env</tt> -- Environment
|
27
|
-
# * <tt>override_configurations</tt> (Optional) -- To override the default configuration.
|
28
|
-
# === Examples
|
29
|
-
# obj.set_config(api.config)
|
30
|
-
# obj.set_config(:http_timeout => 30)
|
31
|
-
# obj.set_config(:development)
|
32
|
-
# obj.set_config(:development, :http_timeout => 30)
|
33
|
-
def set_config(env, override_configurations = {})
|
34
|
-
@config =
|
35
|
-
case env
|
36
|
-
when Config
|
37
|
-
env
|
38
|
-
when Hash
|
39
|
-
begin
|
40
|
-
config.dup.merge!(env)
|
41
|
-
rescue Errno::ENOENT => error
|
42
|
-
Config.new(env)
|
43
|
-
end
|
44
|
-
else
|
45
|
-
Config.config(env, override_configurations)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
alias_method :config=, :set_config
|
50
|
-
end
|
51
|
-
|
52
|
-
# Config class is used to hold the configurations.
|
53
|
-
# == Examples
|
54
|
-
# # To load configurations from file
|
55
|
-
# Config.load('config/paypal.yml', 'development')
|
56
|
-
#
|
57
|
-
# # Get configuration
|
58
|
-
# Config.config # load default configuration
|
59
|
-
# Config.config(:development) # load development configuration
|
60
|
-
# Config.config(:development, :app_id => "XYZ") # Override configuration
|
61
|
-
#
|
62
|
-
# # Read configuration attributes
|
63
|
-
# config = Config.config
|
64
|
-
# config.username
|
65
|
-
# config.endpoint
|
66
|
-
class Config
|
67
|
-
|
68
|
-
include Logging
|
69
|
-
include Exceptions
|
70
|
-
|
71
|
-
attr_accessor :username, :password, :signature, :app_id, :cert_path,
|
72
|
-
:token, :token_secret, :subject,
|
73
|
-
:http_timeout, :http_proxy,
|
74
|
-
:device_ipaddress, :sandbox_email_address,
|
75
|
-
:mode, :endpoint, :merchant_endpoint, :platform_endpoint, :ipn_endpoint,
|
76
|
-
:rest_endpoint, :rest_token_endpoint, :client_id, :client_secret,
|
77
|
-
:openid_endpoint, :openid_redirect_uri, :openid_client_id, :openid_client_secret,
|
78
|
-
:verbose_logging
|
79
|
-
|
80
|
-
alias_method :end_point=, :endpoint=
|
81
|
-
alias_method :end_point, :endpoint
|
82
|
-
alias_method :platform_end_point=, :platform_endpoint=
|
83
|
-
alias_method :platform_end_point, :platform_endpoint
|
84
|
-
alias_method :merchant_end_point=, :merchant_endpoint=
|
85
|
-
alias_method :merchant_end_point, :merchant_endpoint
|
86
|
-
alias_method :ipn_end_point=, :ipn_endpoint=
|
87
|
-
alias_method :ipn_end_point, :ipn_endpoint
|
88
|
-
alias_method :rest_end_point, :rest_endpoint
|
89
|
-
alias_method :rest_end_point=, :rest_endpoint=
|
90
|
-
alias_method :rest_token_end_point, :rest_token_endpoint
|
91
|
-
alias_method :rest_token_end_point=, :rest_token_endpoint=
|
92
|
-
|
93
|
-
# Create Config object
|
94
|
-
# === Options(Hash)
|
95
|
-
# * <tt>username</tt> -- Username
|
96
|
-
# * <tt>password</tt> -- Password
|
97
|
-
# * <tt>signature</tt> (Optional if certificate present) -- Signature
|
98
|
-
# * <tt>app_id</tt> -- Application ID
|
99
|
-
# * <tt>cert_path</tt> (Optional if signature present) -- Certificate file path
|
100
|
-
def initialize(options)
|
101
|
-
merge!(options)
|
102
|
-
end
|
103
|
-
|
104
|
-
def logfile=(filename)
|
105
|
-
logger.warn '`logfile=` is deprecated, Please use `PayPal::SDK::Core::Config.logger = Logger.new(STDERR)`'
|
106
|
-
end
|
107
|
-
|
108
|
-
def redirect_url=(redirect_url)
|
109
|
-
logger.warn '`redirect_url=` is deprecated.'
|
110
|
-
end
|
111
|
-
|
112
|
-
def dev_central_url=(dev_central_url)
|
113
|
-
logger.warn '`dev_central_url=` is deprecated.'
|
114
|
-
end
|
115
|
-
|
116
|
-
def ssl_options
|
117
|
-
@ssl_options ||= {}.freeze
|
118
|
-
end
|
119
|
-
|
120
|
-
def ssl_options=(options)
|
121
|
-
options = Hash[options.map{|key, value| [key.to_sym, value] }]
|
122
|
-
@ssl_options = ssl_options.merge(options).freeze
|
123
|
-
end
|
124
|
-
|
125
|
-
def ca_file=(ca_file)
|
126
|
-
logger.warn '`ca_file=` is deprecated, Please configure `ca_file=` under `ssl_options`'
|
127
|
-
self.ssl_options = { :ca_file => ca_file }
|
128
|
-
end
|
129
|
-
|
130
|
-
def http_verify_mode=(verify_mode)
|
131
|
-
logger.warn '`http_verify_mode=` is deprecated, Please configure `verify_mode=` under `ssl_options`'
|
132
|
-
self.ssl_options = { :verify_mode => verify_mode }
|
133
|
-
end
|
134
|
-
|
135
|
-
# Override configurations
|
136
|
-
def merge!(options)
|
137
|
-
options.each do |key, value|
|
138
|
-
send("#{key}=", value)
|
139
|
-
end
|
140
|
-
self
|
141
|
-
end
|
142
|
-
|
143
|
-
# Validate required configuration
|
144
|
-
def required!(*names)
|
145
|
-
names = names.select{|name| send(name).nil? }
|
146
|
-
raise MissingConfig.new("Required configuration(#{names.join(", ")})") if names.any?
|
147
|
-
end
|
148
|
-
|
149
|
-
class << self
|
150
|
-
|
151
|
-
@@config_cache = {}
|
152
|
-
|
153
|
-
# Load configurations from file
|
154
|
-
# === Arguments
|
155
|
-
# * <tt>file_name</tt> -- Configuration file path
|
156
|
-
# * <tt>default_environment</tt> (Optional) -- default environment configuration to load
|
157
|
-
# === Example
|
158
|
-
# Config.load('config/paypal.yml', 'development')
|
159
|
-
def load(file_name, default_env = default_environment)
|
160
|
-
@@config_cache = {}
|
161
|
-
@@configurations = read_configurations(file_name)
|
162
|
-
@@default_environment = default_env
|
163
|
-
config
|
164
|
-
end
|
165
|
-
|
166
|
-
# Get default environment name
|
167
|
-
def default_environment
|
168
|
-
@@default_environment ||= ENV['PAYPAL_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || "development"
|
169
|
-
end
|
170
|
-
|
171
|
-
# Set default environment
|
172
|
-
def default_environment=(env)
|
173
|
-
@@default_environment = env.to_s
|
174
|
-
end
|
175
|
-
|
176
|
-
def configure(options = {}, &block)
|
177
|
-
begin
|
178
|
-
self.config.merge!(options)
|
179
|
-
rescue Errno::ENOENT
|
180
|
-
self.configurations = { default_environment => options }
|
181
|
-
end
|
182
|
-
block.call(self.config) if block
|
183
|
-
self.config
|
184
|
-
end
|
185
|
-
alias_method :set_config, :configure
|
186
|
-
|
187
|
-
# Create or Load Config object based on given environment and configurations.
|
188
|
-
# === Attributes
|
189
|
-
# * <tt>env</tt> (Optional) -- Environment name
|
190
|
-
# * <tt>override_configuration</tt> (Optional) -- Override the configuration given in file.
|
191
|
-
# === Example
|
192
|
-
# Config.config
|
193
|
-
# Config.config(:development)
|
194
|
-
# Config.config(:development, { :app_id => "XYZ" })
|
195
|
-
def config(env = default_environment, override_configuration = {})
|
196
|
-
if env.is_a? Hash
|
197
|
-
override_configuration = env
|
198
|
-
env = default_environment
|
199
|
-
end
|
200
|
-
if override_configuration.nil? or override_configuration.empty?
|
201
|
-
default_config(env)
|
202
|
-
else
|
203
|
-
default_config(env).dup.merge!(override_configuration)
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
def default_config(env = nil)
|
208
|
-
env = (env || default_environment).to_s
|
209
|
-
if configurations[env]
|
210
|
-
@@config_cache[env] ||= new(configurations[env])
|
211
|
-
else
|
212
|
-
raise Exceptions::MissingConfig.new("Configuration[#{env}] NotFound")
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
# Set logger
|
217
|
-
def logger=(logger)
|
218
|
-
Logging.logger = logger
|
219
|
-
end
|
220
|
-
|
221
|
-
# Get logger
|
222
|
-
def logger
|
223
|
-
if @@configurations[:mode] == 'live' and Logging.logger.level == Logger::DEBUG
|
224
|
-
Logging.logger.warn "DEBUG log level not allowed in live mode for security of confidential information. Changing log level to INFO..."
|
225
|
-
Logging.logger.level = Logger::INFO
|
226
|
-
end
|
227
|
-
Logging.logger
|
228
|
-
end
|
229
|
-
|
230
|
-
# Get raw configurations in Hash format.
|
231
|
-
def configurations
|
232
|
-
@@configurations ||= read_configurations
|
233
|
-
end
|
234
|
-
|
235
|
-
# Set configuration
|
236
|
-
def configurations=(configs)
|
237
|
-
@@config_cache = {}
|
238
|
-
@@configurations = configs && Hash[configs.map{|k,v| [k.to_s, v] }]
|
239
|
-
end
|
240
|
-
|
241
|
-
private
|
242
|
-
# Read configurations from the given file name
|
243
|
-
# === Arguments
|
244
|
-
# * <tt>file_name</tt> (Optional) -- Configuration file path
|
245
|
-
def read_configurations(file_name = "config/paypal.yml")
|
246
|
-
erb = ERB.new(File.read(file_name))
|
247
|
-
erb.filename = file_name
|
248
|
-
YAML.load(erb.result)
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module PayPal
|
2
|
-
module SDK
|
3
|
-
module Core
|
4
|
-
module Credential
|
5
|
-
autoload :Base, "paypal-sdk/core/credential/base"
|
6
|
-
autoload :Certificate, "paypal-sdk/core/credential/certificate"
|
7
|
-
autoload :Signature, "paypal-sdk/core/credential/signature"
|
8
|
-
|
9
|
-
module ThirdParty
|
10
|
-
autoload :Token, "paypal-sdk/core/credential/third_party/token"
|
11
|
-
autoload :Subject, "paypal-sdk/core/credential/third_party/subject"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module PayPal::SDK::Core
|
2
|
-
module Credential
|
3
|
-
|
4
|
-
# Base credential Class for authentication
|
5
|
-
class Base
|
6
|
-
attr_accessor :username, :password, :app_id, :device_ipaddress, :sandbox_email_address
|
7
|
-
|
8
|
-
# Initialize authentication configurations
|
9
|
-
# === Arguments
|
10
|
-
# * <tt>config</tt> -- Configuration object
|
11
|
-
def initialize(config)
|
12
|
-
self.username = config.username
|
13
|
-
self.password = config.password
|
14
|
-
self.app_id = config.app_id
|
15
|
-
self.device_ipaddress = config.device_ipaddress
|
16
|
-
self.sandbox_email_address = config.sandbox_email_address
|
17
|
-
end
|
18
|
-
|
19
|
-
# Return credential properties
|
20
|
-
def properties
|
21
|
-
{ :username => username, :password => password, :app_id => app_id,
|
22
|
-
:device_ipaddress => device_ipaddress, :sandbox_email_address => sandbox_email_address }
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module PayPal::SDK::Core
|
2
|
-
module Credential
|
3
|
-
|
4
|
-
# Certificate class for SSL Certificate authentication
|
5
|
-
class Certificate < Base
|
6
|
-
|
7
|
-
attr_reader :cert_path
|
8
|
-
|
9
|
-
def initialize(config)
|
10
|
-
super
|
11
|
-
@cert_path = config.cert_path
|
12
|
-
end
|
13
|
-
|
14
|
-
# Return SSL certificate
|
15
|
-
def cert
|
16
|
-
@cert ||= OpenSSL::X509::Certificate.new(cert_content)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Return SSL certificate key
|
20
|
-
def key
|
21
|
-
@key = OpenSSL::PKey::RSA.new(cert_content)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
# Return certificate content from the configured file.
|
26
|
-
def cert_content
|
27
|
-
@cert_content ||= File.read(cert_path)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module PayPal::SDK::Core
|
2
|
-
module Credential
|
3
|
-
class Signature < Base
|
4
|
-
|
5
|
-
attr_accessor :signature
|
6
|
-
|
7
|
-
# Initialize configuration
|
8
|
-
# === Argument
|
9
|
-
# * <tt>config</tt> -- Configuration object
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
self.signature = config.signature
|
13
|
-
end
|
14
|
-
|
15
|
-
# Return properties for authentication
|
16
|
-
def properties
|
17
|
-
super.merge({ :signature => signature })
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module PayPal::SDK::Core
|
2
|
-
module Credential
|
3
|
-
module ThirdParty
|
4
|
-
class Subject
|
5
|
-
|
6
|
-
attr_accessor :subject, :credential
|
7
|
-
|
8
|
-
# Initialize configuration
|
9
|
-
# === Arguments
|
10
|
-
# * <tt>credential</tt> -- Credential object
|
11
|
-
# * <tt>config</tt> -- Configuration object
|
12
|
-
def initialize(credential, config)
|
13
|
-
@credential = credential
|
14
|
-
@subject = config.subject
|
15
|
-
end
|
16
|
-
|
17
|
-
# Return properties for authentication.
|
18
|
-
def properties
|
19
|
-
credential.properties.merge( :subject => subject )
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|