Дерево страниц

Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

Блок кода
public class AddRecsum
    extends EventScriptBase<MPSBeforeRequestEvent>
{
    @Override
    public void onEvent( MPSOSMPRequestEvent event, Setup setup, ConnectionSet set )
        throws Exception
    {
        event.getResponse().getParameters().put( "recsum", 1000 );
        // event.setProcessed( true );
    }
}

С версии 7.2+ доступно событие MPSBeforeResponseEvent (поддерживается не всеми протоколами, есть в osmp, cp, kaspi, quickpay)

Блок кода
public class MPSResponseScript
	extends EventScriptBase<MPSBeforeResponseEvent>
{
	@Override
	public void onEvent( MPSBeforeResponseEvent mpsBeforeResponseEvent, Setup setup, ConnectionSet connectionSet )
		throws Exception
	{
	    Contract contract = mpsBeforeResponseEvent.getResponse().getContract();
	    
	    if ( contract != null )
	    {
            MPSResponse response = mpsBeforeResponseEvent.getResponse();

            try( ContractParameterManager contractParameterManager = new ContractParameterManager( connectionSet.getConnection() ); )
    	    {
    	        ContractAddressParamValue contractAddressParamValue = contractParameterManager.getAddressParam( contract.getId(), PARAM_ADDRESS_ID );
    	        if ( contractAddressParamValue != null )
    	        {
    	            address = contractAddressParamValue.getAddress();
    	        }
    	    }
    	    
    	    Map<String, String> responseParameters = new HashMap<>();
        	if ( address != null )
        	{
        	    responseParameters.put( "add", "address: " + address );
        	}
    	    if ( !responseParameters.isEmpty() )
    	    {
    	        response.getParameters().put( MPSTransactionManager.KEY_RESPONSE_PARAMETERS, responseParameters );
    	    }
	    }
	}
}