Class: Flexpay::API

Inherits:
Object
  • Object
show all
Defined in:
lib/flexpay.rb

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
SIMPLEPAY_ENDPOINT =
'https://authorize.payments.amazon.com/pba/paypipeline'.freeze
SIMPLEPAY_SANDBOX_ENDPOINT =
"https://authorize.payments-sandbox.amazon.com/pba/paypipeline".freeze
SIGNATURE_VERSION =
2.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ API

Returns a new instance of API.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/flexpay.rb', line 39

def initialize(params)
  @access_key = params[:access_key]
  @secret_key = params[:secret_key]
  @cobranding_version = params[:cobranding_version] || "2009-01-09"
  @fps_version = params[:fps_version] || "2008-09-17"
  @simple_pay_version = params[:simple_pay_version] || "2009-04-17"
  
  if params[:sandbox].nil? or params[:sandbox] == true
    @pipeline_url = PIPELINE_SANDBOX_URL
    @fps_url = API_SANDBOX_ENDPOINT
    @simplepay_url = SIMPLEPAY_SANDBOX_ENDPOINT
  else
    @pipeline_url = PIPELINE_URL
    @fps_url = API_ENDPOINT
    @simplepay_url = SIMPLEPAY_ENDPOINT
  end

end

Instance Attribute Details

#access_key ⇒ Object (readonly)

Returns the value of attribute access_key.

Raises:



30
31
32
# File 'lib/flexpay.rb', line 30

def access_key
  @access_key
end

#cobranding_version ⇒ Object (readonly)

Returns the value of attribute cobranding_version.



35
36
37
# File 'lib/flexpay.rb', line 35

def cobranding_version
  @cobranding_version
end

#fps_url ⇒ Object (readonly)

Returns the value of attribute fps_url.



32
33
34
# File 'lib/flexpay.rb', line 32

def fps_url
  @fps_url
end

#fps_version ⇒ Object (readonly)

Returns the value of attribute fps_version.



36
37
38
# File 'lib/flexpay.rb', line 36

def fps_version
  @fps_version
end

#pipeline_url ⇒ Object (readonly)

Returns the value of attribute pipeline_url.



33
34
35
# File 'lib/flexpay.rb', line 33

def pipeline_url
  @pipeline_url
end

#secret_key ⇒ Object (readonly)

Returns the value of attribute secret_key.

Raises:



31
32
33
# File 'lib/flexpay.rb', line 31

def secret_key
  @secret_key
end

#simple_pay_version ⇒ Object (readonly)

Returns the value of attribute simple_pay_version.



37
38
39
# File 'lib/flexpay.rb', line 37

def simple_pay_version
  @simple_pay_version
end

#simplepay_url ⇒ Object (readonly)

Returns the value of attribute simplepay_url.



34
35
36
# File 'lib/flexpay.rb', line 34

def simplepay_url
  @simplepay_url
end

Instance Method Details

#get_cancel_subscription_and_refund ⇒ Object



83
84
85
86
# File 'lib/flexpay.rb', line 83

def get_cancel_subscription_and_refund
  obj = fps_constant_lookup(:CancelSubscriptionAndRefund).new
  supply_defaults_for_fps_and_return(obj)
end

#get_pay ⇒ Object



73
74
75
76
# File 'lib/flexpay.rb', line 73

def get_pay
  obj = fps_constant_lookup(:Pay).new
  supply_defaults_for_fps_and_return(obj)
end

#get_recipient_token ⇒ Object



63
64
65
66
# File 'lib/flexpay.rb', line 63

def get_recipient_token
  obj = cobranding_constant_lookup(:RecipientToken).new
  supply_defaults_for_pipeline_and_return(obj)
end

#get_recurring_pipeline ⇒ Object



58
59
60
61
# File 'lib/flexpay.rb', line 58

def get_recurring_pipeline
  obj = cobranding_constant_lookup(:RecurringPipeline).new
  supply_defaults_for_pipeline_and_return(obj)
end

#get_subscription_button ⇒ Object



78
79
80
81
# File 'lib/flexpay.rb', line 78

def get_subscription_button
  obj = simple_pay_constant_lookup(:SubscriptionButton).new
  supply_defaults_for_simple_pay_and_return(obj)
end

#get_verify_signature ⇒ Object



68
69
70
71
# File 'lib/flexpay.rb', line 68

def get_verify_signature
  obj = fps_constant_lookup(:VerifySignature).new
  supply_defaults_for_fps_and_return(obj)
end