Skip to content

Instantly share code, notes, and snippets.

@etsms
Last active May 23, 2017 14:51
Show Gist options
  • Select an option

  • Save etsms/3479c770fbbbfb8e02ec155b0b23da2d to your computer and use it in GitHub Desktop.

Select an option

Save etsms/3479c770fbbbfb8e02ec155b0b23da2d to your computer and use it in GitHub Desktop.
Sample Hosted Payments with App Scheme
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/etsms/hosted-payments@3.8.5/dist/jquery.hosted-payments.min.css">
<script src="https://cdn.jsdelivr.net/gh/jquery/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/etsms/hosted-payments@3.8.5/dist/jquery.hosted-payments.min.js"></script>
</head>
<body>
<div id="test"
data-amount="2.89"
data-payment-type-order="0,3"
data-payment-type="charge"
data-correlation-id="invoice123">
loading...
</div>
<br />
<br />
<br />
<br />
<label>Terminal ID</label>
<br />
<br />
<input id="terminalId" type="text" />
<br />
<br />
<label>Amount</label>
<br />
<br />
<input id="amount" type="number" />
<br />
<br />
<label>Api Key</label>
<br />
<br />
<input id="apiKey" type="text" value="676c352d-2ba0-48a0-ba3f-a5eae303dc5b" />
<br />
<br />
<br />
<button>Update Plugin</button>
<script>
$("#test").hp({
apiKey: "676c352d-2ba0-48a0-ba3f-a5eae303dc5b",
baseUrl: "https://stage-htv1b.emoney.com/v3/adapters",
successCallback: function(response) {
console.log(JSON.stringify(response));
alert(response.transaction_approval_code);
},
errorCallback: function(response) {
console.log(JSON.stringify(response));
}
});
$("button").on("click", function() {
var options = {
amount: +($("#amount").val()),
apiKey: $("#apiKey").val()
};
if ($("#terminalId").val() != "") {
options.terminalId = $("#terminalId").val()
};
hp.Utils.reset(options);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment