contract SoftcappedCrowdsale is AdminRole, Crowdsale {
    // minimum amount of tokens to be sold
    uint256 private _goal;

    // minimum amount of wei to be accepted
    // from a single user before softcap collected
    uint256 private _minimalPay = 0;

    /**
     * @dev Constructor, creates RefundEscrow.
     * @param goal Funding goal
     */
    constructor (uint256 goal) public {
        require(goal > 0);
        _goal = goal;
    }

    /**
     * @return minimum amount of tokens to be sold.
     */
    function goal() public view returns (uint256) {
        return _goal;
    }

    /**
     * @return minimum amount of wei to be paid until softcap is reached.
     */
    function minimalPay() public view returns (uint256) {
        return goalReached() ? 0 : _minimalPay;
    }

    /**
     * @return minimum amount of wei to be paid until softcap is reached.
     */
    function setMinimalPay(uint256 weiAmount) WhileSetup internal {
        _minimalPay = weiAmount;
    }

    /**
     * @dev Checks whether funding goal was reached.
     * @return Whether funding goal was reached
     */
    function goalReached() public view returns (bool) {
        return sold() >= _goal;
    }

    /**
     * @dev Extends parent with additional wei amount check sent by user
     * @param beneficiary Token purchaser
     * @param weiAmount Amount of received wei
     */
    function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
        super._preValidatePurchase(beneficiary, weiAmount);

        if (!goalReached() && _minimalPay != 0) {
            require(weiAmount >= _minimalPay);
        }
    }

}
function setMinimalPay(uint256 weiAmount) WhileSetup internal {
    _minimalPay = weiAmount;
}

/**
 * @return minimum amount of wei to be paid until softcap is reached.
 */