Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amazon_flex_pay

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amazon_flex_pay

  • 0.11.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= AmazonFlexPay

Library for Amazon's Flexible Payment Service.

== 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[https://github.com/kickstarter/amazon_flex_pay/blob/master/lib/amazon_flex_pay/api.rb].

==== 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 (c) 2013 Kickstarter, released under the MIT license.

FAQs

Package last updated on 30 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc