コード例 #1
0
  private HkPaymentResponse createPayment(
      String gatewayOrderId,
      String gatewayReferenceId,
      String rrn,
      String respMsg,
      String txnType,
      String amount,
      String authIdCode) {
    HkPaymentResponse hkPaymentResponse =
        new HkPaymentResponse(
            gatewayOrderId,
            gatewayReferenceId,
            respMsg,
            EnumGateway.EBS.asGateway(),
            null,
            null,
            rrn,
            authIdCode,
            NumberUtils.toDouble(amount));

    if (txnType.equalsIgnoreCase(EnumPaymentTransactionType.SALE.getName())) {
      hkPaymentResponse.setGatewayOrderId(gatewayOrderId);
      hkPaymentResponse.setTransactionType(EnumPaymentTransactionType.SALE.getName());
    } else if (txnType.equalsIgnoreCase(EnumPaymentTransactionType.REFUND.getName())) {
      hkPaymentResponse.setTransactionType(EnumPaymentTransactionType.REFUND.getName());
    }
    return hkPaymentResponse;
  }
コード例 #2
0
  @Override
  public HkPaymentResponse refundPayment(Payment basePayment, Double amount)
      throws HealthkartPaymentGatewayException {
    String baseGatewayOrderId = basePayment.getGatewayOrderId();
    String gatewayReferenceId = basePayment.getGatewayReferenceId();
    HkPaymentResponse hkRefundPaymentResponse = null;

    if (baseGatewayOrderId != null && gatewayReferenceId != null) {
      try {
        Element element =
            callPaymentGateway(
                null,
                gatewayReferenceId,
                null,
                amount.toString(),
                EbsPaymentGatewayWrapper.TXN_ACTION_REFUND);

        hkRefundPaymentResponse =
            verifyAndCreateHkResponsePayment(
                element, baseGatewayOrderId, EnumPaymentTransactionType.REFUND.getName());
      } catch (Exception e) {
        logger.debug("Ebs Payment gateway exception :", e);
      }

    } else {
      throw new HealthkartPaymentGatewayException(
          HealthkartPaymentGatewayException.Error.PAYMENT_NOT_UPDATED);
    }

    return hkRefundPaymentResponse;
  }
コード例 #3
0
 private void updateResponseStatus(
     HkPaymentResponse hkPaymentResponse,
     String transactionType,
     String isFlagged,
     String status,
     String ebsTransactionType) {
   if (transactionType.equalsIgnoreCase(EnumPaymentTransactionType.REFUND.getName())) {
     updateRefundPaymentStatus(hkPaymentResponse, status);
   } else {
     updateSalePaymentStatus(hkPaymentResponse, isFlagged, ebsTransactionType);
   }
 }
コード例 #4
0
  @Override
  public List<HkPaymentResponse> seekPaymentFromGateway(Payment basePayment)
      throws HealthkartPaymentGatewayException {
    String gatewayOrderId = basePayment.getGatewayOrderId();
    List<HkPaymentResponse> gatewayPaymentList = new ArrayList<HkPaymentResponse>();

    try {

      // call payment gateway and get the base payment object
      Element element =
          callPaymentGateway(
              gatewayOrderId, null, null, null, EbsPaymentGatewayWrapper.TXN_ACTION_STATUS);
      HkPaymentResponse baseGatewayPayment =
          verifyAndCreateHkResponsePayment(
              element, gatewayOrderId, EnumPaymentTransactionType.SALE.getName());
      List<Payment> paymentList =
          paymentDao.searchPayments(null, null, null, null, null, null, null, basePayment, null);

      gatewayPaymentList.add(baseGatewayPayment);

      // again call gateway and update all child payment list
      if (paymentList != null) {
        for (Payment payment : paymentList) {
          String gatewayReferenceId = payment.getGatewayReferenceId();
          String rrn = payment.getRrn();
          if (gatewayReferenceId != null && rrn != null) {
            Element ele =
                callPaymentGateway(
                    gatewayOrderId,
                    payment.getGatewayReferenceId(),
                    payment.getRrn(),
                    null,
                    EbsPaymentGatewayWrapper.TXN_ACTION_STATUS_PAYMENT_ID);
            HkPaymentResponse childPayment =
                verifyAndCreateHkResponsePayment(
                    ele, payment.getGatewayOrderId(), EnumPaymentTransactionType.REFUND.getName());
            gatewayPaymentList.add(childPayment);
          } else {
            HkPaymentResponse hkPaymentResponse =
                createPayment(
                    payment.getGatewayOrderId(),
                    null,
                    null,
                    payment.getErrorLog(),
                    EnumPaymentTransactionType.REFUND.getName(),
                    payment.getAmount().toString(),
                    null);
            hkPaymentResponse.setHKPaymentStatus(EnumHKPaymentStatus.FAILURE);
            gatewayPaymentList.add(hkPaymentResponse);
          }
        }
      }

    } catch (Exception e) {
      logger.debug("Ebs Payment gateway exception :", e);
      // throw new
      // HealthkartPaymentGatewayException(HealthkartPaymentGatewayException.Error.UNKNOWN);
    }

    return gatewayPaymentList;
  }