Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Commit

Permalink
Migrate Amazon Flexible Payments Service (FPS) from the old awssum, t…
Browse files Browse the repository at this point in the history
…o the new plugin architecture.
  • Loading branch information
chilts committed Mar 2, 2013
0 parents commit 24f5dd8
Show file tree
Hide file tree
Showing 6 changed files with 528 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
*~
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-------------------------------------------------------------------------------

This software is published under the MIT license as published here:

* http://opensource.org/licenses/MIT

-------------------------------------------------------------------------------

Copyright 2011-2013 Apps Attic Ltd. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-------------------------------------------------------------------------------
Empty file added README.md
Empty file.
93 changes: 93 additions & 0 deletions awssum-amazon-fps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// --------------------------------------------------------------------------------------------------------------------
//
// fps.js - class for AWS Flexible Payments
//
// Copyright (c) 2012 AppsAttic Ltd - http://www.appsattic.com/
// Written by Andrew Chilton <chilts@appsattic.com>
//
// License: http://opensource.org/licenses/MIT
//
// --------------------------------------------------------------------------------------------------------------------
// requires

// built-ins
var util = require('util');
var crypto = require('crypto');

// dependencies
var _ = require('underscore');
var dateFormat = require('dateformat');

// our own
var awssum = require('awssum');
var amazon = require('awssum-amazon');
var Sts = require('awssum-amazon-sts').Sts;
var operations = require('./config.js');

// --------------------------------------------------------------------------------------------------------------------
// package variables

var MARK = 'fps: ';

// From: http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/EndPoints.html
var endPoint = {};
endPoint['FPS-PROD'] = "fps.amazonaws.com";
endPoint['FPS-SANDBOX'] = "fps.sandbox.amazonaws.com";
// endPoint[''] = "authorize.payments-sandbox.amazon.com/cobranded-ui/actions/start";
// endPoint[''] = "authorize.payments.amazon.com/cobranded-ui/actions/start";

// From: http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/DataTypesAndFPSWsdl.html
var version = '2010-08-28';

// --------------------------------------------------------------------------------------------------------------------
// constructor

var Fps = function(opts) {
var self = this;

// call the superclass for initialisation
Fps.super_.call(this, opts);

// check the region is valid
if ( ! endPoint[opts.region] ) {
throw MARK + "invalid region '" + opts.region + "'";
}

return self;
};

// inherit from Amazon
util.inherits(Fps, amazon.Amazon);

// --------------------------------------------------------------------------------------------------------------------
// methods we need to implement from amazon.js

Fps.prototype.method = function() {
return 'POST';
};

Fps.prototype.host = function(args) {
return endPoint[this.region()];
};

Fps.prototype.version = function() {
return version;
};

Fps.prototype.extractBody = function() {
return 'xml';
};

// --------------------------------------------------------------------------------------------------------------------
// operations on the service

_.each(operations, function(operation, operationName) {
Fps.prototype[operationName] = awssum.makeOperation(operation);
});

// --------------------------------------------------------------------------------------------------------------------
// exports

exports.Fps = Fps;

// --------------------------------------------------------------------------------------------------------------------
Loading

0 comments on commit 24f5dd8

Please sign in to comment.