forked from globalpayments/rxp-js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
process-a-payment-embedded-autoload-callback.html
46 lines (46 loc) · 1.59 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
<!DOCTYPE html>
<html>
<head>
<title>HPP embed Demo</title>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="/dist/rxp-js.js"></script>
<script>
RealexHpp.setHppUrl('https://pay.sandbox.realexpayments.com/pay');
// get the HPP JSON from the server-side SDK
$(document).ready(function () {
$.getJSON("/examples/hpp/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,
{
onResize:function(data){
$('#targetIframe').css(data)
}
}
);
$('body').addClass('loaded');
});
});
</script>
</head>
<body>
<div class="paymentResult"></div>
<iframe id="targetIframe" style="display:none;"></iframe>
</body>
</html>