当前位置: 首页>>代码示例>>Java>>正文


Java Payment类代码示例

本文整理汇总了Java中securepay.jxa.api.Payment的典型用法代码示例。如果您正苦于以下问题:Java Payment类的具体用法?Java Payment怎么用?Java Payment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Payment类属于securepay.jxa.api包,在下文中一共展示了Payment类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doCapture

import securepay.jxa.api.Payment; //导入依赖的package包/类
public static Map<String, Object> doCapture(DispatchContext dctx, Map<String, Object> context) {
    Locale locale = (Locale) context.get("locale");
    Delegator delegator = dctx.getDelegator();
    GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
    GenericValue authTransaction = (GenericValue) context.get("authTrans");
    if (authTransaction == null) {
        authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
    }
    if (authTransaction == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale));
    }

    Properties props = buildScProperties(context, delegator);
    if (props == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingSecurityPayNotProperlyConfigurated", locale));
    }

    String merchantId = props.getProperty("merchantID");
    String serverURL = props.getProperty("serverurl");
    String processtimeout = props.getProperty("processtimeout");
    String pwd = props.getProperty("pwd");
    String enableamountround = props.getProperty("enableamountround");
    String currency = authTransaction.getString("currencyUomId");
    BigDecimal captureAmount = (BigDecimal) context.get("captureAmount");
    BigDecimal multiplyAmount = new BigDecimal(100);
    BigDecimal newAmount = null;
    int amont;

    if (enableamountround.equals("Y")) {
        newAmount = new BigDecimal(captureAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00");
    } else {
        newAmount = captureAmount;
    }

    if (currency.equals("JPY")) {
        amont = newAmount.intValue();
    } else {
        amont = newAmount.multiply(multiplyAmount).intValue();
    }

    Payment payment = new Payment();
    payment.setServerURL(serverURL);
    payment.setProcessTimeout(Integer.valueOf(processtimeout));
    payment.setMerchantId(merchantId);
    Txn txn = payment.addTxn(11, (String) orderPaymentPreference.get("orderId"));
    txn.setTxnSource(8);
    txn.setAmount(Integer.toString(amont));
    txn.setPreauthId(authTransaction.getString("referenceNum"));

    // Send payment to SecurePay for processing
    boolean processed = payment.process(pwd);

    Map<String, Object> result = ServiceUtil.returnSuccess();
    if (UtilValidate.isEmpty(processed)) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingSecurityPayPaymentWasNotSent", locale));
    } else {
        if (payment.getCount() == 1){
            Txn resp = payment.getTxn(0);
            boolean approved = resp.getApproved();
            if (approved == false){
                result.put("captureResult", false);
                result.put("captureRefNum", authTransaction.getString("referenceNum"));
                result.put("captureAmount", BigDecimal.ZERO);
            } else {
                result.put("captureResult", true);
                result.put("captureAmount", captureAmount);
                result.put("captureRefNum", resp.getTxnId());
            }
            result.put("captureFlag", "C");
            result.put("captureCode", resp.getResponseCode());
            result.put("captureMessage", resp.getResponseText());
        }
    }
    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:79,代码来源:SecurePayPaymentServices.java

示例2: doVoid

import securepay.jxa.api.Payment; //导入依赖的package包/类
public static Map<String, Object> doVoid(DispatchContext dctx, Map<String, Object> context) {
    Locale locale = (Locale) context.get("locale");
    Delegator delegator = dctx.getDelegator();
    GenericValue orderPaymentPreference = (GenericValue) context.get("orderPaymentPreference");
    GenericValue authTransaction = (GenericValue) context.get("authTrans");
    if (authTransaction == null) {
        authTransaction = PaymentGatewayServices.getAuthTransaction(orderPaymentPreference);
    }
    if (authTransaction == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale));
    }

    Properties props = buildScProperties(context, delegator);
    if (props == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingSecurityPayNotProperlyConfigurated", locale));
    }

    String merchantId = props.getProperty("merchantID");
    String serverURL = props.getProperty("serverurl");
    String processtimeout = props.getProperty("processtimeout");
    String pwd = props.getProperty("pwd");
    String enableamountround = props.getProperty("enableamountround");
    String currency = authTransaction.getString("currencyUomId");
    BigDecimal releaseAmount = (BigDecimal) context.get("releaseAmount");
    BigDecimal multiplyAmount = new BigDecimal(100);
    BigDecimal newAmount = null;
    int amont;

    if (enableamountround.equals("Y")) {
        newAmount = new BigDecimal(releaseAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00");
    } else {
        newAmount = releaseAmount;
    }

    if (currency.equals("JPY")) {
        amont = newAmount.intValue();
    } else {
        amont = newAmount.multiply(multiplyAmount).intValue();
    }

    Payment payment = new Payment();
    payment.setServerURL(serverURL);
    payment.setProcessTimeout(Integer.valueOf(processtimeout));
    payment.setMerchantId(merchantId);
    Txn txn = payment.addTxn(6, (String) orderPaymentPreference.get("orderId"));
    txn.setTxnSource(8);
    txn.setAmount(Integer.toString(amont));
    txn.setTxnId(authTransaction.getString("referenceNum"));

    // Send payment to SecurePay for processing
    boolean processed = payment.process(pwd);

    Map<String, Object> result = ServiceUtil.returnSuccess();
    if (UtilValidate.isEmpty(processed)) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingSecurityPayPaymentWasNotSent", locale));
    } else {
        if (payment.getCount() == 1){
            Txn resp = payment.getTxn(0);
            boolean approved = resp.getApproved();
            if (approved == false){
                result.put("releaseResult", false);
                result.put("releaseRefNum", authTransaction.getString("referenceNum"));
                result.put("releaseAmount", BigDecimal.ZERO);
            } else {
                result.put("releaseResult", true);
                result.put("releaseAmount", releaseAmount);
                result.put("releaseRefNum", resp.getTxnId());
            }
            result.put("releaseFlag", "U");
            result.put("releaseCode", resp.getResponseCode());
            result.put("releaseMessage", resp.getResponseText());
        }
    }
    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:79,代码来源:SecurePayPaymentServices.java

