Class: Braintree::PaymentMethodNonceGateway

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/payment_method_nonce_gateway.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

#initialize(gateway) ⇒ PaymentMethodNonceGateway

Returns a new instance of PaymentMethodNonceGateway.


5
6
7
8
9
# File 'lib/braintree/payment_method_nonce_gateway.rb', line 5

def initialize(gateway)
  @gateway = gateway
  @config = gateway.config
  @config.assert_has_access_token_or_keys
end

Class Method Details

._create_signatureObject


19
20
21
22
23
24
25
26
# File 'lib/braintree/payment_method_nonce_gateway.rb', line 19

def self._create_signature
  [ {
    :payment_method_nonce=> [
      :merchant_account_id, :authentication_insight,
      {:authentication_insight_options => [:amount, :recurring_customer_consent, :recurring_max_amount]}
    ]
  }]
end

Instance Method Details

#create(payment_method_token, args = {payment_method_nonce: {}}) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/braintree/payment_method_nonce_gateway.rb', line 11

def create(payment_method_token, args = {payment_method_nonce: {}})
  Util.verify_keys(PaymentMethodNonceGateway._create_signature, args)

  response = @config.http.post("#{@config.base_merchant_path}/payment_methods/#{payment_method_token}/nonces", args)
  payment_method_nonce = PaymentMethodNonce._new(@gateway, response.fetch(:payment_method_nonce))
  SuccessfulResult.new(:payment_method_nonce => payment_method_nonce)
end

#create!(*args) ⇒ Object


28
29
30
# File 'lib/braintree/payment_method_nonce_gateway.rb', line 28

def create!(*args)
  return_object_or_raise(:payment_method_nonce) { create(*args) }
end

#find(payment_method_nonce) ⇒ Object


32
33
34
35
36
# File 'lib/braintree/payment_method_nonce_gateway.rb', line 32

def find(payment_method_nonce)
  response = @config.http.get("#{@config.base_merchant_path}/payment_method_nonces/#{payment_method_nonce}")
  payment_method_nonce = PaymentMethodNonce._new(@gateway, response.fetch(:payment_method_nonce))
  SuccessfulResult.new(:payment_method_nonce => payment_method_nonce)
end