All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.midtrans.httpclient.SnapApi Maven / Gradle / Ivy

Go to download

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

There is a newer version: 3.2.0
Show newest version
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");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy