我使用iframe方法在沙箱中使用Authorize.net托管的付款页面。我实现了IFrameCommunicator机制来接收消息。我的页面获取调整大小事件和取消事件。我没有在已完成的交易中获得transactResponse事件。
想知道沙盒环境中是否有transactResponse事件?
答案 0 :(得分: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));
}