Search in sources :

Example 1 with GsmaParty

use of org.mifos.connector.common.gsma.dto.GsmaParty in project ph-ee-connector-mpesa by openMF.

the class SafaricomUtils method channelRequestConvertor.

public BuyGoodsPaymentRequestDTO channelRequestConvertor(TransactionChannelC2BRequestDTO transactionChannelRequestDTO) {
    logger.info("TransactionChannelCollectionRequestDTO chile converting " + transactionChannelRequestDTO);
    BuyGoodsPaymentRequestDTO buyGoodsPaymentRequestDTO = new BuyGoodsPaymentRequestDTO();
    mpesaProps = mpesaUtils.setMpesaProperties();
    long amount = Long.parseLong(transactionChannelRequestDTO.getAmount().getAmount().trim());
    // 123; //Long.parseLong(sdf.format(new Date()));
    long timestamp = getTimestamp();
    long payer;
    GsmaParty[] party = transactionChannelRequestDTO.getPayer();
    if (party[0].getKey().equals("MSISDN")) {
        // case where 1st array element is MSISDN
        payer = Long.parseLong(party[0].getValue().trim());
    } else {
        // case where 1st array element is ACCOUNTID
        payer = Long.parseLong(party[1].getValue().trim());
    }
    buyGoodsPaymentRequestDTO.setTimestamp("" + timestamp);
    buyGoodsPaymentRequestDTO.setCallBackURL(host + callbackEndpoint);
    buyGoodsPaymentRequestDTO.setPartyA(payer);
    buyGoodsPaymentRequestDTO.setPhoneNumber(payer);
    buyGoodsPaymentRequestDTO.setPartyB(mpesaProps.getTill());
    buyGoodsPaymentRequestDTO.setBusinessShortCode(mpesaProps.getBusinessShortCode());
    buyGoodsPaymentRequestDTO.setAmount(amount);
    buyGoodsPaymentRequestDTO.setPassword(getPassword("" + mpesaProps.getBusinessShortCode(), mpesaProps.getPassKey(), "" + timestamp));
    buyGoodsPaymentRequestDTO.setTransactionType(MPESA_BUY_GOODS_TRANSACTION_TYPE);
    buyGoodsPaymentRequestDTO.setTransactionDesc("Payment from account id" + transactionChannelRequestDTO.getPayer()[1].getValue());
    buyGoodsPaymentRequestDTO.setAccountReference("Payment to " + mpesaProps.getBusinessShortCode());
    logger.info("Values from Safaricom utils: Shortcode - " + mpesaProps.getBusinessShortCode() + " Till -" + mpesaProps.getTill());
    return buyGoodsPaymentRequestDTO;
}
Also used : GsmaParty(org.mifos.connector.common.gsma.dto.GsmaParty) BuyGoodsPaymentRequestDTO(org.mifos.connector.mpesa.dto.BuyGoodsPaymentRequestDTO)

Example 2 with GsmaParty

use of org.mifos.connector.common.gsma.dto.GsmaParty in project ph-ee-connector-mpesa by openMF.

the class SafaricomUtils method channelRequestConvertor.

public BuyGoodsPaymentRequestDTO channelRequestConvertor(TransactionChannelCollectionRequestDTO transactionChannelRequestDTO) {
    logger.info("TransactionChannelCollectionRequestDTO chile converting " + transactionChannelRequestDTO);
    BuyGoodsPaymentRequestDTO buyGoodsPaymentRequestDTO = new BuyGoodsPaymentRequestDTO();
    long amount = Long.parseLong(transactionChannelRequestDTO.getAmount().getAmount().trim());
    // 123; //Long.parseLong(sdf.format(new Date()));
    long timestamp = getTimestamp();
    long payer;
    GsmaParty[] party = transactionChannelRequestDTO.getPayer();
    if (party[0].getKey().equals("MSISDN")) {
        // case where 1st array element is MSISDN
        payer = Long.parseLong(party[0].getValue().trim());
    } else {
        // case where 1st array element is ACCOUNTID
        payer = Long.parseLong(party[1].getValue().trim());
    }
    buyGoodsPaymentRequestDTO.setTimestamp("" + timestamp);
    buyGoodsPaymentRequestDTO.setCallBackURL(host + callbackEndpoint);
    buyGoodsPaymentRequestDTO.setPartyA(payer);
    buyGoodsPaymentRequestDTO.setPhoneNumber(payer);
    buyGoodsPaymentRequestDTO.setPartyB(tillNumber);
    buyGoodsPaymentRequestDTO.setBusinessShortCode(businessShortCode);
    buyGoodsPaymentRequestDTO.setAmount(amount);
    buyGoodsPaymentRequestDTO.setPassword(getPassword("" + businessShortCode, passKey, "" + timestamp));
    buyGoodsPaymentRequestDTO.setTransactionType(MPESA_BUY_GOODS_TRANSACTION_TYPE);
    buyGoodsPaymentRequestDTO.setTransactionDesc("Payment from account id" + transactionChannelRequestDTO.getPayer()[1].getValue());
    buyGoodsPaymentRequestDTO.setAccountReference("Payment to " + businessShortCode);
    return buyGoodsPaymentRequestDTO;
}
Also used : GsmaParty(org.mifos.connector.common.gsma.dto.GsmaParty) BuyGoodsPaymentRequestDTO(org.mifos.connector.mpesa.dto.BuyGoodsPaymentRequestDTO)

Aggregations

GsmaParty (org.mifos.connector.common.gsma.dto.GsmaParty)2 BuyGoodsPaymentRequestDTO (org.mifos.connector.mpesa.dto.BuyGoodsPaymentRequestDTO)2