Sha256: d2c964cf526c05581d8932999a4477c09d1842719afe5f297a4b775a7c770427

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

module Braintree
  class PaymentMethodNonceGateway
    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-4.23.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.22.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.21.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.20.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.19.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.18.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.17.0 lib/braintree/payment_method_nonce_gateway.rb
braintree-4.16.0 lib/braintree/payment_method_nonce_gateway.rb