-
Notifications
You must be signed in to change notification settings - Fork 70
/
process-a-payment-embedded-autoload-callback.html
48 lines (48 loc) · 1.77 KB
/
process-a-payment-embedded-autoload-callback.html
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
<!DOCTYPE html>
<html>
<head>
<title>HPP embed Demo</title>
<meta charset="UTF-8">
<style>
#targetIframe {
min-height: 600px;
min-width: 350px;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="./../../dist/rxp-js.js"></script>
<script src="./helper.js"></script>
<script>
RealexHpp.setHppUrl('https://pay.sandbox.realexpayments.com/pay');
// get the HPP JSON from the server-side SDK
$(document).ready(function () {
$.getJSON("./proxy-request.php?slug=process-a-payment", function (jsonFromServerSdk) {
RealexHpp.embedded.init(
"autoload",
"targetIframe",
function (answer, close) {
console.log('embed answer: ', answer)
close();
if (answer.AUTHCODE) {
$('.paymentResult').html('<div class="alert alert-success">All set!</div>');
//success
success(answer);
}
else {
//error
$('.paymentResult').html('<div class="alert alert-danger">'+answer.MESSAGE+'</div>');
//would you retry? This part should be handled at the rxp side, stay in the modal/iframe... TODO
}
},
jsonFromServerSdk
);
$('body').addClass('loaded');
});
});
</script>
</head>
<body>
<div class="paymentResult"></div>
<iframe id="targetIframe" style="display:none;"></iframe>
</body>
</html>