0

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&amp;li_0_price=1.00&amp;li_0_name=Example+Product&amp;sid=1817037&amp;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?

Tiny
  • 27,221
  • 105
  • 339
  • 599
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

0 Answers0