Package in.juspay.model

Examples of in.juspay.model.Promotion


            orderStatusResponse.setPaymentGatewayResponse(paymentGatewayResponse);
        }

        JSONObject promotionResponse = (JSONObject) jsonResponse.get("promotion");
        if(promotionResponse != null) {
            Promotion promotion = assemblePromotionObjectFromJSON(promotionResponse);
            orderStatusResponse.setPromotion(promotion);
        }

        JSONArray refunds = (JSONArray) jsonResponse.get("refunds");
        if(refunds != null && refunds.size() > 0) {
View Full Code Here


     *  - An instance of JSONObject that contains promotion information.
     * @return
     *  - Promotion object that corresponds to the json input.
     */
    private Promotion assemblePromotionObjectFromJSON(JSONObject jsonObject) {
        Promotion promotion = new Promotion();
        promotion.setId((String) jsonObject.get("id"));
        promotion.setOrderId((String) jsonObject.get("order_id"));
        promotion.setDiscountAmount(Double.valueOf(jsonObject.get("discount_amount").toString()));
        String status = (String) jsonObject.get("status");
        promotion.setStatus(PromotionStatus.valueOf(status));

        ArrayList<JSONObject> conditions = (ArrayList<JSONObject>) jsonObject.get("conditions");
        ArrayList<JSONObject> rules = (ArrayList<JSONObject>) jsonObject.get("rules");

        List<PromotionCondition> promotionConditions = new ArrayList<PromotionCondition>();
        for(JSONObject jsonCondition : (conditions != null ? conditions : rules)) {
            PromotionCondition promotionCondition = new PromotionCondition();
            promotionCondition.setDimension((String) jsonCondition.get("dimension"));
            promotionCondition.setValue((String) jsonCondition.get("value"));
            promotionConditions.add(promotionCondition);
        }
        promotion.setPromotionConditions(promotionConditions);
        return promotion;
    }
View Full Code Here

        String response = makeServiceCall(url, serializedParams);
        JSONObject jsonResponse = (JSONObject) JSONValue.parse(response);

        CreatePromotionResponse promotionResponse = new CreatePromotionResponse();
        promotionResponse.setSuccess(true);
        Promotion promotion = assemblePromotionObjectFromJSON(jsonResponse);
        promotionResponse.setPromotion(promotion);
        return promotionResponse;
    }
View Full Code Here

        String response = makeServiceCall(url, serializedParams);
        JSONObject jsonResponse = (JSONObject) JSONValue.parse(response);

        DeactivatePromotionResponse deactivatePromotionResponse = new DeactivatePromotionResponse();
        deactivatePromotionResponse.setSuccess(true);
        Promotion promotion = assemblePromotionObjectFromJSON(jsonResponse);
        deactivatePromotionResponse.setPromotion(promotion);
        return deactivatePromotionResponse;
    }
View Full Code Here

        CreatePromotionResponse promotionResponse = juspayService.createPromotion(promotionRequest);
        assertTrue(promotionResponse.isSuccess());
        assertNotNull(promotionResponse.getPromotion());

        Promotion promotion = promotionResponse.getPromotion();
        assertEquals(orderId, promotion.getOrderId());
        assertEquals(PromotionStatus.ACTIVE, promotion.getStatus());
        assertEquals(new Double(1.00), promotion.getDiscountAmount());

        // test /order/status API as well

        GetOrderStatusRequest orderStatusRequest = new GetOrderStatusRequest();
        orderStatusRequest.setOrderId(orderId);
View Full Code Here

TOP

Related Classes of in.juspay.model.Promotion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.