2017-09-03 45 views
0

我在使用iframe方法的沙箱中使用Authorize.net托管的付款页面。我实现了IFrameCommunicator机制来接收消息。我的页面获取调整大小事件和取消事件。我没有收到完成的交易的transactResponse事件。使用iframeCommunicator时未收到transactResponse事件(沙箱)

想知道在沙箱环境中是否可以使用transactResponse事件?

回答

0

您应该设置'hostedProfileIFrameCommunicatorUrl'值。例如:

$setting = new AnetAPI\SettingType(); 
$setting->setSettingName("hostedProfileIFrameCommunicatorUrl"); 
$url = 'your url'; 
$setting->setSettingValue($url); 
$request->addToHostedProfileSettings($setting); 
$controller = new AnetController\GetHostedProfilePageController($request); 
$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); 

function callParentFunction(str) { 
 
    var referrer = document.referrer; 
 
    var s = {qstr : str , parent : referrer}; 
 
    //console.log(s); str include response . 
 
    if(referrer == 'https://test.authorize.net/customer/addPayment'){ 
 
     switch(str){ 
 
      case 'action=successfulSave' : 
 
       //your code 
 
       break; 
 
     } 
 
    } 
 
} 
 

 
function receiveMessage(event) { 
 
    if (event && event.data) { 
 
     callParentFunction(event.data); 
 
    } 
 
} 
 

 
if (window.addEventListener) { 
 
    window.addEventListener("message", receiveMessage, false); 
 
} else if (window.attachEvent) { 
 
    window.attachEvent("onmessage", receiveMessage); 
 
} 
 

 
if (window.location.hash && window.location.hash.length > 1) { 
 
    callParentFunction(window.location.hash.substring(1)); 
 
}