This repository has been archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
awssum-amazon-fps.js
93 lines (70 loc) · 2.89 KB
/
awssum-amazon-fps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// --------------------------------------------------------------------------------------------------------------------
//
// fps.js - class for AWS Flexible Payments
//
// Copyright (c) 2012 AppsAttic Ltd - http://www.appsattic.com/
// Written by Andrew Chilton <[email protected]>
//
// 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.AmazonSignatureV2);
// --------------------------------------------------------------------------------------------------------------------
// 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;
// --------------------------------------------------------------------------------------------------------------------