Module: AmazonFlexPay::API
- Included in:
- AmazonFlexPay
- Defined in:
- lib/amazon_flex_pay/api/pay.rb,
lib/amazon_flex_pay/api.rb,
lib/amazon_flex_pay/api/cancel.rb,
lib/amazon_flex_pay/api/errors.rb,
lib/amazon_flex_pay/api/refund.rb,
lib/amazon_flex_pay/api/settle.rb,
lib/amazon_flex_pay/api/reserve.rb,
lib/amazon_flex_pay/api/get_tokens.rb,
lib/amazon_flex_pay/api/base_request.rb,
lib/amazon_flex_pay/api/cancel_token.rb,
lib/amazon_flex_pay/api/get_token_usage.rb,
lib/amazon_flex_pay/api/get_transaction.rb,
lib/amazon_flex_pay/api/verify_signature.rb,
lib/amazon_flex_pay/api/get_account_balance.rb,
lib/amazon_flex_pay/api/get_token_by_caller.rb,
lib/amazon_flex_pay/api/get_account_activity.rb,
lib/amazon_flex_pay/api/get_transaction_status.rb,
lib/amazon_flex_pay/api/get_recipient_verification_status.rb
Overview
:nodoc:
Defined Under Namespace
Classes: BaseRequest, Cancel, CancelToken, Error, GetAccountActivity, GetAccountBalance, GetRecipientVerificationStatus, GetTokenByCaller, GetTokenUsage, GetTokens, GetTransaction, GetTransactionStatus, Pay, Refund, Reserve, Settle, VerifySignature
Instance Method Summary collapse
-
#cancel(transaction_id, options = {}) ⇒ Object
Cancels a transaction.
-
#cancel_token(token_id, options = {}) ⇒ Object
Cancels a token.
-
#get_account_activity(start_date, end_date, options = {}) ⇒ Object
Searches through transactions on your account.
-
#get_account_balance ⇒ Object
Gets your Amazon Payments account balance.
-
#get_recipient_verification_status(recipient_token_id) ⇒ Object
Returns the status of a recipient’s Amazon account.
-
#get_token_by_caller_reference(ref) ⇒ Object
Returns information about a token’s state from a caller reference.
-
#get_token_by_id(id) ⇒ Object
Returns information about a token’s state from a token id.
-
#get_token_usage(id) ⇒ Object
Returns information about how much of the token has been used, and what remains.
-
#get_tokens(options = {}) ⇒ Object
Returns all of your tokens.
-
#get_transaction(id) ⇒ Object
Returns all of Amazon’s details about a transaction, such as its status and when it began and finished processing.
-
#get_transaction_status(id) ⇒ Object
Returns the current status of the transaction.
-
#pay(value, currency, sender_token_id, caller_reference, options = {}) ⇒ Object
Begins a Pay request for a sender token.
-
#refund(transaction_id, caller_reference, options = {}) ⇒ Object
Refunds a transaction.
-
#reserve(value, currency, sender_token_id, caller_reference, options = {}) ⇒ Object
Begins a Reserve request for the sender token.
-
#settle(transaction_id, options = {}) ⇒ Object
If you have a Reserve transaction, use this to Settle (capture) it.
-
#verify_request(request) ⇒ Object
This is how you verify IPNs and pipeline responses.
-
#verify_signature(url, params) ⇒ Object
Verifies the signature embedded in the params string for the given url.
Instance Method Details
#cancel(transaction_id, options = {}) ⇒ Object
Cancels a transaction.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/Cancel.html
9 10 11 |
# File 'lib/amazon_flex_pay/api.rb', line 9 def cancel(transaction_id, = {}) submit Cancel.new(.merge(:transaction_id => transaction_id)) end |
#cancel_token(token_id, options = {}) ⇒ Object
Cancels a token.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/CancelToken.html
16 17 18 |
# File 'lib/amazon_flex_pay/api.rb', line 16 def cancel_token(token_id, = {}) submit CancelToken.new(.merge(:token_id => token_id)) end |
#get_account_activity(start_date, end_date, options = {}) ⇒ Object
Searches through transactions on your account. Helpful if you want to compare vs your own records, or print an admin report.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/GetAccountActivity.html
24 25 26 |
# File 'lib/amazon_flex_pay/api.rb', line 24 def get_account_activity(start_date, end_date, = {}) submit GetAccountActivity.new(.merge(:start_date => start_date, :end_date => end_date)) end |
#get_account_balance ⇒ Object
Gets your Amazon Payments account balance.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/GetAccountBalance.html
31 32 33 |
# File 'lib/amazon_flex_pay/api.rb', line 31 def get_account_balance submit GetAccountBalance.new end |
#get_recipient_verification_status(recipient_token_id) ⇒ Object
Returns the status of a recipient’s Amazon account.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/GetRecipientVerificationStatus.html
38 39 40 |
# File 'lib/amazon_flex_pay/api.rb', line 38 def get_recipient_verification_status(recipient_token_id) submit GetRecipientVerificationStatus.new(:recipient_token_id => recipient_token_id) end |
#get_token_by_caller_reference(ref) ⇒ Object
Returns information about a token’s state from a caller reference.
This is the closest thing that Amazon’s API has to getting the status of a pipeline. Provide the caller reference for your pipeline (you are saving caller references, right?), and if this returns a token you can assume the pipeline finished successfully.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/GetTokensByCaller.html
49 50 51 |
# File 'lib/amazon_flex_pay/api.rb', line 49 def get_token_by_caller_reference(ref) submit GetTokenByCaller.new(:caller_reference => ref) end |
#get_token_by_id(id) ⇒ Object
Returns information about a token’s state from a token id.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/GetTokensByCaller.html
56 57 58 |
# File 'lib/amazon_flex_pay/api.rb', line 56 def get_token_by_id(id) submit GetTokenByCaller.new(:token_id => id) end |
#get_token_usage(id) ⇒ Object
Returns information about how much of the token has been used, and what remains.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/GetTokenUsage.html
63 64 65 |
# File 'lib/amazon_flex_pay/api.rb', line 63 def get_token_usage(id) submit GetTokenUsage.new(:token_id => id) end |
#get_tokens(options = {}) ⇒ Object
Returns all of your tokens. Note that when you send someone through a recipient pipeline, that registers a recipient token on their account, not yours. And when you send someone through a single use pipeline, that registers a sender token on _their_account, not yours.
So basically this will only return recipient tokens where you are the recipient, or sender tokens where you are the sender.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/GetTokens.html
75 76 77 |
# File 'lib/amazon_flex_pay/api.rb', line 75 def get_tokens( = {}) submit GetTokens.new() end |
#get_transaction(id) ⇒ Object
Returns all of Amazon’s details about a transaction, such as its status and when it began and finished processing.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/GetTransaction.html
83 84 85 |
# File 'lib/amazon_flex_pay/api.rb', line 83 def get_transaction(id) submit GetTransaction.new(:transaction_id => id) end |
#get_transaction_status(id) ⇒ Object
Returns the current status of the transaction. Note that this information is also available from get_transaction
.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAccountManagementGuide/GetTransactionStatus.html
91 92 93 |
# File 'lib/amazon_flex_pay/api.rb', line 91 def get_transaction_status(id) submit GetTransactionStatus.new(:transaction_id => id) end |
#pay(value, currency, sender_token_id, caller_reference, options = {}) ⇒ Object
Begins a Pay request for a sender token. If you are not also the recipient (this is a three-party marketplace transaction) then you must also specify the recipient token.
Sign up for Instant Payment Notifications to be told when this has finished.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/Pay.html
101 102 103 104 105 106 107 |
# File 'lib/amazon_flex_pay/api.rb', line 101 def pay(value, currency, sender_token_id, caller_reference, = {}) submit Pay.new(.merge( :transaction_amount => {:value => value, :currency_code => currency}, :sender_token_id => sender_token_id, :caller_reference => caller_reference )) end |
#refund(transaction_id, caller_reference, options = {}) ⇒ Object
Refunds a transaction. By default it will refund the entire transaction, but you can provide an amount for partial refunds.
Sign up for Instant Payment Notifications to be told when this has finished.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/Refund.html
128 129 130 |
# File 'lib/amazon_flex_pay/api.rb', line 128 def refund(transaction_id, caller_reference, = {}) submit Refund.new(.merge(:transaction_id => transaction_id, :caller_reference => caller_reference)) end |
#reserve(value, currency, sender_token_id, caller_reference, options = {}) ⇒ Object
Begins a Reserve request for the sender token. Very similar to pay
.
Sign up for Instant Payment Notifications to be told when this has finished.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/Reserve.html
114 115 116 117 118 119 120 |
# File 'lib/amazon_flex_pay/api.rb', line 114 def reserve(value, currency, sender_token_id, caller_reference, = {}) submit Reserve.new(.merge( :transaction_amount => {:value => value, :currency_code => currency}, :sender_token_id => sender_token_id, :caller_reference => caller_reference )) end |
#settle(transaction_id, options = {}) ⇒ Object
If you have a Reserve transaction, use this to Settle (capture) it.
Sign up for Instant Payment Notifications to be told when this has finished.
See docs.amazonwebservices.com/AmazonFPS/latest/FPSAdvancedGuide/Settle.html
137 138 139 |
# File 'lib/amazon_flex_pay/api.rb', line 137 def settle(transaction_id, = {}) submit Settle.new(.merge(:reserve_transaction_id => transaction_id)) end |
#verify_request(request) ⇒ Object
This is how you verify IPNs and pipeline responses. Pass the entire request object.
143 144 145 146 147 148 149 150 |
# File 'lib/amazon_flex_pay/api.rb', line 143 def verify_request(request) verify_signature( # url without query string request.protocol + request.host_with_port + request.path, # raw parameters request.get? ? request.query_string : request.raw_post ) end |
#verify_signature(url, params) ⇒ Object
Verifies the signature embedded in the params string for the given url.
Please use verify_request
instead to make sure the URL and params remain properly formatted.
155 156 157 |
# File 'lib/amazon_flex_pay/api.rb', line 155 def verify_signature(url, params) submit VerifySignature.new(:url_end_point => url, :http_parameters => params) end |