// Path: src/main/java/com/twocheckout/model/Authorization.java
// public class Authorization {
//     private String type;
//     private String responseCode;
//     private String currencyCode;
//     private String orderNumber;
//     private String transactionId;
//     private String recurrentInstallmentId;
//     private String responseMsg;
//     private String merchantOrderId;
//     private BigDecimal total;
//     private Lineitems[] lineItems;
// 
//     public String getType() { return type; }
//     public String getResponseCode() { return responseCode; }
//     public String getCurrencyCode() { return currencyCode; }
//     public String getOrderNumber() { return orderNumber; }
//     public String getTransactionId() { return transactionId; }
//     public String getRecurrentInstallmentId() { return recurrentInstallmentId; }
//     public String getResponseMsg() { return responseMsg; }
//     public String getMerchantOrderId() { return merchantOrderId; }
//     public BigDecimal getTotal() { return total; }
//     public Lineitems[] getLineitems() { return lineItems; }
// }


import com.google.gson.Gson;
import com.twocheckout.model.Authorization;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
        for (Map.Entry<String, String> entry : args.entrySet())
        {
            html.append( "<input type=\"hidden\" name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\"/>\n" );
        }
        html.append( "<input type=\"submit\" value=\"Checkout\" />\n</form>\n" );
        return html.toString();
    }

    public static String submit(HashMap<String, String> args) {
        StringBuilder html = new StringBuilder();
        html.append( "<form id=\"2checkout\" action=\"" + checkout_url() + "/checkout/purchase\" method=\"post\">\n" );
        for (Map.Entry<String, String> entry : args.entrySet())
        {
            html.append( "<input type=\"hidden\" name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\"/>\n" );
        }
        html.append( "</form>\n" );
        html.append( "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>" );
        return html.toString();
    }

    public static String url(HashMap<String, String> args) {
        String url = checkout_url() + "/checkout/purchase?";
        ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
        for (Map.Entry<String, String> entry : args.entrySet()) {
            params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
        }
        String paramString = URLEncodedUtils.format(params, "utf-8");
        return url += paramString;
    }

// Path: src/main/java/com/twocheckout/model/Authorization.java
// public class Authorization {
//     private String type;
//     private String responseCode;
//     private String currencyCode;
//     private String orderNumber;
//     private String transactionId;
//     private String recurrentInstallmentId;
//     private String responseMsg;
//     private String merchantOrderId;
//     private BigDecimal total;
//     private Lineitems[] lineItems;
// 
//     public String getType() { return type; }
//     public String getResponseCode() { return responseCode; }
//     public String getCurrencyCode() { return currencyCode; }
//     public String getOrderNumber() { return orderNumber; }
//     public String getTransactionId() { return transactionId; }
//     public String getRecurrentInstallmentId() { return recurrentInstallmentId; }
//     public String getResponseMsg() { return responseMsg; }
//     public String getMerchantOrderId() { return merchantOrderId; }
//     public BigDecimal getTotal() { return total; }
//     public Lineitems[] getLineitems() { return lineItems; }
// }


// Path: src/main/java/com/twocheckout/TwocheckoutCharge.java
import com.google.gson.Gson;
import com.twocheckout.model.Authorization;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;

        for (Map.Entry<String, String> entry : args.entrySet())
        {
            html.append( "<input type=\"hidden\" name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\"/>\n" );
        }
        html.append( "<input type=\"submit\" value=\"Checkout\" />\n</form>\n" );
        return html.toString();
    }

    public static String submit(HashMap<String, String> args) {
        StringBuilder html = new StringBuilder();
        html.append( "<form id=\"2checkout\" action=\"" + checkout_url() + "/checkout/purchase\" method=\"post\">\n" );
        for (Map.Entry<String, String> entry : args.entrySet())
        {
            html.append( "<input type=\"hidden\" name=\"" + entry.getKey() + "\" value=\"" + entry.getValue() + "\"/>\n" );
        }
        html.append( "</form>\n" );
        html.append( "<script type=\"text/javascript\">document.getElementById('2checkout').submit();</script>" );
        return html.toString();
    }

    public static String url(HashMap<String, String> args) {
        String url = checkout_url() + "/checkout/purchase?";
        ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
        for (Map.Entry<String, String> entry : args.entrySet()) {
            params.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
        }
        String paramString = URLEncodedUtils.format(params, "utf-8");
        return url += paramString;
    }

    public static Authorization authorize(HashMap<String, Object> args) throws TwocheckoutException {