Exemplo n.º 1
0
        private T SendRequest <T>(Func <cnpOnlineResponse, T> getResponse, transactionRequest transaction)
        {
            var request = CreateRequest(transaction);
            cnpOnlineResponse response = SendToCnp(request);

            return(getResponse(response));
        }
Exemplo n.º 2
0
        private cnpOnlineRequest CreateRequest(transactionRequest transaction)
        {
            cnpOnlineRequest request = CreateCnpOnlineRequest();

            if (transaction is transactionTypeWithReportGroup)
            {
                FillInReportGroup((transactionTypeWithReportGroup)transaction);
            }
            else if (transaction is transactionTypeWithReportGroupAndPartial)
            {
                FillInReportGroup((transactionTypeWithReportGroupAndPartial)transaction);
            }
            if (transaction is authorization)
            {
                request.authorization = (authorization)transaction;
            }
            else if (transaction is authReversal)
            {
                request.authReversal = (authReversal)transaction;
            }
            else if (transaction is capture)
            {
                request.capture = (capture)transaction;
            }
            else if (transaction is captureGivenAuth)
            {
                request.captureGivenAuth = (captureGivenAuth)transaction;
            }
            else if (transaction is credit)
            {
                request.credit = (credit)transaction;
            }
            else if (transaction is echeckCredit)
            {
                request.echeckCredit = (echeckCredit)transaction;
            }
            else if (transaction is echeckRedeposit)
            {
                request.echeckRedeposit = (echeckRedeposit)transaction;
            }
            else if (transaction is echeckSale)
            {
                request.echeckSale = (echeckSale)transaction;
            }
            else if (transaction is echeckVerification)
            {
                request.echeckVerification = (echeckVerification)transaction;
            }
            else if (transaction is forceCapture)
            {
                request.forceCapture = (forceCapture)transaction;
            }
            else if (transaction is sale)
            {
                request.sale = (sale)transaction;
            }
            else if (transaction is registerTokenRequestType)
            {
                request.registerTokenRequest = (registerTokenRequestType)transaction;
            }
            else if (transaction is voidTxn)
            {
                request.voidTxn = (voidTxn)transaction;
            }
            else if (transaction is echeckVoid)
            {
                request.echeckVoid = (echeckVoid)transaction;
            }
            else if (transaction is updateCardValidationNumOnToken)
            {
                request.updateCardValidationNumOnToken = (updateCardValidationNumOnToken)transaction;
            }
            else if (transaction is cancelSubscription)
            {
                request.cancelSubscription = (cancelSubscription)transaction;
            }
            else if (transaction is updateSubscription)
            {
                request.updateSubscription = (updateSubscription)transaction;
            }
            else if (transaction is activate)
            {
                request.activate = (activate)transaction;
            }
            else if (transaction is deactivate)
            {
                request.deactivate = (deactivate)transaction;
            }
            else if (transaction is load)
            {
                request.load = (load)transaction;
            }
            else if (transaction is unload)
            {
                request.unload = (unload)transaction;
            }
            else if (transaction is balanceInquiry)
            {
                request.balanceInquiry = (balanceInquiry)transaction;
            }
            else if (transaction is createPlan)
            {
                request.createPlan = (createPlan)transaction;
            }
            else if (transaction is updatePlan)
            {
                request.updatePlan = (updatePlan)transaction;
            }
            else if (transaction is refundReversal)
            {
                request.refundReversal = (refundReversal)transaction;
            }
            else if (transaction is depositReversal)
            {
                request.depositReversal = (depositReversal)transaction;
            }
            else if (transaction is activateReversal)
            {
                request.activateReversal = (activateReversal)transaction;
            }
            else if (transaction is deactivateReversal)
            {
                request.deactivateReversal = (deactivateReversal)transaction;
            }
            else if (transaction is loadReversal)
            {
                request.loadReversal = (loadReversal)transaction;
            }
            else if (transaction is unloadReversal)
            {
                request.unloadReversal = (unloadReversal)transaction;
            }
            else if (transaction is fraudCheck)
            {
                request.fraudCheck = (fraudCheck)transaction;
            }
            else if (transaction is giftCardAuthReversal)
            {
                request.giftCardAuthReversal = (giftCardAuthReversal)transaction;
            }
            else if (transaction is giftCardCapture)
            {
                request.giftCardCapture = (giftCardCapture)transaction;
            }
            else if (transaction is giftCardCredit)
            {
                request.giftCardCredit = (giftCardCredit)transaction;
            }
            else if (transaction is queryTransaction)
            {
                request.queryTransaction = (queryTransaction)transaction;
            }
            else if (transaction is fastAccessFunding)
            {
                request.fastAccessFunding = (fastAccessFunding)transaction;
            }
            else if (transaction is payFacCredit)
            {
                request.payFacCredit = (payFacCredit)transaction;
            }
            else if (transaction is payFacDebit)
            {
                request.payFacDebit = (payFacDebit)transaction;
            }
            else if (transaction is physicalCheckCredit)
            {
                request.physicalCheckCredit = (physicalCheckCredit)transaction;
            }
            else if (transaction is physicalCheckDebit)
            {
                request.physicalCheckDebit = (physicalCheckDebit)transaction;
            }
            else if (transaction is reserveCredit)
            {
                request.reserveCredit = (reserveCredit)transaction;
            }
            else if (transaction is reserveDebit)
            {
                request.reserveDebit = (reserveDebit)transaction;
            }
            else if (transaction is submerchantCredit)
            {
                request.submerchantCredit = (submerchantCredit)transaction;
            }
            else if (transaction is submerchantDebit)
            {
                request.submerchantDebit = (submerchantDebit)transaction;
            }
            else if (transaction is vendorCredit)
            {
                request.vendorCredit = (vendorCredit)transaction;
            }
            else if (transaction is translateToLowValueTokenRequest)
            {
                request.translateToLowValueTokenRequest = (translateToLowValueTokenRequest)transaction;
            }
            else if (transaction is vendorDebit)
            {
                request.vendorDebit = (vendorDebit)transaction;
            }
            else
            {
                throw new NotImplementedException("Support for type: " + transaction.GetType().Name +
                                                  " not implemented.");
            }
            return(request);
        }
Exemplo n.º 3
0
        private async Task <T> SendRequestAsync <T>(Func <cnpOnlineResponse, T> getResponse, transactionRequest transaction, CancellationToken cancellationToken)
        {
            var request = CreateRequest(transaction);

            cnpOnlineResponse response = await SendToCnpAsync(request, cancellationToken).ConfigureAwait(false);

            return(getResponse(response));
        }
Exemplo n.º 4
0
        private string saveElement(litleFile litleFile, litleTime litleTime, string filePath, transactionRequest element)
        {
            string fPath;

            fPath = litleFile.createRandomFile(requestDirectory, Path.GetFileName(filePath), "_temp_batchRequest.xml", litleTime);

            litleFile.AppendLineToFile(fPath, element.Serialize());

            return(fPath);
        }