I want to open 2Checkout express payment form. I created this test code:
JSF code:
<h:form target="_blank" style="padding: 20px 20px 20px 20px;">
<h:commandButton value="TwoCheckout" action="#{pricingCalculator.initTwoCheckout}" />
</h:form>
CDI Bean:
@Named
@ViewScoped
public class PricingCalculator implements Serializable {
public String initTwoCheckout() throws Exception {
HashMap<String, String> params = new HashMap<>();
params.put("sid", "1817037");
params.put("mode", "2CO");
params.put("li_0_type", "product");
params.put("li_0_name", "Example Product");
params.put("li_0_price", "1.00");
String message = TwocheckoutCharge.url(params);
return message;
}
}
I printed the output I get http link https://www.2checkout.com/checkout/spurchase?mode=2CO&li_0_price=1.00&li_0_name=Example+Product&sid=1817037&li_0_type=product
But when I press the h:commandButton
the page is just refreshed in a new window. Can you tell me what is the proper way to open the return link using h:commandButton
?