Class: Remit::API

Constant Summary collapse

API_ENDPOINT =
'https://fps.amazonaws.com/'.freeze
API_SANDBOX_ENDPOINT =
'https://fps.sandbox.amazonaws.com/'.freeze
PIPELINE_URL =
'https://authorize.payments.amazon.com/cobranded-ui/actions/start'.freeze
PIPELINE_SANDBOX_URL =
'https://authorize.payments-sandbox.amazon.com/cobranded-ui/actions/start'.freeze
API_VERSION =
Date.new(2008, 9, 17).to_s.freeze
PIPELINE_VERSION =
Date.new(2009, 1, 9).to_s.freeze
SIGNATURE_VERSION =
2.freeze
SIGNATURE_METHOD =
"HmacSHA256".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from WriteOffDebt

#write_off_debt

Methods included from UnsubscribeForCallerNotification

#unsubscribe_for_caller_notification

Methods included from SubscribeForCallerNotification

#subscribe_for_caller_notification

Methods included from SettleDebt

#settle_debt

Methods included from Settle

#settle

Methods included from Reserve

#reserve

Methods included from Refund

#refund

Methods included from Pay

#pay

Methods included from InstallPaymentInstruction

#install_payment_instruction

Methods included from GetTransaction

#get_transaction

Methods included from GetTotalPrepaidLiability

#get_total_prepaid_liability

Methods included from GetTokenByCaller

#get_token_by_caller

Methods included from GetTokens

#get_tokens

Methods included from GetTokenUsage

#get_token_usage

Methods included from GetRecipientVerificationStatus

#get_recipient_verification_status

Methods included from GetPrepaidBalance

#get_prepaid_balance

Methods included from GetPipeline

#get_edit_token_pipeline, #get_multi_use_pipeline, #get_pipeline, #get_postpaid_pipeline, #get_prepaid_pipeline, #get_recipient_pipeline, #get_recurring_use_pipeline, #get_single_use_pipeline

Methods included from GetPaymentInstruction

#get_payment_instruction

Methods included from GetOutstandingDebtBalance

#get_outstanding_debt_balance

Methods included from GetDebtBalance

#get_debt_balance

Methods included from GetAllPrepaidInstruments

#get_all_prepaid_instruments

Methods included from GetAllCreditInstruments

#get_all_credit_instruments

Methods included from GetAccountBalance

#get_account_balance

Methods included from GetAccountActivity

#get_account_activity

Methods included from FundPrepaid

#fund_prepaid

Methods included from Cancel

#cancel

Methods included from CancelToken

#cancel_token

Methods included from CancelSubscriptionAndRefund

#cancel_subscription_and_refund

Methods included from VerifySignature

#verify_signature

Constructor Details

#initialize(access_key, secret_key, sandbox = false) ⇒ API

Returns a new instance of API.



104
105
106
107
108
109
110
# File 'lib/remit.rb', line 104

def initialize(access_key, secret_key, sandbox=false)
  @access_key = access_key
  @secret_key = secret_key
  @pipeline_url = sandbox ? PIPELINE_SANDBOX_URL : PIPELINE_URL
  @api_endpoint = sandbox ? API_SANDBOX_ENDPOINT : API_ENDPOINT
  super(@api_endpoint)
end

Instance Attribute Details

#access_keyObject (readonly)

Returns the value of attribute access_key.



100
101
102
# File 'lib/remit.rb', line 100

def access_key
  @access_key
end

#api_endpointObject (readonly)

Returns the value of attribute api_endpoint.



102
103
104
# File 'lib/remit.rb', line 102

def api_endpoint
  @api_endpoint
end

#pipeline_urlObject (readonly)

attr_reader :pipeline # kickstarter



99
100
101
# File 'lib/remit.rb', line 99

def pipeline_url
  @pipeline_url
end

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



101
102
103
# File 'lib/remit.rb', line 101

def secret_key
  @secret_key
end

Class Method Details

.signature_v1(path, params, secret_key) ⇒ Object

generates v1 signatures, for historical purposes.



113
114
115
116
117
# File 'lib/remit.rb', line 113

def self.signature_v1(path, params, secret_key)
  params = params.reject {|key, val| ['awsSignature', 'action', 'controller', 'id'].include?(key) }.sort_by{ |k,v| k.to_s.downcase }.map{|k,v| "#{CGI::escape(k)}=#{Remit::SignedQuery.escape_value(v)}"}.join('&')
  signable = path + '?' + params
  Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, secret_key, signable)).strip
end