
zw.co.paynow.parsers.PaymentParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-sdk Show documentation
Show all versions of java-sdk Show documentation
This project contains libraries to interface with Zimbabwe's Leading Payments Gateway, Paynow REST API.
package zw.co.paynow.parsers;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* Used to parse various 'Payment' related fields
*/
public class PaymentParser {
public static String flattenCollection(HashMap items) {
StringBuilder sb = new StringBuilder();
int i = 1;
for (Map.Entry pair : items.entrySet()) {
sb.append(pair.getKey());
//Don't put comma at last item in cart
if (!(i == items.size())) {
sb.append(", ");
}
i++;
}
return sb.toString();
}
/**
* Compute the total of the values in a Payment object
*
* @param items The collection of values
* @return The total of the items
*/
public static BigDecimal addCollectionValues(HashMap items) {
BigDecimal number = BigDecimal.ZERO;
for (Map.Entry pair : items.entrySet()) {
number = number.add(pair.getValue());
}
return number;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy