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

com.safecharge.util.RequestUtils Maven / Gradle / Ivy

Go to download

SafeCharge’s REST API SDK for Java provides developer tools for accessing Safecharge's REST API. SafeCharge’s REST API is a simple, easy to use, secure and stateless API, which enables online merchants and service providers to process consumer payments through SafeCharge’s payment gateway. The API supports merchants of all levels of PCI certification, from their online and mobile merchant applications, and is compatible with a large variety of payment options, i.e. payment cards, alternative payment methods, etc.

There is a newer version: 1.7.11
Show newest version
package com.safecharge.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * Copyright (C) 2007-2017 SafeCharge International Group Limited.
 * 

* Utility class with helper methods for calculating some of the params needed when creating a request to Safecharge * * @author Nikola Dichev * @since 2/17/2017 */ public class RequestUtils { private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); private RequestUtils() { } /** * This method is used to calculate the current timestamp of a request. *

* The format of the returned String is "yyyyMMddHHmmss". * * @return the current time as a String */ public static String calculateTimestamp() { Calendar cal = new GregorianCalendar(); sdf.setTimeZone(cal.getTimeZone()); return sdf.format(cal.getTime()); } /** * This method is used to calculate the clientRequestId parameter of a request. * * @param timestamp the timestamp to generate clientRequestId from. It should be in "yyyyMMddHHmmss" format * @return the clientRequestId or -1 if it can't be calculated */ public static String calculateClientRequestId(String timestamp) { try { return String.valueOf(sdf.parse(timestamp) .getTime()); } catch (ParseException e) { return "-1"; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy