コード例 #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 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;
  }