Sha256: 68670649ef79f440a9b9f674df566dade17d9efef69aca867cda8d03cd3e6eed

Contents?: true

Size: 1.36 KB

Versions: 17

Compression:

Stored size: 1.36 KB

Contents

module Braintree
  class PaymentMethodNonceGateway # :nodoc:
    include BaseModule

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

    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

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

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

    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
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
braintree-4.15.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.14.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.13.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.12.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.11.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.10.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.9.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.8.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.7.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.6.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.5.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.4.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.3.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.2.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.1.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.0.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-3.4.0 lib/braintree/payment_method_nonce_gateway.rb