Skip to content

Instantly share code, notes, and snippets.

@spaomalley
Last active December 16, 2015 07:28
Show Gist options
  • Save spaomalley/5398641 to your computer and use it in GitHub Desktop.
Save spaomalley/5398641 to your computer and use it in GitHub Desktop.
function Payment(){
var setTokenData = function(response){
Config.tokens.oauth_token = response.oauth_token;
Config.tokens.oauth_token_secret = response.oauth_token_secret;
}
var Tokens = {
set: function(){
var rt = new OAuthObject(Config.Endpoints.request);
rt.run();
setTokenData(rt.parsedResponse_Text());
var at = new OAuthObject(Config.Endpoints.access);
at.run();
setTokenData(at.parsedResponse_Text());
}
}
this.post = function(paymentData){
Tokens.set();
var postPayment = new OAuthObject(Config.Endpoints.payment);
postPayment.run(JSON.stringify(paymentData));
}
}
window.onload = function(){
var payment = new Payment();
payment.post({
merchantId: Config.merchantId,
tenderType: "Card",
cardAccount: {
number: '4123412341234123',
expiryMonth: '06',
expiryYear: '2017',
CVV: '123',
avsZip: '12345'
},
amount: .01
});
}
<html>
<head>
<!-- The below 3 Library references are required -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha1.js"></script>
<script type="text/javascript" src="http://oauth.googlecode.com/svn/code/javascript/sha1.js"></script>
<script type="text/javascript" src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64-min.js"></script>
<script src="Config.js"></script>
<script src="OAuthObject.js"></script>
<script src="Payment.js"></script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment