com.payu.sdk.PayU Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-client Show documentation
Show all versions of api-client Show documentation
A fresh implementation of the PayU API Client for Android
The newest version!
package com.payu.sdk;
import com.payu.sdk.api.ApiClient;
import com.payu.sdk.api.ApiClient.Builder;
import com.payu.sdk.api.Callback;
import com.payu.sdk.api.model.Bank;
import com.payu.sdk.api.model.CreditCard;
import com.payu.sdk.api.model.Language;
import com.payu.sdk.api.model.Order;
import com.payu.sdk.api.model.PaymentMethods;
import com.payu.sdk.api.model.TransactionResponse;
import com.payu.sdk.api.model.mobile.DeviceIdentifierResponse;
import com.payu.sdk.api.model.mobile.SenderIdResponse;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Static access to a PayU Client, the easiest way to use PayU in your Android app.
* Example: {@code
* PayU.init(yourApiKey, yourApiLogin, yourMerchantId, appFingerprint, appPackageId);
* }
*/
public final class PayU {
private static ApiClient client;
/**
* Set the URI endpoint to send payments to. By default we'll send payments to
* the standard https://api.payulatam.com/payments-api endpoint, but you can override
* this if you are using STG API or another PayU Payments.
*
* @param paymentsURI the custom endpoint to send payments to.
*/
public static void setPaymentsURI(URI paymentsURI) {
client = getApiClientBuilder().paymentsURI(paymentsURI).build();
}
/**
* Set the URI endpoint to get reports to. By default we'll get reports to
* the standard https://api.payulatam.com/reports-api endpoint, but you can override
* this if you are using STG API or another PayU Reports.
*
* @param reportsURI the custom endpoint to obtain reports to.
*/
public static void setReportsURI(URI reportsURI) {
client = getApiClientBuilder().reportsURI(reportsURI).build();
}
/**
* Set the language used by the API to return the reply messages and errors.
*
* @param language the Language to use.
*/
public static void setLanguage(Language language) {
client = getApiClientBuilder().language(language).build();
}
/**
* Set the mode test in your transactions,"true" if it is a test request, "false" otherwise.
* Depending on the type of transaction or operation, the behavior varies depending on the value
* of this boolean.
*
* @param enabledTest the boolean
indicates the testing mode is enabled.
*/
public static void setEnabledTestMode(boolean enabledTest) {
client = getApiClientBuilder().enableTestMode(enabledTest).build();
}
/**
* Activate the logs in the SDK. No enable in Production Environments.
*
* @param enableLogs the boolean
indicates if the log is enabled.
*/
public static void setEnableLog(boolean enableLogs) {
client = getApiClientBuilder().enableLog(enableLogs).build();
}
/**
* Verifies connectivity with PayU Payments API.
*
* @param callback the callback
*/
public static void paymentsDoPing(Callback callback) {
getApiClient().paymentsDoPing(callback);
}
/**
* Obtains a list of active payments on the platform PayU.
*
* @param callback the callback
*/
public static void getPaymentMethods(Callback> callback) {
getApiClient().getPaymentMethods(callback);
}
public static void getListPSEBanks(Callback> callback) {
getApiClient().getListPSEBanks(callback);
}
/**
* Verifies connectivity with PayU Reports API.
*
* @param callback the callback
*/
public static void reportsDoPing(Callback callback) {
getApiClient().reportsDoPing(callback);
}
public static void doOrderDetailReportingById(Map parameters,
Callback callback) {
getApiClient().doOrderDetailReportingById(parameters, callback);
}
public static void doOrderDetailReportingByReferenceCode(Map parameters,
Callback> callback) {
getApiClient().doOrderDetailReportingByReferenceCode(parameters, callback);
}
public static void doTransactionResponseReporting(HashMap parameters,
Callback callback) {
getApiClient().doTransactionResponseReporting(parameters, callback);
}
public static void registerInstallation(Map parameters,
Callback callback) {
getApiClient().registerInstallation(parameters, callback);
}
public static void authorizeInstallation(Map parameters,
Callback callback) {
getApiClient().authorizeInstallation(parameters, callback);
}
public static void findDeviceTokens(Map parameters,
Callback> callback) {
getApiClient().findDeviceTokens(parameters, callback);
}
public static void getSenderId(Callback callback) {
getApiClient().getSenderId(callback);
}
/**
* Return the current {@link ApiClient ApiClient} instance.
*/
private static ApiClient getApiClient() {
if (client == null) {
throw new IllegalStateException("You must call PayU.init() before any other PayU methods");
}
return client;
}
/**
* Return the Api client {@link Builder builder}.
*
* @see ApiClient
*/
private static Builder getApiClientBuilder() {
return getApiClient().builder();
}
/**
* Initialize the static PayU client.
*
* @param apiKey your PayU API key from your PayU dashboard.
* @param apiLogin your PayU API login from your payU.
* @param applicationFingerprint the application Fingerprint
* @param applicationPackage the application package id
*/
public static void init(String apiKey, String apiLogin, String applicationFingerprint,
String applicationPackage) {
client = new Builder(apiKey, apiLogin, applicationFingerprint, applicationPackage).build();
}
}