Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #245 from tvdeyen/configure-timeouts
Browse files Browse the repository at this point in the history
Make http open and read timeouts configurable
  • Loading branch information
spaghetticode authored Jan 10, 2020
2 parents af58f37 + df6d02f commit 6d22350
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/solidus_paypal_braintree/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class Gateway < ::Spree::PaymentMethod
preference(:merchant_id, :string, default: nil)
preference(:public_key, :string, default: nil)
preference(:private_key, :string, default: nil)
preference(:http_open_timeout, :integer, default: 60)
preference(:http_read_timeout, :integer, default: 60)
preference(:merchant_currency_map, :hash, default: {})
preference(:paypal_payee_email_map, :hash, default: {})

Expand All @@ -60,6 +62,8 @@ def gateway_options
merchant_id: preferred_merchant_id,
public_key: preferred_public_key,
private_key: preferred_private_key,
http_open_timeout: preferred_http_open_timeout,
http_read_timeout: preferred_http_read_timeout,
logger: logger
}
end
Expand Down
14 changes: 14 additions & 0 deletions spec/models/solidus_paypal_braintree/gateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@
it { is_expected.to eq "paypal_braintree" }
end

describe '#gateway_options' do
subject(:gateway_options) { gateway.gateway_options }

it 'includes http_open_timeout' do
is_expected.to have_key(:http_open_timeout)
expect(gateway_options[:http_open_timeout]).to eq(60)
end

it 'includes http_read_timeout' do
is_expected.to have_key(:http_read_timeout)
expect(gateway_options[:http_read_timeout]).to eq(60)
end
end

describe '#purchase' do
subject(:purchase) { gateway.purchase(1000, source, gateway_options) }

Expand Down

0 comments on commit 6d22350

Please sign in to comment.