Repository is archived
No commit activity in last 3 years
No release in over 3 years
A straight-forward REST API for Amazon's Flexible Payments Services.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies

Development

~> 1.3
>= 0
= 3.2.5
>= 0

Runtime

>= 3.0.14
>= 0.5.2
~> 1.8.0
 Project Readme

AmazonFlexPay¶ ↑

Library for Amazon's Flexible Payment Service.

As of 2015, Amazon Flexible Payment Service has shut down and as a result this gem is no longer maintained.

INITIALIZE¶ ↑

Initialize the gem, probably in config/initializers/amazon_flex_pay.rb (for Rails):

AmazonFlexPay.access_key = 'your access key'
AmazonFlexPay.secret_key = 'your secret key'
AmazonFlexPay.go_live! if Rails.env.production?

CALL¶ ↑

AmazonFlexPay::Pipelines¶ ↑

Start here. You'll need tokens for API calls. These are generated by users via parameterized pipelines.

Example¶ ↑

Construct a single-use pipeline for the user. This is where the user will agree to pay a certain amount to a specific recipient (maybe you?).

redirect_to AmazonFlexPay.single_use_pipeline(
  'mypipeline3292',
  'http://example.com/return',
  :recipient_token => 'RTOKEN',
  :transaction_amount => '12.99'
)

AmazonFlexPay::API¶ ↑

With tokens, you can make API calls. Note that results are asynchronous via IPNs. Payment and Refund examples are below. You can see all available API methods here.

Payment Example¶ ↑

Once you have a sender token, you can attempt to collect.

begin
  response = AmazonFlexPay.pay('12.99', 'USD', 'senderToken123')
  flash[:notice] = "Thanks! Your payment is processing."
rescue AmazonFlexPay::API::Error => e
  flash[:error] = "Sorry, something went wrong."
  e.errors.each do |error|
    # notify yourself about error.code and error.message
  end
end

redirect_to product_path

Refund Example¶ ↑

If you would like to give your last order a $10 refund, you can call the refund method like this:

order = Order.last

AmazonFlexPay.refund(
  order.transaction_id,
  order.id,
  caller_description: 'Friends and family discount.',
  refund_amount: { value: 10, currency_code: 'USD' },
)

Note: In this example, we are using the order id as the caller reference. You can pass any reference that you like. Also, the 'caller_description' and 'refund_amount' options are not required. The default refund amount is the original transaction amount.

Copyright © 2013 Kickstarter, released under the MIT license.