Browse files

Migrate Amazon Flexible Payments Service (FPS) from the old awssum, t…

…o the new plugin architecture.
  • Loading branch information...
0 parents commit 24f5dd8ce7ef39f9cb394445c14b6dd594eb8521 @chilts committed Mar 2, 2013
Showing with 528 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +29 −0 LICENSE
  3. 0 README.md
  4. +93 −0 awssum-amazon-fps.js
  5. +356 −0 config.js
  6. +48 −0 package.json
2 .gitignore
@@ -0,0 +1,2 @@
+node_modules/
+*~
29 LICENSE
@@ -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.
+
+-------------------------------------------------------------------------------
0 README.md
No changes.
93 awssum-amazon-fps.js
@@ -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;
+
+// --------------------------------------------------------------------------------------------------------------------
356 config.js
@@ -0,0 +1,356 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// fps-config.js - config for Amazon DynamoDB
+//
+// Copyright (c) 2012 AppsAttic Ltd - http://www.appsattic.com/
+// Written by Andrew Chilton <chilts@appsattic.com>
+//
+// License: http://opensource.org/licenses/MIT
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+var _ = require('underscore');
+
+// --------------------------------------------------------------------------------------------------------------------
+
+var required = {
+ 'required' : true,
+ 'type' : 'param',
+};
+
+var optional = {
+ 'required' : false,
+ 'type' : 'param',
+};
+
+function requiredWithName(name) {
+ return {
+ 'name' : name,
+ 'required' : true,
+ 'type' : 'param',
+ };
+}
+
+function optionalWithName(name) {
+ return {
+ 'name' : name,
+ 'required' : false,
+ 'type' : 'param',
+ };
+}
+
+// --------------------------------------------------------------------------------------------------------------------
+
+module.exports = {
+
+ Cancel : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/Cancel.html',
+ defaults : {
+ Action : 'Cancel',
+ },
+ args : {
+ Action : required,
+ Description : optional,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ TransactionId : required,
+ },
+ },
+
+ CancelToken : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/CancelToken.html',
+ defaults : {
+ Action : 'CancelToken',
+ },
+ args : {
+ Action : required,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ ReasonText : optional,
+ TokenId : required,
+ },
+ },
+
+ FundPrepaid : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/FundPrepaid.html',
+ defaults : {
+ Action : 'FundPrepaid',
+ },
+ args : {
+ Action : required,
+ CallerDescription : optional,
+ CallerReference : required,
+ 'DescriptorPolicy.CSOwner' : optional,
+ 'DescriptorPolicy.SoftDescriptorType' : optional,
+ 'FundingAmount.CurrencyCode' : required,
+ 'FundingAmount.Value' : required,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ PrepaidInstrumentId : required,
+ SenderDescription : optional,
+ SenderTokenId : required,
+ TransactionTimeoutInMins : optional
+ },
+ },
+
+ GetAccountActivity : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetAccountActivity.html',
+ defaults : {
+ Action : 'GetAccountActivity',
+ },
+ args : {
+ Action : required,
+ EndDate : optional,
+ FpsOperation : optionalWithName('FPSOperation'),
+ MaxBatchSize : optional,
+ PaymentMethod : optional,
+ ResponseGroup : optional,
+ Role : optional,
+ SortByDateOrder : optional,
+ StartDate : required,
+ Status : optional,
+ },
+ },
+
+ GetAccountBalance : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetAccountBalance.html',
+ defaults : {
+ Action : 'GetAccountBalance',
+ },
+ args : {
+ Action : required,
+ },
+ },
+
+ GetDebtBalance : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetDebtBalance.html',
+ defaults : {
+ Action : 'GetDebtBalance',
+ },
+ args : {
+ Action : required,
+ CreditInstrumentId : required,
+ },
+ },
+
+ GetOutstandingDebtBalance : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetOutstandingDebtBalance.html',
+ defaults : {
+ Action : 'GetOutstandingDebtBalance',
+ },
+ args : {
+ Action : required,
+ },
+ },
+
+ GetPrepaidDebtBalance : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetPrepaidBalance.html',
+ defaults : {
+ Action : 'GetPrepaidDebtBalance',
+ },
+ args : {
+ Action : required,
+ PrepaidInstrumentId : required,
+ },
+ },
+
+ GetRecipientVerificationStatus : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetRecipientVerificationStatus.html',
+ defaults : {
+ Action : 'GetRecipientVerificationStatus',
+ },
+ args : {
+ Action : required,
+ RecipientTokenId : required,
+ },
+ },
+
+ GetTokens : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetTokens.html',
+ defaults : {
+ Action : 'GetTokens',
+ },
+ args : {
+ Action : required,
+ CallerReference : optional,
+ TokenStatus : optional,
+ TokenType : optional,
+ },
+ },
+
+ GetTokensByCaller : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetTokensByCaller.html',
+ defaults : {
+ Action : 'GetTokensByCaller',
+ },
+ args : {
+ Action : required,
+ CallerReference : optional,
+ TokenId : optional,
+ },
+ },
+
+ GetTokenUsage : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetTokenUsage.html',
+ defaults : {
+ Action : 'GetTokenUsage',
+ },
+ args : {
+ Action : required,
+ TokenId : optional,
+ },
+ },
+
+ GetTotalPrepaidLiability : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetTotalPrepaidLiability.html',
+ defaults : {
+ Action : 'GetTotalPrepaidLiability',
+ },
+ args : {
+ Action : required,
+ },
+ },
+
+ GetTransaction : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetTransaction.html',
+ defaults : {
+ Action : 'GetTransaction',
+ },
+ args : {
+ Action : required,
+ TransactionId : required,
+ },
+ },
+
+ GetTransactionStatus : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/GetTransactionStatus.html',
+ defaults : {
+ Action : 'GetTransactionStatus',
+ },
+ args : {
+ Action : required,
+ TransactionId : required,
+ },
+ },
+
+ Pay : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/Pay.html',
+ defaults : {
+ Action : 'Pay',
+ },
+ args : {
+ Action : required,
+ CallerDescription : optional,
+ CallerReference : required,
+ ChargeFeeTo : optional,
+ 'DescriptorPolicy.CsOwner' : optional,
+ 'DescriptorPolicy.SoftDescriptorType' : optional,
+ MarketplaceFixedFee : optional,
+ MarketplaceVariableFee : optional,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ RecipientTokenId : optional,
+ SenderDescription : optional,
+ SenderTokenId : required,
+ TransactionAmount : required,
+ TransactionTimeoutInMins : optional,
+ },
+ },
+
+ Refund : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/Refund.html',
+ defaults : {
+ Action : 'Refund',
+ },
+ args : {
+ Action : required,
+ CallerDescription : optional,
+ CallerReference : required,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ RefundAmount : optional,
+ TransactionId : required,
+ MarketplaceRefundPolicy : optional,
+ },
+ },
+
+ Reserve : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/Reserve.html',
+ defaults : {
+ Action : 'Reserve',
+ },
+ args : {
+ Action : required,
+ CallerDescription : optional,
+ CallerReference : required,
+ ChargeFeeTo : optional,
+ 'DescriptorPolicy.CsOwner' : optional,
+ 'DescriptorPolicy.SoftDescriptorType' : optional,
+ MarketplaceFixedFee : optional,
+ MarketplaceVariableFee : optional,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ RecipientTokenId : optional,
+ SenderDescription : optional,
+ SenderTokenId : required,
+ TransactionAmount : required,
+ TransactionTimeoutInMins : optional,
+ },
+ },
+
+ Settle : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/Settle.html',
+ defaults : {
+ Action : 'Settle',
+ },
+ args : {
+ Action : required,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ ReserveTransactionId : required,
+ TransactionAmount : required,
+ },
+ },
+
+ SettleDebt : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/SettleDebt.html',
+ defaults : {
+ Action : 'SettleDebt',
+ },
+ args : {
+ Action : required,
+ CallerDescription : optional,
+ CallerReference : required,
+ CreditInstrumentId : required,
+ 'DescriptorPolicy.CsOwner' : optional,
+ 'DescriptorPolicy.SoftDescriptorType' : optional,
+ OverrideIpnUrl : optionalWithName('OverrideIPNURL'),
+ SenderDescription : optional,
+ SenderTokenId : required,
+ SettlementAmount : required,
+ TransactionTimeoutInMins : optional,
+ },
+ },
+
+ VerifySignature : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/VerifySignatureAPI.html',
+ defaults : {
+ Action : 'VerifySignature',
+ },
+ args : {
+ Action : required,
+ UrlEndPoint : required,
+ HttpParameters : required,
+ },
+ },
+
+ WriteOffDebt : {
+ url : 'http://docs.amazonwebservices.com/AmazonFPS/latest/FPSAPIReference/WriteOffDebt.html',
+ defaults : {
+ Action : 'WriteOffDebt',
+ },
+ args : {
+ Action : required,
+ AdjustmentAmount : required,
+ CallerDescription : optional,
+ CallerReference : required,
+ CreditInstrumentId : required,
+ },
+ },
+
+};
+
+// --------------------------------------------------------------------------------------------------------------------
48 package.json
@@ -0,0 +1,48 @@
+{
+ "name" : "awssum-amazon-fps",
+ "description" : "NodeJS module to talk to Amazon Flexible Payments Service (FPS).",
+ "version" : "1.0.0",
+
+ "main" : "awssum-amazon-fps.js",
+ "engines" : {
+ "node" : ">= 0.6.0"
+ },
+ "peerDependencies" : {
+ "awssum-amazon" : "1.x.x"
+ },
+ "dependencies" : {
+ "data2xml" : "0.8.x",
+ "underscore" : "1.4.x",
+ "dateformat" : "1.0.4-1.2.3"
+ },
+ "devDependencies" : {
+ "tap" : "0.4.x"
+ },
+ "scripts" : {
+ "test" : "tap test/*.js test/integration/*.js"
+ },
+
+ "homepage" : "https://awssum.io/",
+ "repository" : {
+ "type" : "git",
+ "url" : "git://github.com/awssum/awssum-amazon-fps.git"
+ },
+ "bugs" : {
+ "url" : "http://github.com/awssum/awssum-amazon-fps/issues",
+ "mail" : "andychilton@gmail.com"
+ },
+
+ "author" : {
+ "name" : "Andrew Chilton",
+ "email" : "andychilton@gmail.com",
+ "url" : "http://chilts.org/"
+ },
+ "contributors" : [],
+ "licenses" : [{
+ "type" : "MIT",
+ "url" : "http://github.com/awssum/awssum-amazon-fps/raw/master/LICENSE"
+ }],
+ "keywords" : [
+ "awssum", "awssum-plugin", "amazon", "aws", "webapi", "api", "fps"
+ ]
+}

0 comments on commit 24f5dd8

Please sign in to comment.