本文整理汇总了Java中org.ofbiz.accounting.payment.PaymentGatewayServices类的典型用法代码示例。如果您正苦于以下问题:Java PaymentGatewayServices类的具体用法?Java PaymentGatewayServices怎么用?Java PaymentGatewayServices使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaymentGatewayServices类属于org.ofbiz.accounting.payment包,在下文中一共展示了PaymentGatewayServices类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ccRelease
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccRelease(DispatchContext ctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
Delegator delegator = ctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
}
Map<String, Object> reply = voidTransaction(authTransaction, context, delegator);
if (ServiceUtil.isError(reply)) {
return reply;
}
Map<String, Object> results = ServiceUtil.returnSuccess();
context.put("x_Amount", ((BigDecimal) context.get("releaseAmount")).toPlainString()); // hack for releaseAmount
results.putAll(processReleaseTransResult(context, reply));
return results;
}
示例2: ccReleaseNoop
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccReleaseNoop(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
}
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("releaseResult", Boolean.valueOf(true));
result.put("releaseCode", authTransaction.getString("gatewayCode"));
result.put("releaseAmount", authTransaction.getBigDecimal("amount"));
result.put("releaseRefNum", authTransaction.getString("referenceNum"));
result.put("releaseFlag", authTransaction.getString("gatewayFlag"));
result.put("releaseMessage", "Approved.");
return result;
}
示例3: ccRelease
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccRelease(DispatchContext ctx, Map<String, Object> context) {
Debug.logInfo("SagePay - Entered ccRelease", module);
Debug.logInfo("SagePay ccRelease context : " + context, module);
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
}
context.put("authTransaction", authTransaction);
Map<String, Object> response = processCardReleasePayment(ctx, context);
Debug.logInfo("SagePay ccRelease response : " + response, module);
return response;
}
示例4: ccRelease
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccRelease(DispatchContext ctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
Delegator delegator = ctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
}
Map<String, Object> reply = voidTransaction(authTransaction, context, delegator);
if (ServiceUtil.isError(reply)) {
return reply;
}
Map<String, Object> results = ServiceUtil.returnSuccess();
context.put("x_Amount", context.get("releaseAmount")); // hack for releaseAmount
results.putAll(processReleaseTransResult(context, reply));
return results;
}
示例5: ccCapture
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccCapture(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
}
Document captureRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
"PostAuth", (BigDecimal) context.get("captureAmount"), delegator);
Document captureResponseDoc = null;
try {
captureResponseDoc = sendRequest(captureRequestDoc, (String) context.get("paymentConfig"), delegator);
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(captureResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("captureResult", new Boolean(false));
result.put("captureAmount", BigDecimal.ZERO);
result.put("captureRefNum", getReferenceNum(captureResponseDoc));
List<String> messages = getMessageList(captureResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processCaptureResponse(captureResponseDoc);
}
示例6: ccRelease
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccRelease(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
}
Document releaseRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"), "Void", null, delegator);
Document releaseResponseDoc = null;
try {
releaseResponseDoc = sendRequest(releaseRequestDoc, (String) context.get("paymentConfig"), delegator);
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(releaseResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("releaseResult", new Boolean(false));
result.put("releaseAmount", BigDecimal.ZERO);
result.put("releaseRefNum", getReferenceNum(releaseResponseDoc));
List<String> messages = getMessageList(releaseResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processReleaseResponse(releaseResponseDoc);
}
示例7: ccRefund
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccRefund(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
}
// Although refunds are applied to captured transactions, using the auth reference number is ok here
// Related auth and capture transactions will always have the same reference number
Document refundRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
"Credit", (BigDecimal) context.get("refundAmount"), delegator);
Document refundResponseDoc = null;
try {
refundResponseDoc = sendRequest(refundRequestDoc, (String) context.get("paymentConfig"), delegator);
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(refundResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("refundResult", new Boolean(false));
result.put("refundAmount", BigDecimal.ZERO);
result.put("refundRefNum", getReferenceNum(refundResponseDoc));
List<String> messages = getMessageList(refundResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processRefundResponse(refundResponseDoc);
}
示例8: ccReAuth
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccReAuth(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
Delegator delegator = dctx.getDelegator();
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotReauth", locale));
}
Document reauthRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
"RePreAuth", (BigDecimal) context.get("reauthAmount"), delegator);
Document reauthResponseDoc = null;
try {
reauthResponseDoc = sendRequest(reauthRequestDoc, (String) context.get("paymentConfig"), delegator);
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(reauthResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("reauthResult", new Boolean(false));
result.put("reauthAmount", BigDecimal.ZERO);
result.put("reauthRefNum", getReferenceNum(reauthResponseDoc));
List<String> messages = getMessageList(reauthResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processReAuthResponse(reauthResponseDoc);
}
示例9: ccCapture
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccCapture(DispatchContext ctx, Map<String, Object> context) {
Debug.logInfo("SagePay - Entered ccCapture", module);
Debug.logInfo("SagePay ccCapture context : " + context, module);
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
context.put("authTransaction", authTransaction);
Map<String, Object> response = processCardCapturePayment(ctx, context);
Debug.logInfo("SagePay ccCapture response : " + response, module);
Debug.logInfo("SagePay - Exiting ccCapture", module);
return response;
}
示例10: finAccountReleaseAuth
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> finAccountReleaseAuth(DispatchContext dctx, Map<String, Object> context) {
LocalDispatcher dispatcher = dctx.getDispatcher();
GenericValue userLogin = (GenericValue) context.get("userLogin");
GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference");
Locale locale = (Locale) context.get("locale");
String err = UtilProperties.getMessage(resourceError, "AccountingFinAccountCannotBeExpired", locale);
try {
// expire the related financial authorization transaction
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(paymentPref);
if (authTransaction == null) {
return ServiceUtil.returnError(err + UtilProperties.getMessage(resourceError,
"AccountingFinAccountCannotFindAuthorization", locale));
}
Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "finAccountAuthId", authTransaction.get("referenceNum"));
Map<String, Object> serviceResults = dispatcher.runSync("expireFinAccountAuth", input);
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("releaseRefNum", authTransaction.getString("referenceNum"));
result.put("releaseAmount", authTransaction.getBigDecimal("amount"));
result.put("releaseResult", Boolean.TRUE);
// if there's an error, don't release
if (ServiceUtil.isError(serviceResults)) {
return ServiceUtil.returnError(err + ServiceUtil.getErrorMessage(serviceResults));
}
return result;
} catch (GenericServiceException e) {
Debug.logError(e, e.getMessage(), module);
return ServiceUtil.returnError(err + e.getMessage());
}
}
示例11: ccCapture
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccCapture(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
}
Document captureRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
"PostAuth", (BigDecimal) context.get("captureAmount"));
Document captureResponseDoc = null;
try {
captureResponseDoc = sendRequest(captureRequestDoc, (String) context.get("paymentConfig"));
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(captureResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("captureResult", new Boolean(false));
result.put("captureAmount", BigDecimal.ZERO);
result.put("captureRefNum", getReferenceNum(captureResponseDoc));
List<String> messages = getMessageList(captureResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processCaptureResponse(captureResponseDoc);
}
示例12: ccRelease
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccRelease(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
}
Document releaseRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"), "Void", null);
Document releaseResponseDoc = null;
try {
releaseResponseDoc = sendRequest(releaseRequestDoc, (String) context.get("paymentConfig"));
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(releaseResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("releaseResult", new Boolean(false));
result.put("releaseAmount", BigDecimal.ZERO);
result.put("releaseRefNum", getReferenceNum(releaseResponseDoc));
List<String> messages = getMessageList(releaseResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processReleaseResponse(releaseResponseDoc);
}
示例13: ccRefund
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccRefund(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotRefund", locale));
}
// Although refunds are applied to captured transactions, using the auth reference number is ok here
// Related auth and capture transactions will always have the same reference number
Document refundRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
"Credit", (BigDecimal) context.get("refundAmount"));
Document refundResponseDoc = null;
try {
refundResponseDoc = sendRequest(refundRequestDoc, (String) context.get("paymentConfig"));
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(refundResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("refundResult", new Boolean(false));
result.put("refundAmount", BigDecimal.ZERO);
result.put("refundRefNum", getReferenceNum(refundResponseDoc));
List<String> messages = getMessageList(refundResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processRefundResponse(refundResponseDoc);
}
示例14: ccReAuth
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> ccReAuth(DispatchContext dctx, Map<String, Object> context) {
Locale locale = (Locale) context.get("locale");
GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
GenericValue authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
if (authTransaction == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPaymentTransactionAuthorizationNotFoundCannotReauth", locale));
}
Document reauthRequestDoc = buildSecondaryTxRequest(context, authTransaction.getString("referenceNum"),
"RePreAuth", (BigDecimal) context.get("reauthAmount"));
Document reauthResponseDoc = null;
try {
reauthResponseDoc = sendRequest(reauthRequestDoc, (String) context.get("paymentConfig"));
} catch (ClearCommerceException cce) {
return ServiceUtil.returnError(cce.getMessage());
}
if (getMessageListMaxSev(reauthResponseDoc) > 4) {
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("reauthResult", new Boolean(false));
result.put("reauthAmount", BigDecimal.ZERO);
result.put("reauthRefNum", getReferenceNum(reauthResponseDoc));
List<String> messages = getMessageList(reauthResponseDoc);
if (UtilValidate.isNotEmpty(messages)) {
result.put("internalRespMsgs", messages);
}
return result;
}
return processReAuthResponse(reauthResponseDoc);
}
示例15: doAuthorization
import org.ofbiz.accounting.payment.PaymentGatewayServices; //导入依赖的package包/类
public static Map<String, Object> doAuthorization(DispatchContext dctx, Map<String, Object> context) {
Delegator delegator = dctx.getDelegator();
String orderId = (String) context.get("orderId");
BigDecimal processAmount = (BigDecimal) context.get("processAmount");
GenericValue payPalPaymentMethod = (GenericValue) context.get("payPalPaymentMethod");
OrderReadHelper orh = new OrderReadHelper(delegator, orderId);
GenericValue payPalConfig = getPaymentMethodGatewayPayPal(dctx, context, PaymentGatewayServices.AUTH_SERVICE_TYPE);
Locale locale = (Locale) context.get("locale");
NVPEncoder encoder = new NVPEncoder();
encoder.add("METHOD", "DoAuthorization");
encoder.add("TRANSACTIONID", payPalPaymentMethod.getString("transactionId"));
encoder.add("AMT", processAmount.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
encoder.add("TRANSACTIONENTITY", "Order");
String currency = (String) context.get("currency");
if (currency == null) {
currency = orh.getCurrency();
}
encoder.add("CURRENCYCODE", currency);
NVPDecoder decoder = null;
try {
decoder = sendNVPRequest(payPalConfig, encoder);
} catch (PayPalException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
}
if (decoder == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"AccountingPayPalUnknownError", locale));
}
Map<String, Object> result = ServiceUtil.returnSuccess();
Map<String, String> errors = getErrorMessageMap(decoder);
if (UtilValidate.isNotEmpty(errors)) {
result.put("authResult", false);
result.put("authRefNum", "N/A");
result.put("processAmount", BigDecimal.ZERO);
if (errors.size() == 1) {
Map.Entry<String, String> error = errors.entrySet().iterator().next();
result.put("authCode", error.getKey());
result.put("authMessage", error.getValue());
} else {
result.put("authMessage", "Multiple errors occurred, please refer to the gateway response messages");
result.put("internalRespMsgs", errors);
}
} else {
result.put("authResult", true);
result.put("processAmount", new BigDecimal(decoder.get("AMT")));
result.put("authRefNum", decoder.get("TRANSACTIONID"));
}
//TODO: Look into possible PAYMENTSTATUS and PENDINGREASON return codes, it is unclear what should be checked for this type of transaction
return result;
}