Hashtag should work fine in the return url:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" target="paypal" method="post">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="hbsawnhdglv@paypal.com" />
<input type="hidden" name="item_name" value="item" />
<input type="hidden" name="currency" value="USD" />
<input type="hidden" name="amount" value="0" />
<input type="hidden" name="return" value="http://localhost/test.php#test" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
and on jsfiddle. I also tried with ExpressCheckout and it works as well, however using standard anchors this may not work as the hashtag may be in the wrong place. Also, if you are trying to put it at the end of a GET
variable it will think it is part of the variable and encode it:
<input type="hidden" name="return" value="http://localhost/test.php?v=1#test" />
Produces: http://localhost/test.php?v=1%23test