Sha256: 460d1e7de72dad4bb8b574ad4c56a245d4a8a43f8c85ee97f4e20f50d04b6624

Contents?: true

Size: 1.36 KB

Versions: 8

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

8 entries across 8 versions & 1 rubygems

Version Path
braintree-3.3.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-3.2.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-3.1.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-3.0.1 lib/braintree/payment_method_nonce_gateway.rb
braintree-2.104.1 lib/braintree/payment_method_nonce_gateway.rb
braintree-2.104.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-2.103.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-2.102.0 lib/braintree/payment_method_nonce_gateway.rb