OrderReadHelper orh = new OrderReadHelper(delegator, orderId);
String productStoreId = orh.getProductStoreId();
try {
// if the store requires pin codes, then validate pin code against card number, and the gift certificate's finAccountId is the gift card's card number
// otherwise, the gift card's card number is an ecrypted string, which must be decoded to find the FinAccount
GenericValue giftCertSettings = delegator.findByPrimaryKeyCache("ProductStoreFinActSetting", UtilMisc.toMap("productStoreId", productStoreId, "finAccountTypeId", FinAccountHelper.giftCertFinAccountTypeId));
GenericValue finAccount = null;
String finAccountId = null;
if (UtilValidate.isNotEmpty(giftCertSettings)) {
if ("Y".equals(giftCertSettings.getString("requirePinCode"))) {
if (validatePin(delegator, giftCard.getString("cardNumber"), giftCard.getString("pinNumber"))) {