com.midtrans.httpclient.SnapApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-library Show documentation
Show all versions of java-library Show documentation
This is the Official Java API client/library for Midtrans Payment API. Visit https://midtrans.com. More information about the product and see documentation at http://docs.midtrans.com for more technical details. This library used java version 1.8
package com.midtrans.httpclient;
import com.midtrans.Config;
import com.midtrans.httpclient.error.MidtransError;
import com.midtrans.utils.Utility;
import org.json.JSONObject;
import java.util.Map;
public class SnapApi {
public static JSONObject createTransaction(Map requestBody, Config configOptions) throws MidtransError {
return new JSONObject((String) APIHttpClient.request(
APIHttpClient.POST,
configOptions.getSnapApiURL(),
configOptions,
requestBody
));
}
public static JSONObject createTransaction(Map requestBody) throws MidtransError {
return new JSONObject((String) APIHttpClient.request(
APIHttpClient.POST,
Config.getGlobalConfig().getSnapApiURL(),
Config.getGlobalConfig(),
requestBody
));
}
public static String createTransactionToken(Map requestBody) throws MidtransError {
return createTransaction(requestBody).getString("token");
}
public static String createTransactionToken(Map requestBody, Config configOptions) throws MidtransError {
return createTransaction(requestBody, configOptions).getString("token");
}
public static String createTransactionRedirectUrl(Map requestBody) throws MidtransError {
return createTransaction(requestBody).getString("redirect_url");
}
public static String createTransactionRedirectUrl(Map requestBody, Config configOptions) throws MidtransError {
return createTransaction(requestBody, configOptions).getString("redirect_url");
}
}