示例3: doCredit

import securepay.jxa.api.Payment; //导入依赖的package包/类
public static Map<String, Object> doCredit(DispatchContext dctx, Map<String, Object> context) {
    Locale locale = (Locale) context.get("locale");
    Delegator delegator = dctx.getDelegator();
    // generate the request/properties
    Properties props = buildScProperties(context, delegator);
    if (props == null) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingSecurityPayNotProperlyConfigurated", locale));
    }

    String merchantId = props.getProperty("merchantID");
    String serverURL = props.getProperty("serverurl");
    String processtimeout = props.getProperty("processtimeout");
    String pwd = props.getProperty("pwd");
    String enableamountround = props.getProperty("enableamountround");
    String referenceCode = (String) context.get("referenceCode");
    String currency = (String) context.get("currency");
    String cardSecurityCode = (String) context.get("cardSecurityCode");
    BigDecimal creditAmount = (BigDecimal) context.get("creditAmount");
    BigDecimal multiplyAmount = new BigDecimal(100);
    BigDecimal newAmount = null;
    int amont;

    if (enableamountround.equals("Y")) {
        newAmount = new BigDecimal(creditAmount.setScale(0, BigDecimal.ROUND_HALF_UP)+".00");
    } else {
        newAmount = creditAmount;
    }

    if (currency.equals("JPY")) {
        amont = newAmount.intValue();
    } else {
        amont = newAmount.multiply(multiplyAmount).intValue();
    }

    GenericValue creditCard = (GenericValue) context.get("creditCard");
    Payment payment = new Payment();
    payment.setServerURL(serverURL);
    payment.setProcessTimeout(Integer.valueOf(processtimeout));
    payment.setMerchantId(merchantId);

    Txn txn = payment.addTxn(0, referenceCode);
    txn.setTxnSource(8);
    txn.setAmount(Integer.toString(amont));
    txn.setCardNumber((String) creditCard.get("cardNumber"));
    String expiryDate = (String) creditCard.get("expireDate");
    txn.setExpiryDate(expiryDate.substring(0, 3) + expiryDate.substring(5));
    if (UtilValidate.isNotEmpty(cardSecurityCode)) {
        txn.setCVV(cardSecurityCode);
    }

    // Send payment to SecurePay for processing
    boolean processed = payment.process(pwd);

    Map<String, Object> result = ServiceUtil.returnSuccess();
    if (UtilValidate.isEmpty(processed)) {
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, 
                "AccountingSecurityPayPaymentWasNotSent", locale));
    } else {
        if (payment.getCount() == 1) {
            Txn resp = payment.getTxn(0);
            boolean approved = resp.getApproved();
            if (approved == false){
                result.put("creditResult", false);
                result.put("creditRefNum", "N/A");
                result.put("creditAmount", BigDecimal.ZERO);
            } else {
                result.put("creditResult", true);
                result.put("creditAmount", creditAmount);
                result.put("creditRefNum", resp.getTxnId());
            }
            result.put("creditCode", resp.getResponseCode());
            result.put("creditMessage", resp.getResponseText());
        }
    }
    return result;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:78,代码来源:SecurePayPaymentServices.java


注:本文中的securepay.jxa.api.Payment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。