cancel
Showing results for 
Search instead for 
Did you mean: 

Capture hosted form success

I'm trying to use hosted form to add payment in my app. Can you help me please, how can I capture moment when i get success?

 

My html seems like:

<form style="display:none;" id="aNetForm" action="https://test.authorize.net/customer/addPayment" target="aNetIframe" method="post">
<input type="hidden" name="token" value="{{authorizeNetToken}}"/>
</form>
<iframe style="width:100%; height:500px;" src="" name="aNetIframe" id="aNetIframe" frameborder="0"></iframe>

And my JS seems like:  

function useAuthorizeNetFn(token){
$scope.authorizeNetToken = token;
$('#aNetForm').submit();
$('#aNetIframe').css('height', ($('.page-content').height()-45)+'px');
$('#aNetIframe').on('load', function(e){
window.addEventListener('message', function listenAnetCardAdded(e){
if(e.origin.match('authorize.net') && e.data.match("successfulSave")){
// code
}
});
})
}

 this working, but maybe you can tell me better solution? Not event listener ...

 

vitalii
Member
1 REPLY 1

@vitalii

 

If you are using an iFrame, another developer provided an answere here: https://community.developer.authorize.net/t5/Integration-and-Testing/Question-Can-I-get-a-response-f...

 

Richard

RichardH
Administrator Administrator
Administrator