Class: Braintree::PayPalAccountGateway
- Inherits:
-
Object
- Object
- Braintree::PayPalAccountGateway
- Defined in:
- lib/braintree/paypal_account_gateway.rb
Class Method Summary collapse
Instance Method Summary collapse
- #_do_create(path, params) ⇒ Object
- #_do_update(http_verb, path, params) ⇒ Object
- #create(attributes) ⇒ Object
- #delete(token) ⇒ Object
- #find(token) ⇒ Object
-
#initialize(gateway) ⇒ PayPalAccountGateway
constructor
A new instance of PayPalAccountGateway.
- #update(token, attributes) ⇒ Object
Constructor Details
#initialize(gateway) ⇒ PayPalAccountGateway
Returns a new instance of PayPalAccountGateway.
3 4 5 6 7 |
# File 'lib/braintree/paypal_account_gateway.rb', line 3 def initialize(gateway) @gateway = gateway @config = gateway.config @config.assert_has_access_token_or_keys end |
Class Method Details
._create_nested_signature ⇒ Object
61 62 63 64 65 66 |
# File 'lib/braintree/paypal_account_gateway.rb', line 61 def self._create_nested_signature [ :email, :token, :billing_agreement_id, {:options => [:make_default]} ] end |
._create_signature ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/braintree/paypal_account_gateway.rb', line 53 def self._create_signature = [:fail_on_duplicate_payment_method, :make_default] [ :email, :token, :billing_agreement_id, :customer_id, {:options => }, ] end |
._update_signature ⇒ Object
68 69 70 71 |
# File 'lib/braintree/paypal_account_gateway.rb', line 68 def self._update_signature = [:fail_on_duplicate_payment_method, :make_default] [:email, :token, :billing_agreement_id, {:options => }] end |
Instance Method Details
#_do_create(path, params) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/braintree/paypal_account_gateway.rb', line 31 def _do_create(path, params) response = @config.http.post("#{@config.base_merchant_path}#{path}", params) if response[:paypal_account] SuccessfulResult.new(:paypal_account => PayPalAccount._new(@gateway, response[:paypal_account])) elsif response[:api_error_response] ErrorResult.new(@gateway, response[:api_error_response]) else raise UnexpectedError, "expected :paypal_account or :api_error_response" end end |
#_do_update(http_verb, path, params) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/braintree/paypal_account_gateway.rb', line 42 def _do_update(http_verb, path, params) response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", params) if response[:paypal_account] SuccessfulResult.new(:paypal_account => PayPalAccount._new(@gateway, response[:paypal_account])) elsif response[:api_error_response] ErrorResult.new(@gateway, response[:api_error_response]) else raise UnexpectedError, "expected :paypal_account or :api_error_response" end end |
#create(attributes) ⇒ Object
17 18 19 20 |
# File 'lib/braintree/paypal_account_gateway.rb', line 17 def create(attributes) Util.verify_keys(PayPalAccountGateway._create_signature, attributes) _do_create("/payment_methods", :paypal_account => attributes) end |
#delete(token) ⇒ Object
27 28 29 |
# File 'lib/braintree/paypal_account_gateway.rb', line 27 def delete(token) @config.http.delete("#{@config.base_merchant_path}/payment_methods/paypal_account/#{token}") end |
#find(token) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/braintree/paypal_account_gateway.rb', line 9 def find(token) raise ArgumentError if token.nil? || token.to_s.strip == "" response = @config.http.get("#{@config.base_merchant_path}/payment_methods/paypal_account/#{token}") PayPalAccount._new(@gateway, response[:paypal_account]) rescue NotFoundError raise NotFoundError, "payment method with token #{token.inspect} not found" end |
#update(token, attributes) ⇒ Object
22 23 24 25 |
# File 'lib/braintree/paypal_account_gateway.rb', line 22 def update(token, attributes) Util.verify_keys(PayPalAccountGateway._update_signature, attributes) _do_update(:put, "/payment_methods/paypal_account/#{token}", :paypal_account => attributes) end |